 |
Dumas Enchanter
Joined: 11 Feb 2003 Posts: 511 Location: USA
|
Posted: 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. |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: 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. |
|
|
 |
Dumas Enchanter
Joined: 11 Feb 2003 Posts: 511 Location: USA
|
Posted: 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. |
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: 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.
|
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: 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.
|
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: 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. |
|
|
 |
|
|