Page 2 of 3
Re: Useful scripts repository
Posted: Thu Sep 20, 2012 2:31 am
by Komag
You would make the script very close to the example:
function poisontrap()
damageTile(party.level, party.x, party.y, party.facing, 1, "poison", 50)
hudPrint("A noxious gas fills the chamber!")
end
Then just create your pressure plate and connect the pressure plate to the script with activate - poisontrap
it works to do the damage, but there is poison cloud effect or lingering poison, so I'm not exactly sure how to do that part yet
-----------------
The original thread for the insta-kill script was here:
viewtopic.php?f=14&t=3248
Re: Lua scripts
Posted: Thu Sep 20, 2012 8:49 am
by sevenbirds
Hello everyone. I'm moving my questions to this thread instead of flooding the excellent scripting example one if that is all right.
So I'm trying to create a tile that damage any player or monster that steps on it, then continuously deals damage over a period of time. Here is what I currently have.
Code: Select all
function poisontrap()
damageTile(party.level, party.x, party.y, party.facing, 1, "poison", 5)
end
This is connected to a timer called poisontimer set with the interval of 2,defaulted to stopped and calls the poisontrap function when activated. stepping on a pressure plate activates this timer, with the idea being that it will do 5 damage every 2 seconds.
I then have a counter named poisoncounter that starts at 15. poisontimer is connected and decrements poisoncounter every time it activates. This is reset when the same pressure plate is activated. My idea is that it will cause a lingering poison that does 5 damage every 2 seconds for 30 seconds, and start all over again if you step on the pressure plate. However, right now all it does is hurt you once. the lingering damage never happens. Does anyone have any idea where I went wrong?
EDIT: I solved the problem. Always make sure to restart the preview, don't just pause. the changes were not taking effect until I stopped the playtest an redid it. this works like a charm now. However, it still doesn't damage enemies as far as I can tell. Is there a way to get this to affect both enemies and the party?
Re: Lua scripts
Posted: Thu Sep 20, 2012 9:20 am
by petri
Why not just spawn a poison cloud there?
Re: Lua scripts
Posted: Thu Sep 20, 2012 9:27 am
by sevenbirds
petri wrote:Why not just spawn a poison cloud there?
It's times like this that make learning fun. Here I was trying to reinvent the wheel and that's all it took. Thank you so much!
Re: Lua scripts
Posted: Thu Sep 20, 2012 10:18 am
by Xzalander
Hah Seven, still its always good to try and look at the complicated methods also, as it opens up avenues. Perhaps you want a slightly stronger poison cloud or one that lasts longer, one that doesn't infect and only causes poison damage and so forth.
Re: Lua scripts
Posted: Thu Sep 20, 2012 11:28 am
by Montis
sevenbirds wrote:Code: Select all
function poisontrap()
damageTile(party.level, party.x, party.y, party.facing, 1, "poison", 5)
end
[...]
However, it still doesn't damage enemies as far as I can tell. Is there a way to get this to affect both enemies and the party?
When you use the code above it will always damage the tile that the player is on (and thus the party), no matter who's stepping on the pressure plate.
Edit:
If you want to damage monsters, you have to specify the square that needs to get damaged (probably the one with the pressure plate). See code by Xzalander below.
Re: help with insta-death square script and other Qs
Posted: Thu Sep 20, 2012 12:33 pm
by Komag
I split off this section of the discussion into a new thread, to try to maintain the script repository thread as mostly just a place for finished scripts

Re: help with insta-death square script and other Qs
Posted: Thu Sep 20, 2012 12:39 pm
by Montis
Komag wrote:I split off this section of the discussion into a new thread, to try to maintain the script repository thread as mostly just a place for finished scripts

Thanks a lot!
I actually took some time to make an index in the first post of that thread.

Re: Lua scripts
Posted: Thu Sep 20, 2012 1:15 pm
by Xzalander
Montis I think he means he wants the poison trap to hurt monsters as well.
In which case you simply specify the tile location instead of using party.x etc
So for example
Code: Select all
function poisontrap()
damageTile(1, 14, 14, 0, 1, "poison", 5)
end
That would cause the poison effect to happen on Floor 1, Grid Reference 14x 14y. 0 is the direction (north).
Re: Lua scripts
Posted: Thu Sep 20, 2012 1:29 pm
by Montis
Xzalander wrote:Montis I think he means he wants the poison trap to hurt monsters as well.
Uh yes, I just said that he will always damage the party with the code that he used. I edited the post above to make it a bit more clear what I meant.