|
Kronus Wanderer
Joined: 13 Jan 2002 Posts: 76 Location: USA
|
Posted: Sun Feb 10, 2002 9:33 am
New Problems |
Ok here is the problem. I am trying to get a number from the MUD in this form: Powerlevel [330,891/330,891] .
The red is what I am trying to get. I put that in a variable and then divide it by 10000, put that in a varible then pass it to the mud. Only.... it's not working out quite right. I will continue to play with it, but I would appreciate and help given. Thanks!!
P.S. This is what I have so far.
#var trainlevel;
#trigger {Powerlevel ~[%d~/%d~]} {#var powerlevel %1}
#MATH trainlevel { @powerlevel/10000 }
#loop 5 {train grav @trainlevel } |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Sun Feb 10, 2002 1:49 pm |
Let's start with missing parentheses. You are trying to assing %1 to @powerlevel, but %1 is not defined since the pattern of the trigger has nothing enclosed in parentheses (you must enclose stuff in parentheses to have them available in %1, %2, etc.)
Second problem: %d matches numbers, but what the MUD outputs contains a comma so %d will not match that. You need to change the pattern to either one of these:
Powerlevel ~[(%x)/(%x)~]
or:
Powerlevel~[([0-9,])/[0-9,]~]
The second pattern is more restrictive and there is less of a chance that it will fire on text that it shouldn't. However, there shouldn't be a problem with any of the two. Then, we need to remove the comma from whatever we matched. We use %replace for that and the trigger should not look like:
#TRIGGER {Powerlevel ~[(%x)/(%x)~]} {#VAR powerlevel %replace(%1, ",", "")}
Finally, you have a line that is:
#VAR trainlevel
but this line will either tell you that the variable is not defined or the value the variable contains if it is defined. It will not define the variable if it doesn't exist. To define a variable that doesn't exist (or initialize it to 0) you can do this:
#VAR trainlevel 0
Note: zMUD 6.16 and below doesn't not support floating-point operations. When you devide @powerlevel by 1000, whatever decimal fraction results, is dropped and only the integer part is returned.
Kjata |
|
|
|
Kronus Wanderer
Joined: 13 Jan 2002 Posts: 76 Location: USA
|
Posted: Sun Feb 10, 2002 6:10 pm |
Thanks for the help, but there is still a bug in it some where and I think it has to do with the #MATH command. This is what I have so far #var trainlevel 0;
#TRIGGER {Powerlevel ~[(x)~/(%x)~]} {#VAR powerlevel %replace(%1, ",", "")}
#MATH @trainlevel { @powerlevel/10000 }
#loop 5 {train grav @trainlevel }
For some odd reason the math command isn't passing the interger from the division of the @powerlevel to the @trainlevel variable. Can you give me somemore insight on why or what I did wrong? Thanks again |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Sun Feb 10, 2002 7:54 pm |
Oops, I wrote something wrong. Both %x's should not be surrounded by parenthesis. Only the first one. Like this:
Powerlevel ~[(%x)~/%x~]
Also, it might be a typo, or not, but there is a % missing for the first %x.
Finally, the variable name you pass to #MATH does not need the @. That is, this line:
#MATH @trainlevel { @powerlevel/10000 }
should be:
#MATH trainlevel { @powerlevel/10000 }
Otherwise, you are telling zMUD to put the result of the division in a variable whose name is stored in @trainlevel.
Kjata |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sun Feb 10, 2002 7:57 pm |
It's a bit complicated, but you could just do it all in one step unless you need those variables for later use.
#TRIGGER {Powerlevel ~[(x)~/(%x)~]} {#loop 5 {train grav %eval(%replace(%1, ",", "")/10000)}}
LightBulb
All scripts untested unless otherwise noted |
|
|
|
Kronus Wanderer
Joined: 13 Jan 2002 Posts: 76 Location: USA
|
Posted: Mon Feb 11, 2002 12:22 am |
Ok I got it almost working now, but I have one more question. How can you stop a loop and have it wait for a certain amount of time before finishing the loop and doing it again. Would you have to use the #wait command or could you use the #alarm command??
Thanks for all your help guys! |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Mon Feb 11, 2002 2:37 am |
You can do it with #WAIT or with #ALARM. The oficial use of #WAIT is precisely for this. However, #WAIT works as it should only in the current BETA versions. So, a solution with alarms would be something like this:
#WHILE (@thingstodo > 0) {#IF (@doloop) {do this;then do this;#ADD thingstodo -1;#VAR doloop 0;#ALARM +5 {#VAR doloop 1}}}
Kjata |
|
|
|
|
|