View Full Version : TriggerAction

06-30-2001, 11:52 AM
Can someone demonstrate an effective way to pass variables with triggeraction? For some reason I am not apprehending how to correctly pass a variable...

06-30-2001, 11:58 AM
....ok...right....for trigger action just use this simple stuff....


oh...and...i missed the main thing...but bah im lazy :D
thats all im telling :-)

06-30-2001, 12:30 PM
I haven't used the parameters of triggeraction yet, but I think this is how they would work. Let's say you want to pass a damage qand type value with this. You would call triggeraction similar to this:

triggeraction x,y,damaged,damage,type;

triggeraction, in this case, has 2 parameters. (Parameters are anything after the action type, in this case "damaged". It's a standard programming term, look it up if you're still confused.)All parameters are strings, and however many parameters are passed determines the strings. If triggeraction passes 5 parameters you'd have variables from #p(0) to #p(4). If it passed 10, you'd have from #p(0) to #p(9). In this case we're passing 2, so there's #p(0) and #p(1). You must always pass 1 parameter, or your script will not run! Of course this paramater may be empty, as in triggeraction x,y,action,; (notice nothing between the comma and semicolon.)

In this case, the parameter #p(0) contains the damage amount, and #p(1) contains the type of weapon (ie freezing, burning, shocking, normal, whatever). Here's how the recieving NPC uses this:

if (actiondamaged) {
hearts -= strtofloat(#p(0));

If an NPC was weak to freezing weapons, it could have this:

if (actiondamaged) {
if (strequals(#p(1),freezing) {
hearts -= 2*strtofloat(#p(0));
} else {
hearts -= srtofloat(#p(0));

And so on. Hope this helped.

[Edit: Added some code tags to make the script snippets look a little better.]

07-02-2001, 04:32 AM
Here is an example from my farming script im making:

//Water Can by Warcaptain
if (playertouchsme) toweapons Water Can;
if (weaponfired) {
triggeraction playerx+1.5+vecx(playerdir)*2,

// Plant by Warcaptain
if (actioniswatered) {
sleep 1;

It baisicly triggers the given action on the given X Y

Of course thats a simple version of my script

Im not giving you all of it, or it wouldnt be mine anymore ;)

07-03-2001, 12:17 AM
Bleh. Read through and noticed "passing variables"... Use the message commands to pass variables in a parameter.

triggeraction x,y,damage,#v(damagevalue),#s(damagetype);