Deciphering Code

by Unknown

Back to Mechanic's Corner.

Unknown2005-09-10 23:31:55
Hello everyone. After seeing some of the Zmud screenshots that some of you guys and gals have posted, it's inspired my to make my own. The only problem is that I have no idea how to read the coding for more complex things. I can make basic macros and stuff, even a basic target, though. Here is the code for a "targetting by numbers" script I saw looking around the forum. If you could help me understand it that would be really great.

CODE
#CLASS {Targetting}
#ALIAS t {target=%1;get_target_number}
#ALIAS get_target_number {target_once=0;targetnumber="";#t+ targetMatch;#t+ targetEnd;#t+ targetGag;ih}
#VAR target_func {%if( @targetnumber =~ "%d" & @targetnumber, @targetnumber, @target)}
#TRIGGER "targetMatch" {^~"%w(%d)~"*@target*$} {#if (!@target_once) {target_once=1;targetnumber=%1;#gag;#mxp ~Target: @targetnumber~}} "" {disable}
#TRIGGER "targetEnd" {^Number of objects~: %d} {#gag;#t- targetGag;#t- targetMatch;#t- targetEnd} "" {disable}
#TRIGGER {^You have slain*@target*$} {get_target_number}
#TRIGGER "targetGag" {*} {#gag} "" {disable}
#CLASS 0



Cheers!
Taika2005-09-10 23:57:51
ok
pretty much, you run the t alias, which will set your target to whatever you put as an argument (t dog will make the dog the target). It then runs the get_target_number alias, which sets up some triggers and variables to look through IH and find the first ocurrence of that target, and change the target to a number. once it finds one, it turns off the variables (like it does at the end).

#CLASS {Targetting} --- The class your in
#ALIAS t {target=%1;get_target_number} --- Sets the target variable, and runs the alias.
#ALIAS get_target_number {target_once=0;targetnumber="";#t+ targetMatch;#t+ targetEnd;#t+ targetGag;ih} - resets the varaibles which hold if you have found the number yet, and what that number is. Turns on the trigger to check if you've found the target, the end, and the gagging trigger. Does INFO HERE.
#VAR target_func {%if( @targetnumber =~ "%d" & @targetnumber, @targetnumber, @target)} Doesnt use this, have no idea what they are doing.
#TRIGGER "targetMatch" {^~"%w(%d)~"*@target*$} {#if (!@target_once) {target_once=1;targetnumber=%1;#gag;#mxp ~Target: @targetnumber~}} "" {disable} - the trigger that matches up with the target in INFO HERE. if you have the target set to dog, and you see "dog26134", then it will catch it. Then it checks if it already found the number: if no, it will set the number to the right one, it will set that it has found one, and it will display the target.

#TRIGGER "targetEnd" {^Number of objects~: %d} {#gag;#t- targetGag;#t- targetMatch;#t- targetEnd} "" {disable} - turns off the triggers when your done looking through INFO HERE
#TRIGGER {^You have slain*@target*$} {get_target_number} - choose a new number when youve killed the mob.
#TRIGGER "targetGag" {*} {#gag} "" {disable} - gags everything while looking for a target.
#CLASS 0 - done!
Unknown2005-09-11 00:02:18
So how would I be putting that into Zmud? Would I create a new class, then within that class put each alias and trigger etc. seperatly? and what do the { } things do?
Taika2005-09-11 00:10:45
{} are like parenthesis...
Me, cause im weird, I would do this to put it in ZMUD.

Click on CLASSES. in the new window, click on NEW. Name it whatever you want. Click the class script tab, click on TEXT, copy and paste all the lines except for the #class lines, and then click on zmud script. TADA!
Unknown2005-09-11 00:27:24
Wow, that's fast. But everytime I click the save button afterwards all of the stuff dissapears. What's with that?
Unknown2005-09-11 00:31:19
I have run across that too - think it's a glitch in zmud. I forget off hand how to work around it, but it is something like you need to save the class with a name without the code, and then open it back up and save it with the code ... does anyone remember the exact steps?
Taika2005-09-11 01:25:08
make sure you click on TEXT, then you might need to SAVE (the green check in the top right corner) before you go back to ZMUD SCRIPT.
Unknown2005-09-11 04:46:38
Thanks Taika! Now it works biggrin.gif

By the way, I found some code for health and mana bars, but they do not update until I type score. The author said to put
CODE
"" {prompt|nocr}
at the end of the trigger but everytime I save it reverts back to
CODE
"" {nocr|prompt}
. It's wierd.
Unknown2005-09-15 13:08:20
whether you have prompt|nocr or the other way round really doesn't matter. It just means the trigger is has both "prompt trigger" checked and "after linebreak" unchecked in its options.

Your prompt most likely doesn't match what the trigger needs... can you post the trigger pattern for the prompt trigger and a sample of what your own prompt looks like?
Ekard2005-09-15 17:03:04
My targetting by numbers:

#CLASS {Misc|Targetting}
#ALIAS xx {
#var tar_mob %1
#sa TAR MOB: @tar_mob
}
#VAR tar_mob {gorgog}
#TRIGGER {^~"(%w)(%d)~"} {#if %1=@tar_mob {#var target %2}}
#TRIGGER {@tar_mob} {#cw 12}
#CLASS 0

Its realy simple xx alias will set name of target like rat, lobstrosity, gorgog.
And all what i have to do is type IH and last mob on IH list will be my target now.
So if you alredy fighting with one rat and new one will appear, then dont hit IH before you kill your current one or your target ewill be changed. Just hit IH after you kill something ot enter to new room.