Idea : Horse dismount tracking script

... A place to ask for help on any topic whether it be starting out to player killing to IT issues.
byrg
Posts: 394
Joined: Fri Aug 07, 2015 8:56 pm

Re: Idea : Horse dismount tracking script

Post by byrg » Sat Aug 27, 2016 1:13 am

Taziar wrote:Name the triggers, and put the {disable} tag on them. Then either use an #ALIAS or #ONINPUT to enable the trigger when you want to use it. #T+ {triggerName} will turn it on. Then put #T- {triggerName} inside the trigger so that after it operates it turns itself back off.

#TRIGGER "triggerName" {pattern} {trigger operations} "" {disable}

This also optimizes zMud to be less laggy as each new line is not matched against a {disable} trigger. Imagine thousands of triggers checking every new line, turn most off and only have them on right before you need them will help greatly with that.

#T+ #T- will also turn on/off #CLASS so you could do that also... just turn the class on when you need it and off when you dont. No way to false trigger then.
Nice! I've played with #T+ and #T- before, but never knew about oninput - that solves this pretty much perfectly. Thanks!!! :D

byrg
Posts: 394
Joined: Fri Aug 07, 2015 8:56 pm

Re: Idea : Horse dismount tracking script

Post by byrg » Sat Aug 27, 2016 1:25 am

Incorporating Taziar's suggestions, the triggers start disabled, and enable when "ride" or "dism" are entered as commands, and then disable themselves again after firing, which should negate the worry of someone else talking/chatting/whatever to trigger them, which I would argue means we can just use one trigger for mount and dismount again, and take out the newline character - that makes this a fair bit simpler. Also added a 3 second timer to the ride and dism oninput triggers, so that if you ride while already riding or dism while not riding, the triggers will shut back off 3 seconds later.

Code: Select all

#CLASS {RandomHorseThing}
#VAR lonelyhorse 0
#VAR startingcolor ""
#TRIGGER DismTrigger {you stop riding %1} {#VAR startingcolor %roomcol();#CALL %maplocked( 0);#CALL %roomcol(,lightgreen);#CALL %maplocked( 1);#VAR lonelyhorse %mapvnum();#T- {DismTrigger}} RandomHorseThing disable
#TRIGGER RideTrigger {you start riding %1} {#CALL %maplocked( 0);#IF (@startingcolor = "") {} {#CALL %roomcol(@lonelyhorse,@startingcolor);};#CALL %maplocked( 1);#VAR startingcolor "";#VAR lonelyhorse 0;#T- {RideTrigger}} RandomHorseThing disable
#ONINPUT {ride} {#T+ {RideTrigger};#WAIT 3000;#T- {RideTrigger}}
#ONINPUT {dism} {#T+ {DismTrigger};#WAIT 3000;#T- {RideTrigger}}
#ALIAS horseloc {#ECHO %ansi(green) You left a horse: %replace(%pathexpand(%pathfrom(,@lonelyhorse)),"|",";")}
#ALIAS gotohorse {#WALK @lonelyhorse}
#ALIAS forgethorse {#CALL %maplocked( 0);#CALL %roomcol(@lonelyhorse,@startingcolor);#CALL %maplocked( 1);#VAR lonelyhorse 0;#VAR startingcolor "";}
#CLASS 0

Taziar
Posts: 961
Joined: Sat Mar 21, 2015 10:28 pm

Re: Idea : Horse dismount tracking script

Post by Taziar » Sat Aug 27, 2016 1:58 am

Couple things I noticed....
First off never use #WAIT command... can do some bad things and is a known bug in zMud. Instead use #ALARM to create time related triggers.
Second, when using #ONINPUT the way you did any time in any part of an input that contains the word ride will trigger. Need to use ^ and $ to manage them fully.. which can be challenging.

Examples:

#ONINPUT {ride} {quit}

typing: I like to ride my horse

This would quit you out of the game.

#ONINPUT {^ride} {quit}

typing: I like to ride my horse

Should not trigger... but typing ride with anything after it will. This will be the best use for the script I think.

#ONINPUT {^ride$} {quit}

typing: ride

