|
ennye Novice
Joined: 17 Dec 2007 Posts: 49
|
Posted: Fri Mar 13, 2009 10:42 pm
Variables inside #button commands. |
Need to do something like this:
[simple example]
VARIABLE @team:
john|marry
ALIAS:
#forall @team {
#button but_%i {%i HP @hp_%i} {check %i}
}
How to make vars expanded or not expanded in #button commands. Is it possible?
Alias creates 1 button for any variable item (person) with item specific captions:
Button id : but_john, but_marry .... WORKS
%i HP @hp_%i i need to get inside button: John(%i expanded) HP @hp_john
hit command: check john
I managed to have it under zmud, no chance in any version of cmud ;)
Is it possible to expand anything in {caption or command part} of #button command ? |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sat Mar 14, 2009 4:02 am |
Buttons really were never meant to be created on the fly. zMud sort of made it doable through button IDs, and CMud provides the same support. CMud employs a stricter syntax about most everything; while providing the user more conttrol. The #BUTTON command is a huge exception.
If you really examine its history (for the zScript language) you will see the command started with recognizing only a few parameters, and has expanded to something like 23 possible parameters. When it supported only a few parameters buttons had to be continually redefined to update thier display;, but now display updates are automatic, based on variable changes. I would suggest that you should restructure your scripts to make use of this automatic updating. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
Leitia Adept
Joined: 04 May 2007 Posts: 292 Location: Boston
|
Posted: Sat Mar 14, 2009 5:56 pm |
I am using the gauge text to display my speed, target and switch. I do want a gauge mainly to represent a casting speed, and the text seems to update perfectly.
CMUD outputted the value as a return if I press it. I am looking into definition now but "something like 23 possible parameters" have me wondering what is the correct way to execute and how to establish the thing in code. Today's project, not complaining. Not really sure how to make the text display like it did in ZMud, if it is possible evn, but as that space is used why not make it perform admirably.
Anyway gauges that do the work of buttons, gauges, and status lines, seems super useful in a small environment. Am I in murky waters?
I would post this on it's own but the issue I have is the same, only complicated
[edit it accepted #464370 for a color, I am so happy] |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Mar 16, 2009 5:08 pm |
The caption of a button is always expanded and will then update as the variables in the caption changes. For example, if you put
@hp
in the caption of a button, then the button will always show the value of the @hp variable. When @hp changes, the button will automatically update. CMUD is actually much more efficient than zMUD in that it only updates the button caption when the actual variable changes (zMUD would poll continuously to update a button). In the 3.05 beta version, there is even a new #UPDATE command that can be used to force an update to a complex button.
For example, you can call a user-defined function in your button caption. But the button won't be able to tell if some value hidden within the function changes, so #UPDATE can be used to force the button to update when needed.
If you want to create buttons within a script, you might want to look at the Lua interface in the help files. With Lua, you can create a button and then manipulate it's properties by name instead of messing with the "23 parameters" of the #BUTTON command.
In any case, the caption for a button should work. The difference with %i between zMUD and CMUD is that in zMUD, the %i was expanded before the rest of the script was executed, so %i within the button command would get expanded. But in CMUD, the %i isn't expanded until the button command is actually executed (allowing loops within the button command itself, which didn't work properly in zMUD). To force the expansion of %i the way you needed, you could do something like this:
Code: |
#forall @team {
#button but_%i %concat(%i," HP @hp_",%i) %concat("check ", %i)
} |
|
|
|
|
|
|
|
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
|
|