Thread: Triggeraction
View Single Post
  #3  
Old 05-15-2007, 07:51 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
PHP Code:
triggeraction(x,y,"name",param0,param1,...); 
Triggeraction is used to interact between NPCs, by... triggering them, at the x/y coordinate given.

Say you have a weapon called a Hammer:
PHP Code:
function onWeaponfired() {
triggeraction(player.x+vecx(player.dir)*2,player.y+vecx(player.dir)*2,"Hammer",client.hammerstr);

That weapon sends a trigger at the coordinates in front of the player's current direction. The trigger is given the name "Hammer", sent with the parameter of the players hammer strength(if defined of course). Multiple parameters can be given. Then you have... let's say, a rock:

PHP Code:
function onactionHammer() {
  
this.chat="Your hammer is level" params[0] @ "!";

The rock will tell you what level your hammer is when it's hit. So in order to grab the trigger being sent, you use onactionTRIGGERNAME(), and you can do with it and the parameters as you wish.

Triggeraction can also communicate between the clientside and serverside, but I recommend triggerserver/triggerclient. Mainly because they're made specifically for that, and triggeraction was only used because it was the only available method. They do the same thing anyways, and since you're now learning, it's not like you're going to have to break the habit.
Reply With Quote