|
patryn Apprentice
Joined: 26 Sep 2001 Posts: 124
|
Posted: Fri Aug 11, 2006 6:02 am
Neat Trick |
Hey all.
While I've been busy replacing my Loop structures with varous functions that make use of regular expressions in order to speed up my code, I came across a really nifty trick in Zmud which I thought might be worth sharing.
Now, this is probably a bug, although I'm not sure if it's a bug that this trick works or that under normal circumstances it wouldn't work.
If your zmud settings have at least one active OnInput trigger, then it is possible to execute commands (as if typed into the command line) during the runtime of a subregex expression. If no OnInput triggers are active, then this is pretty much impossible. (Or more accurately, my efforts of accomplishing this have failed.)
Following is a mini script which shows what I mean.
Code: |
#ALIAS testing {
test=%null
#LOOP 100 {#ADDITEM test %i}
#NOOP %subregex( @test, "(\d+)", "%exec(%%1)")
#echo Done
}
#ONINPUT "CommandTrig" {^(*)$} {#NOOP} "" {notrig} |
Test while no OnInput triggers active:
#t- CommandTrig
testing
Test while at least one OnInput trigger is active:
#t+ CommandTrig
testing
The first test should return no output except the echo of 'Done' (Note You should disable 'all' oninput triggers in your settings for this to work.. or rather not work.)
The second test should send the numbers 1 through to 100 to your mud.
I find this peculiarity very handy :)
Enjoy |
|
_________________ That which does not kill us, makes us stronger. |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Fri Aug 11, 2006 9:54 am |
This is actually a bug. The %exec function is not actually supposed to send anything to the MUD and the #NOOP command should do nothing beyond expanding any parameters it receives. The way %exec should work is that it preforms any script in its parameter and returns any output that would be sent to the MUD as a stringlist.
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
patryn Apprentice
Joined: 26 Sep 2001 Posts: 124
|
Posted: Fri Aug 11, 2006 11:53 am |
The #noop is there just to have something between the brackets. The flaw/trick still works even if you remove the #Noop, so I doubt that it has anything to do with it really.
As for the %exec... surely it should be possible to send things to the mud, or have things parsed before sending, if you explicity tell it to?
For example #noop %subregex(@test, "(\d+)", "%exec(#send %%1)") is 'supposed' to send things to the mud without parsing through aliases/triggers, isn't it?
where as something like
#noop %subregex(@test, "(\d+)", "%exec(#exec %%1)") should execute just the same as if you had typed it in the command line... shouldn't it?
If this isn't the case, I for one will definately miss this functionality in CMUD, as at the moment, these things allow me to make use of one %subregex statement in place of a loop structure.. this speeds things up infinately, especially for really large string lists... |
|
_________________ That which does not kill us, makes us stronger. |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|