How to check which item is in alcove?

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
LordofKral
Posts: 27
Joined: Mon Feb 10, 2014 5:56 pm

Re: How to check which item is in alcove?

Post by LordofKral »

germanny wrote:

Code: Select all

for i in entitiesAt(place.level,place.x,place.y) do
        if i.name == "that_item" then
		hudPrint("Your item is found: "..i.name)
	else return false
        end
end
Forgot to paste the 'end' parts^^

No problem XD
User avatar
THOM
Posts: 1274
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: How to check which item is in alcove?

Post by THOM »

Funny thing with this script:

Code: Select all

  function checkPoison()
         for i in mouth_socket_poison_1:containedItems() do
             if i.name == "potion_poison"
            then
                playSound("consume_potion")
           	timer_poison_door:activate()
                setMouseItem(spawn("flask"))
 --               containedItems:destroy()
              return
             end
          end
           
        end
The sound is played, the timer is activated - but no flask appears in the mousepointer.. ????

And apart from that: I also try to destroy the poison potion in the mouth-socket (in the script above still disabled with -- ) but I can't figure out how to do that... :-(
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
User avatar
DesperateGames
Posts: 90
Joined: Sun Oct 06, 2013 1:54 pm

Re: How to check which item is in alcove?

Post by DesperateGames »

I think setting the mouse item might not work because the engine will execute the script first which will set the item under the mouse cursor to the flask and then deletes the item from your mouse cursor. (Wild guessing here...) I just tried a similar thing with a pressure plate and it did not work for me as well: When I walked on the plate, it was possible to add something under the mouse cursor, if I put an item on the plate it did not work. It works however if you start a timer with a 0.001 second interval which then creates the flask under the cursor ;-)

Regarding destroying the potion: if you use i:destroy() instead of containedItems:destroy() it should work.
User avatar
THOM
Posts: 1274
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: How to check which item is in alcove?

Post by THOM »

Perfect - works!!! :idea:

Hey DesperateGames - are you the scripting-expert or what?? :D
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
User avatar
DesperateGames
Posts: 90
Joined: Sun Oct 06, 2013 1:54 pm

Re: How to check which item is in alcove?

Post by DesperateGames »

Ah nah, there are people here on the forum which can do far more impressive things than I could, but I'm keeping an eye on the forum as it is the perfect excuse for taking a break from work and typing a response ;)
Darsithis
Posts: 51
Joined: Wed Jul 24, 2013 6:31 pm

Re: How to check which item is in alcove?

Post by Darsithis »

I'm trying something posted earlier in the thread:

Code: Select all

function CheckPlantAlcove()

	for alcoveItem in plantAlcove:containedItems() do
		print (alcoveItem.name)
	end
	
	if containsItems(plantAlcove, "cave_nettle") 
		and containsItems(plantAlcove, "tar_bead")
		and containsItems(plantAlcove, "slime_bell")		
		and containsItems(plantAlcove, "blooddrop_blossom")		
		and containsItems(plantAlcove, "grim_cap")	
		and containsItems(plantAlcove, "milkreed")
	then
		plantDoor:open()
		plantSecret:activate()
	else
		plantDoor:close()	
	end
end

function containsItems(entity, item)
   for i in entity:containedItems() do
      if i.name == item then
         return true
      end
   end
   -- if we get here the item was not found
   return false
end
The idea is that after you put 1 of each of the 6 potion ingredients in the alcove, the door and secret will execute. The print(alcoveItem.name) however shows that it only executes once, ever, for the first item placed. Subsequent items placed in the alcove do not execute the script. Any ideas why?
Post Reply