Only typing ride by itself will send the quit command. Use this style for the dism command.

byrg
Posts: 394
Joined: Fri Aug 07, 2015 8:56 pm

Re: Idea : Horse dismount tracking script

Post by byrg » Sat Aug 27, 2016 2:04 am

Taziar wrote:Couple things I noticed....
First off never use #WAIT command... can do some bad things and is a known bug in zMud. Instead use #ALARM to create time related triggers.
Second, when using #ONINPUT the way you did any time in any part of an input that contains the word ride will trigger. Need to use ^ and $ to manage them fully.. which can be challenging.

Examples:

#ONINPUT {ride} {quit}

typing: I like to ride my horse

This would quit you out of the game.

#ONINPUT {^ride} {quit}

typing: I like to ride my horse

Should not trigger... but typing ride with anything after it will. This will be the best use for the script I think.

#ONINPUT {^ride$} {quit}

typing: ride

Only typing ride by itself will send the quit command. Use this style for the dism command.
Interesting... always used wait in cmud without issue... that another difference between the two?
I kinda figured that with ride and dism - but in this case also didn't see it as a huge issue considering all its doing is enabling a trigger for a few seconds - but good call, can definitely be better.

Taziar
Posts: 961
Joined: Sat Mar 21, 2015 10:28 pm

Re: Idea : Horse dismount tracking script

Post by Taziar » Sat Aug 27, 2016 2:07 am

Yeah, think #WAIT works in cMud... reading the forums at one point it has to do with the fact that cMud is multi threaded and zMud isn't... something like that. I didn't fully comprehend the reasoning but I quit using the command after reading some of the forum posts about it and how it doesn't work as intended in zMud. Think it was Zugg that recommend using alarms instead.

just FYI...
Looking at the following two pages closely shows why not to use #WAIT in zMud.

zMud #WAIT command description http://forums.zuggsoft.com/modules/mx_k ... =doc&k=423
cMud #WAIT command description http://forums.zuggsoft.com/modules/mx_k ... =3&a=%23WA
Last edited by Taziar on Sat Aug 27, 2016 2:17 am, edited 1 time in total.

byrg
Posts: 394
Joined: Fri Aug 07, 2015 8:56 pm

Re: Idea : Horse dismount tracking script

Post by byrg » Sat Aug 27, 2016 2:16 am

Taziar wrote: #ONINPUT {^ride} {quit}
typing: I like to ride my horse
Should not trigger... but typing ride with anything after it will. This will be the best use for the script I think.

#ONINPUT {^ride$} {quit}
typing: ride
Only typing ride by itself will send the quit command. Use this style for the dism command.
The only other issue I see here is that it's right back to our original problem of spamming too fast and getting a prompt before the commands again, then. If I'm spamming quickly and a ride or dism fires after a prompt, with the ^ at the beginning, it won't fire, wont enable the triggers, and brings us back to our original issue. That seems to be where this gets messy regardless.

I do like having the oninputs though, because at least this way we're just enabling and disabling a trigger if something gets spoken, vs breaking the highlight script and leaving green rooms on the map everywhere.

byrg
Posts: 394
Joined: Fri Aug 07, 2015 8:56 pm

Re: Idea : Horse dismount tracking script

Post by byrg » Sat Aug 27, 2016 2:22 am

Alright, so knowing #WAIT is no good for zmud, swapping that out for #ALARM leaves us with this... Also changed the dism oninput to dism$ - that should at least stop anywhere where something comes after it... not sure there's much else to be done considering the prompt issue?

Code: Select all

