Help with Scripting Daemon head eyes

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

Help with Scripting Daemon head eyes

Post by Mysterious »

Hello :)

I want to know how to Script this:

2 x Daemon heads on the wall (opposite from each other)
2 x Eye sockets (one on each head)
1 x Door
1 x dm_yellow_gem (into daemon head 1)
1 x dm_blue_gem (into Daemon head 2)
1 x Counter (Initial Value set 2)

What I need to happen is when the player puts one of the Gems in each of the Daemon head eye's a door will open. It does not matter if the Gems go into left or right eyes on the Daemon heads..

The gems to open the door are the gems I have specified. No other gems can open the door..

Any help how to do this would be great thank you. :)

EDIT: I can do it with one of the eyes and with one gems and one daemon head EG:

function End2()

for i in end1:containedItems() do --- end1 is the eye socket --
if i.name == "dm_gem_blue" then --- One of the Gems --
i:destroy()
enddoor:open() --- The Door that opens --

playSound("level_up")

end
end
end

Don't know how to do it with both eyes and gems in the two daemon heads..
Last edited by Mysterious on Fri Nov 08, 2013 2:29 am, edited 1 time in total.
User avatar
DesperateGames
Posts: 90
Joined: Sun Oct 06, 2013 1:54 pm

Re: Help with Scripting Daemon head eyes

Post by DesperateGames »

Hello Mysterious,

fortunately I had something similiar ready for copy and paste from my own mod:

Code: Select all

solved=false

function checkDemonEyes()
	demon1= false
	demon2= false
	
	for i in eye_socket_left_1:containedItems() do
		if i.name =="dm_yellow_gem" or  i.name =="dm_blue_gem" then
			demon1 = true
		end
	end
	
	for i in eye_socket_right_1:containedItems() do
		if i.name =="dm_yellow_gem" or  i.name =="dm_blue_gem" then
			demon1= true
		end
	end
	
       for i in eye_socket_left_2:containedItems() do
		if i.name =="dm_yellow_gem" or  i.name =="dm_blue_gem" then
			demon2 = true
		end
	end
	
	for i in eye_socket_right_2:containedItems() do
		if i.name =="dm_yellow_gem" or  i.name =="dm_blue_gem" then
			demon2= true
		end
	end

	if demon1 and demon2 and not(solved)then
      solved=true
		dungeon_door_portcullis_6:open()
	end
end

place this code in a script entity in the editor and let the eye sockets execute the function checkDemonEyes() on "activate". You need to adapt the names of the eyesockets of the demon heads in the code above, and you need to set the name of the door that should open. I repeat myself with the "for" loops, it would better to put these in a function like checkYellowBlueonSocket(socket) but I think the above is easier to understand. This method does not use a counter, please post again if the counter is required, it can be added too.
User avatar
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

Re: Help with Scripting Daemon head eyes

Post by Mysterious »

Hi

Thank you kindly for that script :)

Well there was more to it than I first thought.. Will give it a try
Thxs again :)

EDIT: Yes it works exactly the way I wanted.. Thxs for the script.. :)
Post Reply