Page 1 of 1

Mentor wanted?

Posted: Mon Aug 11, 2014 3:36 am
by MLE_muse
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?

Re: Mentor wanted?

Posted: Mon Aug 11, 2014 4:09 am
by Chimera005ao
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.

Code: Select all

function roomWatcher()
	--snail room check
	if (not findEntity("snail_1")) and (not findEntity("snail_2")) then
        door_1:open()
   end
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. :lol:

Re: Mentor wanted?

Posted: Mon Aug 11, 2014 8:16 pm
by MLE_muse
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!

Re: Mentor wanted?

Posted: Mon Aug 11, 2014 9:09 pm
by Isaac
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!
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.

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,
}
** https://www.dropbox.com/s/zkilkq13dgzju ... 20Gate.zip

Re: Mentor wanted?

Posted: Tue Aug 12, 2014 4:32 am
by Komag
The custom monster is, I believe, a much better solution.

Re: Mentor wanted?

Posted: Tue Aug 12, 2014 6:00 am
by Chimera005ao
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.

Re: Mentor wanted?

Posted: Wed Aug 27, 2014 7:44 pm
by MLE_muse
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?

Posted: Thu Aug 28, 2014 1:53 am
by Isaac
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?
The code that I posted isn't affected by the order they kill the snails. 8-)