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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Tue Feb 10, 2009 1:19 am   

Variables using mxp data
 
For the life of me, I can't get this to work constantly. I have a variable that I want to take MXP data received from the mud and evaluate. However, I cannot get this to work constantly. It either gets converted to a number in which case it won't update, or I get no result.

I'm using the following as the value of my variable:

%float(%mud.exp)/%float(%mud.exp+%mud.exptnl)*100

I've tried other variations. It didn't even seem to want to work when I just used %mud.exp as the value.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Tue Feb 10, 2009 5:36 pm   
 
If you do a

#SHOW %mud.exp

on the command line, does it show the correct value of the variable? Same for %mud.exptnl. Your example should work fine, but you might want to show us the exact script that you are using this in.
Reply with quote
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Tue Feb 10, 2009 8:41 pm   
 
Yes, both the shows work. I even have a gauge that doesn't calculate the percentage, it just uses the %mud.exp+%mud.exptnl as the max for the gauge. What I am trying to use this variable for is a status window that shows the percentage, and as I don't believe you can do calculations inside the status window definition, I needed to create this variable.

What I am thinking I may have to do is use an onPrompt event to calculate the variable, but I didn't want to give up on this if I was just missing something minor.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Feb 10, 2009 9:43 pm   
 
ah. That's probably the problem. What you seem to be creating is not truly a variable, but an inline function, or #varfunc. That won't work for a status line.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Feb 11, 2009 2:23 pm   
 
I should explain further. The status window only changes the display when it detects that the time mark on the variable changes, indicating the variable has changed. The time mark on an inline function will only change if the code in the function changes, not if the value returned by the function changes.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Feb 11, 2009 6:31 pm   
 
Yep, Rahab is correct...the status item only updates when a normal zMUD variable change is detected.

However, in the next beta version I am planning to add a new command called #UPDATE that will refresh a button or status bar item manually in a script in cases where you are using functions or MXP variables that don't currently cause the items to be updated.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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