Hi there, I'm a first time mod creator. I'm totally happy reading all the forums but if anyone would mind being able to help me along if I have specific questions I'd be super appreciative.
Here's my first question:
I have a secret door I want to activate once my three set monsters are killed. Obviously a really long timer will do the trick, but is there an easy lua way to set this?
Mentor wanted?
- Chimera005ao
- Posts: 187
- Joined: Sun Jun 29, 2014 8:34 am
Re: Mentor wanted?
Hello, welcome.
Plenty of people around here are willing to help out I'm sure.
How I did it was by making a script entity in the editor.
Named my two snails and the door, and had a timer point to the script.
I wouldn't mind trying to help, but I've only been at it for a bit more than a month, so my knowledge might be limited. 
Plenty of people around here are willing to help out I'm sure.

How I did it was by making a script entity in the editor.
Named my two snails and the door, and had a timer point to the script.
Code: Select all
function roomWatcher()
--snail room check
if (not findEntity("snail_1")) and (not findEntity("snail_2")) then
door_1:open()
end

Re: Mentor wanted?
Chimera thank you so much! I tried to insert the code but I get an error notice?
'end' expected (to close 'function' at line 2) near '<eof>' X
I have a feeling it's something dumb that I did wrong with typing but thank you so so much for help and sticking with me!
'end' expected (to close 'function' at line 2) near '<eof>' X
I have a feeling it's something dumb that I did wrong with typing but thank you so so much for help and sticking with me!
Re: Mentor wanted?
There should be another 'end' statement to close off the function. Just type the word end right after the existing one. It's an extremely easy and common mistake to make; I do it all the time. It helps to use an application that offers error and syntax highlighting to edit your scripts, like Notepad++ or SciTE. In larger scripts, they will make these kinds of mistakes a lot easier to notice.MLE_muse wrote:Chimera thank you so much! I tried to insert the code but I get an error notice?
'end' expected (to close 'function' at line 2) near '<eof>' X
I have a feeling it's something dumb that I did wrong with typing but thank you so so much for help and sticking with me!
Code: Select all
function roomWatcher()
--snail room check
if (not findEntity("snail_1")) and (not findEntity("snail_2")) then
door_1:open()
end
end
An alternate way to do this is to add code to the monster's death event, and use that [hook] code to trigger the event to open the door.
The advantage is one less timer, and that the door's response could always be immediate upon the death of the last monster.
The disadvantage is that it's more work; the monsters should be custom creatures; so that the code in the hook runs only when those specific creatures are killed.
To use snails: place the code in the project's monsters.lua file (reload project), and on the map place or rename a door 'guardedGate'.
Place three gateKeeper snails, and run the preview. To change monster types, change the baseObject value to the name of a different monster.
I've defined health very low, that line can be erased or the value set higher.
Code: Select all
cloneObject {
name= "gateKeeper",
baseObject = "snail",
health = 5,
onDie = function()
if gatekeepers == nil then
spawn("counter", party.level, 1, 1, 1, "gatekeepers")
else gatekeepers:increment()
end
if gatekeepers:getValue() > 1 then
hudPrint("The doorway opens!")
guardedGate:open()
gatekeepers:destroy()
end
end,
}
Re: Mentor wanted?
The custom monster is, I believe, a much better solution.
Finished Dungeons - complete mods to play
- Chimera005ao
- Posts: 187
- Joined: Sun Jun 29, 2014 8:34 am
Re: Mentor wanted?
My mistake, I copied it from a slightly longer script that checks for multiple rooms and deactivates parts so I can reclose the doors XP
I guess that's an advantage of the custom monster part, don't have to worry about it reopening the door after you decide to close it.
And you don't have to name every monster.
I imagine it could get a bit painful if you have multiple monster types for a door, and repeated monsters of the same type for different doors though.
I guess that's an advantage of the custom monster part, don't have to worry about it reopening the door after you decide to close it.
And you don't have to name every monster.
I imagine it could get a bit painful if you have multiple monster types for a door, and repeated monsters of the same type for different doors though.
Re: Mentor wanted?
That makes sense. I'm just trying to think ahead for people who would kill the monsters in different orders. Perhaps just designating levers would be a better option then assigning monsters?
Re: Mentor wanted?
The code that I posted isn't affected by the order they kill the snails.MLE_muse wrote:That makes sense. I'm just trying to think ahead for people who would kill the monsters in different orders. Perhaps just designating levers would be a better option then assigning monsters?