#CLASS {RandomHorseThing}
#VAR lonelyhorse 0
#VAR startingcolor ""
#TRIGGER DismTrigger {you stop riding %1} {#VAR startingcolor %roomcol();#CALL %maplocked( 0);#CALL %roomcol(,lightgreen);#CALL %maplocked( 1);#VAR lonelyhorse %mapvnum();#T- {DismTrigger}} RandomHorseThing disable
#TRIGGER RideTrigger {you start riding %1} {#CALL %maplocked( 0);#IF (@startingcolor = "") {} {#CALL %roomcol(@lonelyhorse,@startingcolor);};#CALL %maplocked( 1);#VAR startingcolor "";#VAR lonelyhorse 0;#T- {RideTrigger}} RandomHorseThing disable
#ONINPUT {ride} {#T+ {RideTrigger};#ALARM {+3} {#T- {RideTrigger}} RandomHorseThing}
#ONINPUT {dism$} {#T+ {DismTrigger};#ALARM {+3} {#T- {DismTrigger}} RandomHorseThing}
#ALIAS horseloc {#ECHO %ansi(green) You left a horse: %replace(%pathexpand(%pathfrom(,@lonelyhorse)),"|",";")}
#ALIAS gotohorse {#WALK @lonelyhorse}
#ALIAS forgethorse {#CALL %maplocked( 0);#CALL %roomcol(@lonelyhorse,@startingcolor);#CALL %maplocked( 1);#VAR lonelyhorse 0;#VAR startingcolor "";}
#CLASS 0

Taziar
Posts: 961
Joined: Sat Mar 21, 2015 10:28 pm

Re: Idea : Horse dismount tracking script

Post by Taziar » Sat Aug 27, 2016 2:34 am

Using ^ and $ in the #ONINPUT trigger only affect pattern matching for what is typed into the command line.

If you do #ONINPUT {^dism$} then only typing: dism (and then enter) will trigger. If you leave off the ^ in front then something like asdfasdgdism (enter) will trigger.

Not 100% sure if this matters but I would remove {} around the +3 after the #ALARM... think it should be...

#ALARM +3 {#T- {RideTrigger}}

byrg
Posts: 394
Joined: Fri Aug 07, 2015 8:56 pm

Re: Idea : Horse dismount tracking script

Post by byrg » Sat Aug 27, 2016 2:37 am

Taziar wrote:Using ^ and $ in the #ONINPUT trigger only affect pattern matching for what is typed into the command line.

If you do #ONINPUT {^dism$} then only typing: dism (and then enter) will trigger. If you leave off the ^ in front then something like asdfasdgdism (enter) will trigger.

Not 100% sure if this matters but I would remove {} around the +3 after the #ALARM... think it should be...

#ALARM +3 {#T- {RideTrigger}}
Nice. Really need to read up on these more, evidently - thanks for all the help with this!

Also - the bracket difference is apparently a zmud/cmud one as well - the zmud doc shows it as you posted, the cmud doc the way I wrote - translating this back to zmud is still throwing me off a bit!

byrg
Posts: 394
Joined: Fri Aug 07, 2015 8:56 pm

Re: Idea : Horse dismount tracking script

Post by byrg » Sat Aug 27, 2016 2:41 am

So then, updated once again:

Code: Select all

#CLASS {RandomHorseThing}
#VAR lonelyhorse 0
#VAR startingcolor ""
#TRIGGER DismTrigger {you stop riding %1} {#VAR startingcolor %roomcol();#CALL %maplocked( 0);#CALL %roomcol(,lightgreen);#CALL %maplocked( 1);#VAR lonelyhorse %mapvnum();#T- {DismTrigger}} RandomHorseThing disable
#TRIGGER RideTrigger {you start riding %1} {#CALL %maplocked( 0);#IF (@startingcolor = "") {} {#CALL %roomcol(@lonelyhorse,@startingcolor);};#CALL %maplocked( 1);#VAR startingcolor "";#VAR lonelyhorse 0;#T- {RideTrigger}} RandomHorseThing disable
#ONINPUT {^ride} {#T+ {RideTrigger};#ALARM +3 {#T- {RideTrigger}}}
#ONINPUT {^dism$} {#T+ {DismTrigger};#ALARM +3 {#T- {DismTrigger}}}
#ALIAS horseloc {#ECHO %ansi(green) You left a horse: %replace(%pathexpand(%pathfrom(,@lonelyhorse)),"|",";")}
#ALIAS gotohorse {#WALK @lonelyhorse}
#ALIAS forgethorse {#CALL %maplocked( 0);#CALL %roomcol(@lonelyhorse,@startingcolor);#CALL %maplocked( 1);#VAR lonelyhorse 0;#VAR startingcolor "";}
#CLASS 0

Post Reply