Some help with tempTrigger()

Post Reply
MUDgate
Posts: 7
Joined: Tue Oct 21, 2014 10:14 pm

Some help with tempTrigger()

Post by MUDgate »

Since there is no lua for dummies or any form of noob instructions or translations of all the coding terminology out there i've been really struggling learning to get all scripty with my mudlet. I decided to try and invent a trigger thing that would walk me around a cave full of orcs and randomly stop when i see one and whoop it's ass, take it's loot and walk on.

So i did a little research and decided to send() the direction i wanted to go by triggering off the first line of the room description and have him walk around in a circuit. Then I thought of the idea to use a combo of disableTrigger()/enableTrigger() commands so that if there happens to be an orc in a room my toon walks into he disables the walking loop, picks a fight, loots the orc, and then enables the walking loop.

So instead of making dozens of individual triggers i thought that if i were to make a script full of tempTriggers with room descriptions that i could just call it as a function after combat and my toon would look at the room and trigger the proper direction.

This is what i tried for my test run:
Code: [show] | [select all] lua
tempTrigger("The corridors in the lower caves are unrefined and narrow.", [[send("north")]])
It worked great the first time but then everytime i would retest it, it would double the "north" command till i had like 10 of them. I deleted it. But even after deleting the damn thing i get like 10 "north" commands every time i enter that first corridor.

How do i fix this mess?

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Some help with tempTrigger()

Post by Vadi »

Well you've done pretty well, just the manual for tempTrigger says: "Creates a temporary substring trigger that executes the code whenever it matches. The function returns the trigger ID for subsequent enableTrigger(), disableTrigger() and killTrigger() calls. The trigger will go off multiple times until you disable or destroy it."

Which is pretty clear that it will go off multiple times, not once after you create it - so you've created many, many triggers. See also the example of how to have only 1 trigger going at a time in the same page. Restarting Mudlet will clear all temporary things.

MUDgate
Posts: 7
Joined: Tue Oct 21, 2014 10:14 pm

Re: Some help with tempTrigger()

Post by MUDgate »

I was able to use resetProfile() to stop the "north" command from being spammed every time i walked through that corridor but now the trigger wont work, at all, even after i deleted the resetProfile() line from the trigger.

I don't know what manual your reading but mudlet.org's (mudlet.org) section on tempTriggers is barely a paragraph long and doesn't mention anything about substrings. It is far from comprehensive.

The section on disabling and enabling triggers is even less:

"enableTrigger() disableTrigger()" Is ALL the info they give you on the subject.

How do i use them? What goes in the ()? The name of the trigger i would guess, But then how would i know what the name of a given tempTrigger is?

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Some help with tempTrigger()

Post by Vadi »

The same manual, the section where every function is described in detail: http://wiki.mudlet.org/w/Manual:Mudlet_ ... empTrigger

MUDgate
Posts: 7
Joined: Tue Oct 21, 2014 10:14 pm

Re: Some help with tempTrigger()

Post by MUDgate »

Okay so this is what I've turned it into:
Code: [show] | [select all] lua
if step1 then killTrigger(step1) end
step1 = tempTrigger("The corridors in the lower caves are unrefined and narrow.", [[send("north") resetFormat()]])
I got it to stop adding "north' commands, it just does the one. But i couldn't get it to turn off. Even if i deleted the trigger it would still trigger a "north" command off that one substring.

The only thing that seems to prevent this ghost trigger from firing is resetProfile(). It seemed to work, no more ghost trigger. So i remade the trigger and tried using resetProfile() in an alias thinking that I can use it to stop my walking loop when i run into an orc.

But the trigger wont fire!

resetProfile() seems to not just shut down the tempTrigger() but prevent it from reestablishing it's self and firing again.

Ideally I'd like to fill a script with these tempTrigger room descriptions and use them in an event with raiseEvent() to re-initiate my walking loop after i kill an orc. I thought that using disalbeKey() would give me blanket control of my tempTriggers since i plan on having them all in one script. But after testing, and my experience with resetProfile, it doesn't seem like disableKey will stop the tempTriggers once they've been created.

It feels like I'd have to disableTrigger() each specific trigger depending on what room I'm in in order to keep from being walked passed any orcs.

Any ideas\advice on how I can get the kind of general control of my tempTriggers I want?

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Some help with tempTrigger()

Post by Vadi »

MUDgate wrote:Okay so this is what I've turned it into:
Code: [show] | [select all] lua
if step1 then killTrigger(step1) end
step1 = tempTrigger("The corridors in the lower caves are unrefined and narrow.", [[send("north") resetFormat()]])
I got it to stop adding "north' commands, it just does the one. But i couldn't get it to turn off. Even if i deleted the trigger it would still trigger a "north" command off that one substring.
Deleting the trigger that created the trigger won't do anything to the trigger that it made, because it lives on its own. To delete it, you would do:
Code: [show] | [select all] lua
if step1 then killTrigger(step1) end
MUDgate wrote:The only thing that seems to prevent this ghost trigger from firing is resetProfile(). It seemed to work, no more ghost trigger.
Yeah, because that (same as a Mudlet restart) clears all temporary triggers.
MUDgate wrote: So i remade the trigger and tried using resetProfile() in an alias thinking that I can use it to stop my walking loop when i run into an orc.

But the trigger wont fire!

resetProfile() seems to not just shut down the tempTrigger() but prevent it from reestablishing it's self and firing again.
Using resetProfile() as part of your actual process is a bad idea. It also doesn't prevent reestablishing triggers, you must have had something else going on.
MUDgate wrote: Ideally I'd like to fill a script with these tempTrigger room descriptions and use them in an event with raiseEvent() to re-initiate my walking loop after i kill an orc. I thought that using disalbeKey() would give me blanket control of my tempTriggers since i plan on having them all in one script. But after testing, and my experience with resetProfile, it doesn't seem like disableKey will stop the tempTriggers once they've been created.
disableKey() is for keys combinations. I think you mean disableTrigger(). disableKey() indeed won't do anything to a trigger.
MUDgate wrote: It feels like I'd have to disableTrigger() each specific trigger depending on what room I'm in in order to keep from being walked passed any orcs.

Any ideas\advice on how I can get the kind of general control of my tempTriggers I want?
I'd just create triggers in the editor, not using temporary triggers, in a group and enableTrigger()/disableTrigger() on that entire group to turn things on and off. Far simpler setup.

MUDgate
Posts: 7
Joined: Tue Oct 21, 2014 10:14 pm

Re: Some help with tempTrigger()

Post by MUDgate »

I didn't know disableTrigger() worked for trigger groups. That's perfect. Thank you.

Post Reply