Page 1 of 2
Check Item Is Missing?
Posted: Wed Oct 17, 2012 12:45 pm
by TheDudeD09
I'm trying to make a trap which is a daemon head with two blue gems for eyes at the end of a corridor. What I want to happen is if the player removes EITHER of the eyes, a gate slams shut trapping them, secret doors open to reveal they are now in a square room with monsters in it.
The script I'm currently using is the alcove item check script, and having the 'else' as my effect, but its not working out so great.
Then I want to have the gate open again once both monsters are dead so the player can leave with his fought for treasures, which I'm going to use a timer for and a script checking for entities.
Any help on the check if blue gems are missing?
Re: Check Item Is Missing?
Posted: Wed Oct 17, 2012 1:11 pm
by Grimwold
Could you just link the eye socket to a script that activates when an item is removed. connect both eyes to the same script and then when either is removed the script will run.
i.e. add a connector to the socket with the "deactivate" condition and link it to a script entity containing your "gate closing, secret door opening" function.
Re: Check Item Is Missing?
Posted: Wed Oct 17, 2012 2:11 pm
by TheDudeD09
I think I tried that and if failed, however after reading your link and altering I'm still failing so, I'll show you what I've got at the moment and then try out the deactivate way again for good measure.
Code: Select all
function hasBlueGem(entity, item)
for i in entity:containedItems() do
if i.name == item then
return
end
end
function eyeTestBlue()
if hasBlueGem(shinyEyesTrapLeft, "blue_gem") and hasBlueGem(shinyEyesTrapRight, "blue_gem") then
shinyTrapTimer:deactivate()
shinyTrapGate:open()
else
shinyTrapTimer:activate()
end
end
function stillAliveSnails()
if not findEntity("shiny_snail_1") then
if not findEntity("shiny_snail_2") then
shinyTrapGate:open()
shinyTrapTimer:deactivate()
else
shinyTrapGate:close()
trapdoorShiny_1:open()
trapdoorShiny_2:open()
trapdoorShiny_3:open()
trapdoorShiny_4:open()
trapdoorShiny_5:open()
trapdoorShiny_6:open()
end
end
end
end
local giveBlueGem = spawn("blue_gem")
local giveBlueGem2 = spawn("blue_gem")
shinyEyesTrapLeft:addItem(giveBlueGem)
shinyEyesTrapRight:addItem(giveBlueGem2)
I then have the stillAliveSnails connected to a 1 second timer, and the eyeTestBlue connected to both eye sockets. No idea what I'm doing wrong, though I'm so new to this I've no idea what I'm going anyway!
Re: Check Item Is Missing?
Posted: Wed Oct 17, 2012 2:17 pm
by TheDudeD09
Hold on I missed a trick there, you mean completely take out any scripting looking for items, because the script that starts the timer/trap is triggered simply by the removing of any item from the socket? GENIUS. and/or I was over complicating everything.
Re: Check Item Is Missing?
Posted: Wed Oct 17, 2012 2:34 pm
by TheDudeD09
Ack!! Still not working!
No idea what's going on.
So heres the code I'm using:
Code: Select all
function stillAliveSnails()
if not findEntity("shiny_snail_1") then
if not findEntity("shiny_snail_2") then
shinyTrapGate:open()
shinyTrapTimer:deactivate()
else
shinyTrapGate:close()
trapDoorShiny_1:open()
trapDoorShiny_2:open()
trapDoorShiny_3:open()
trapDoorShiny_4:open()
trapDoorShiny_5:open()
trapDoorShiny_6:open()
end
end
end
Then I have a timer set to 1 second which runs the stillAlvieSnails script. Then the two sockets both have one blue_gem in each, are set to activate always and have the connector; deactivate/timer/activate. And its still failing.
Re: Check Item Is Missing?
Posted: Wed Oct 17, 2012 3:24 pm
by Grimwold
not sure why your snail script is not working, but perhaps a different approach is to create a clone snail in
monsters.lua and add the onDie Hook.
e.g.
Code: Select all
cloneObject{
name="shiny_snail",
baseObject = "snail",
onDie = function(monster)
shiny_counter:decrement()
if shiny_counter:getValue() == 0 then
shinyTrapGate:open()
end
return true
end,
}
in the editor place 2 of these snails in your room and add a counter called
shiny_counter with initial value 2. When each snail dies the counter is reduced by 1. When it hits 0 it will activate and open shinyTrapGate.
This way there is no need for a timer, and you don't need to constantly check if the snails are dead.
Re: Check Item Is Missing?
Posted: Wed Oct 17, 2012 4:34 pm
by TheDudeD09
Although that works for cutting out the timer, at the moment that's not really the issue, its the fact that when I remove the blue gems from its eyes nothing is happening at all. Which either means the timer has something wrong, or the connections are wrong.
Re: Check Item Is Missing?
Posted: Wed Oct 17, 2012 4:50 pm
by TheDudeD09
Does the 'if not find' search the entire dungeon/level for the target or just the room? I'm really trying to make this work without having to clone the snail simply because I feel as though I shouldn't have to
Re: Check Item Is Missing?
Posted: Wed Oct 17, 2012 5:19 pm
by TheDudeD09
okay so I tried to change the script to if find entity and that half worked, but the thing is, its buggy has hell and trapped my 2/3 times in the room. However if I use if not find entity then it just doesn't seem to work at all as if its not registering that I'm removing the gems. This is so frustrating because I feel like I'm doing it 100% correct and it just wont work. Guess I'll try the clone counter out.
Re: Check Item Is Missing?
Posted: Wed Oct 17, 2012 5:35 pm
by TheDudeD09
Cloning worked a treat, though I still just cannot understand why it wouldn't work with the earlier scripting. Little bit annoying but alas.