Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
zex0s
Wanderer


Joined: 29 Jun 2003
Posts: 64

PostPosted: Sun Jun 29, 2003 4:09 am   

What am I doing wrong here???
 
#VARIABLE %1 %2
#VARIABLE level %1
#MATH prvlevel %1-1
#VARIABLE 1 0
#VARIABLE T1 @{%1}
#VARIABLE T2 @{@prvlevel}
#MATH xpmax @T1-@T2
#ECHO %1 @xpmax

At this point, echo %1 @xplevel is showing the correct value... however, the next set causes an as of yet unknown problem.

#VARIABLE %1 %2
#VARIABLE level %1
#MATH prvlevel %1-1
#VARIABLE 1 0
#VARIABLE T1 @{%1}
#VARIABLE T2 @{@prvlevel}
#MATH xpmax @T1-@T2
#VARIABLE %1 @xpmax
#ECHO %1 @xpmax

At this point, the Echo command gives me incorrect info..

What I am trying to do is take a series of lines, parse them, and assign variables..

[Level: 57] [Experience Required: 16400000]
[Level: 58] [Experience Required: 17200000]

etc.. the script is supposed to figure out the xp differences in each level, and assign those differences to a variable with the levels name.. but while the math is coming out right before I assign the values to the variables, when I assign them, the values get changed.. why??
Reply with quote
mimique6
Newbie


Joined: 09 Jan 2003
Posts: 9
Location: USA

PostPosted: Sun Jun 29, 2003 4:18 am   
 
#VARIABLE %1 %2
I assume you're pulling numbers out of a trigger? Please explain what is being represented by '%1' and '%2' (level/exp?)
Also, is
[Level: 57][Experience Required: 16400000]
an outputted message from the mud, or what you expect your system to show you?
Reply with quote
zex0s
Wanderer


Joined: 29 Jun 2003
Posts: 64

PostPosted: Sun Jun 29, 2003 4:29 am   
 
[Level: 57] [Experience Required: 16400000]
[Level: 58] [Experience Required: 17200000]
those are the lines the mud sends..
Level: %1 Experience Required: %2 are assigned in the trigger, respectively.. Now, there are 60 total levels shown, one right after another. Now.. in this case, I would want @58 's value to become 800000 as that is the difference between the two, and would want this to continue as high as the list goes. the #var 1 0 sets @1 to 0 because the list shows level 1 as having 1xp, which screws up the math in all the rest of them..
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun Jun 29, 2003 6:19 am   
 
The problem is fairly simple, you replaced the actual experience required -- 17,200,000 for level 58 -- with a much lower value -- 800,000 (assuming that level 57 was still correct). Therefore, when you calculate level 59 your answer will be high by the same amount you subtracted -- 16,400,000. Since you actually start messing things up back at level 1, the amounts are probably VERY far off.

The solution is equally simple, use two sets of variables so you can keep your calculated values separate and use the actual values from the MUD for the calculations.
#VAR LevelTotal0 0
#TR {^~[Level:%s(%d)~] ~[Experience Required:%s(%d)~]} {#VAR LevelTotal%1 %2;#MATH T1 (%1 - 1);#MATH Level%1 (@LevelTotal%1 - @{LevelTotal@T1})}
Reply with quote
zex0s
Wanderer


Joined: 29 Jun 2003
Posts: 64

PostPosted: Sun Jun 29, 2003 2:25 pm   
 
Yea, I went to sleep last night, and that hit me.. and using your lines was so much simpler. For the record, I was making an exp bar, where the max was the exp to the next level, and the mud I play only shows your total exp, and how far away you are to the next level, so to figure the differences there I needed to parse the level command info so I could start at 0exp every level. :)

THankx
Zex0s
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net