Temp Trigger

Wennef
Posts: 43
Joined: Sun Apr 11, 2010 3:48 am

Temp Trigger

Post by Wennef »

I don't understand how it's done from reading the manual. Can anyone give me an example? I'm gonna do it for my Achaea antitheft where armour needs balance so I would do wear armournumber when I remove my armour only after I see You have recovered balance on all limbs. Also, reading from the manual,
Contrary to tempTimers, tempTriggers lives throughout the entire session until it is explicitly disabled or killed.
Is this something I should be worried about?

Wyd
Posts: 54
Joined: Wed Mar 24, 2010 11:56 pm

Re: Temp Trigger

Post by Wyd »

When you call tempTrigger(), it returns a trigger ID that you can use to enable/disable/kill the trigger later on.

For example, you might do something like this

Code: Select all

Trigger: 
You remove some armour.

Script:
remove_trigger_id = tempTrigger("You have recovered balance on all limbs.", [[ send("wear armour") ]])
tempTimer(10.0, [[killTrigger( ]] .. remove_trigger_id .. [[)]])
Which would create a trigger that would rewear your armour when you regain balance, and then delete it again after 10 seconds.

Wyd

Wennef
Posts: 43
Joined: Sun Apr 11, 2010 3:48 am

Re: Temp Trigger

Post by Wennef »

How about if I wanna kill it when I have this message "You are now wearing a suit of some armour."?

Wyd
Posts: 54
Joined: Wed Mar 24, 2010 11:56 pm

Re: Temp Trigger

Post by Wyd »

Simply remove the tempTimer() line, and instead create another tempTrigger, which delete both triggers

For example

Code: Select all

Trigger: 
You remove some armour.

Script:
balance_trigger_id = tempTrigger("You have recovered balance on all limbs.", [[ send("wear armour") ]])
wear_trigger_id = tempTrigger("You are now wearing a suit of some armour.", [[ killTrigger(]] .. balance_trigger_id .. [[) killTrigger(]] .. wear_trigger_id .. [[)]])
The bit at the end is a little confusing, but basically all it does is calls the killTrigger() functions with the two temp trigger ids

Wennef
Posts: 43
Joined: Sun Apr 11, 2010 3:48 am

Re: Temp Trigger

Post by Wennef »

Okay, I have this now.

Code: Select all

if matches[2] == "a suit of scale mail" then
	remove_armour_trigger_id = tempTrigger("You have recovered balance on all limbs.", [[ send("wear " .. myarmour) ]])
	wear_armour_trigger_id = tempTrigger("You are now wearing a suit of scale mail.", [[killTrigger(]] .. remove_armour_trigger_id .. [[) killTrigger(]] .. wear_armour_trigger_id .. [[)]])
elseif table.contains(wornitems, matches[2]) then
	table.insert(wearqueue,1,wornitems[matches[2]])
	rewear()
end
But every time I regain my balance, weirdly it still tries to wear my worn mail. It should have killed it when I did You are now wearing a suit of scale mail. so... What's wrong with this now? :(

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Temp Trigger

Post by Heiko »

[quote="Wennef"]Okay, I have this now.

Code: Select all

remove_armour_trigger_id = tempTrigger("You have recovered balance on all limbs.", [[ send("wear " .. myarmour) ]])[/quote]

Your error is that the trigger script will use the value of myarmour from back when the trigger was made. If you want to use the actual value of this variable at the time the script is run you'll need code like this: _G["myarmour"] - _G is the global table where Lua stores all variables and functions.

Wennef
Posts: 43
Joined: Sun Apr 11, 2010 3:48 am

Re: Temp Trigger

Post by Wennef »

So, I just change that to this?

Code: Select all

remove_armour_trigger_id = tempTrigger("You have recovered balance on all limbs.", [[ send("wear " .. _G["myarmour"]) ]])
I changed to that and still I rewear on balance even if I've already worn the mail. :cry:

Wyd
Posts: 54
Joined: Wed Mar 24, 2010 11:56 pm

Re: Temp Trigger

Post by Wyd »

In that case, it seems like the tempTimer/killTrigger functions aren't firing.

If you haven't fixed it by the time I get home, I'll take a look

Wennef
Posts: 43
Joined: Sun Apr 11, 2010 3:48 am

Re: Temp Trigger

Post by Wennef »

T_____T Yeah still not working. >.> it's easier in zmud but I wanna learn mudlet.

Knute
Posts: 87
Joined: Fri Mar 05, 2010 12:08 am

Re: Temp Trigger

Post by Knute »

Are you sure that you have the wearing message correct?

Also, you need a semi-colon (;) between your killTrigger commands otherwise it is read as one command rather than 2, so it won't fire.

Furthermore, what is the rewear function that is being called at the end? Just curious.

Post Reply