[solved] GUI: dynamic return values
Moderator: Forum Moderators
- Celtic_Minstrel
- Developer
- Posts: 2260
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: [solved] GUI: dynamic return values
That's true! That method won't preserve complex procedures where you built up the dialog with multiple variables, but for simple dialogs done all in one go, it's quite a reasonable method.Ravana wrote: ↑January 7th, 2024, 9:59 amFor guide purpose it can be converted with wml.tostring.Celtic_Minstrel wrote: ↑January 7th, 2024, 2:11 am I see. Since you were writing a guide on the wiki, it might be a good idea to at least try the alternate file method so you can add that to the guide, though someone else could always do it later.
-
- Posts: 1257
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: [solved] GUI: dynamic return values
That's very cool, I've included that as a suggestion. Thanks.
Speak softly, and carry Doombringer.
-
- Posts: 1257
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: [solved] GUI: dynamic return values
This morning I was trying to figure out text_boxes. Couldn't find any docs or examples that show how to actually get the value back, and trying to access things like gold_tb.value or gold_tb.label throw up an error and leave the game in a mostly unusable state so I had to restart every time I tried something new.Celtic_Minstrel wrote: ↑January 5th, 2024, 8:19 am If you're running in 1.17, you can use thewesnoth.print_attributes
function (documented here) to determine what properties are valid and exist in any variable.
print_attributes showed me "text", which was the missing piece.
Cool.
Not sure about the output for a slider, however. Many attributes (e.g. right_offset) missing, a couple different (max_value vs maximum_value). Maybe I just don't understand keys vs attributes vs variables.
Speak softly, and carry Doombringer.
- Celtic_Minstrel
- Developer
- Posts: 2260
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: [solved] GUI: dynamic return values
The output for a slider is
The output from
For the ones that are named differently in Lua and WML, that's probably a mistake and we should correct it.
value
. Both text
and value
are documented here.The output from
print_attributes
is the runtime API, and currently only provides the most essential properties. If there's a property exposed in the WML that you'd like to be able to read or change at runtime, you can open a feature request asking to have it exposed in the Lua API.For the ones that are named differently in Lua and WML, that's probably a mistake and we should correct it.
-
- Posts: 1257
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: [solved] GUI: dynamic return values
Ah. I was looking for something that would tell me what the attributes of a text_box were. Didn't think of looking at widget attributes for which one(s) apply to a text box. Have to remember that.
Speak softly, and carry Doombringer.
- Celtic_Minstrel
- Developer
- Posts: 2260
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: [solved] GUI: dynamic return values
Yeah, the widgets page documents (or at least is intended to document) all possible attributes of all widgets.