[solved] GUI: dynamic return values

Discussion of Lua and LuaWML support, development, and ideas.

Moderator: Forum Moderators

User avatar
Celtic_Minstrel
Developer
Posts: 2236
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: [solved] GUI: dynamic return values

Post by Celtic_Minstrel »

Ravana wrote: January 7th, 2024, 9:59 am
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.
For guide purpose it can be converted with wml.tostring.
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.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
white_haired_uncle
Posts: 1207
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: [solved] GUI: dynamic return values

Post by white_haired_uncle »

Ravana wrote: January 7th, 2024, 9:59 am For guide purpose it can be converted with wml.tostring.
That's very cool, I've included that as a suggestion. Thanks.
Speak softly, and carry Doombringer.
white_haired_uncle
Posts: 1207
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: [solved] GUI: dynamic return values

Post by white_haired_uncle »

Celtic_Minstrel wrote: January 5th, 2024, 8:19 am If you're running in 1.17, you can use the wesnoth.print_attributes function (documented here) to determine what properties are valid and exist in any variable.
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.

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.
User avatar
Celtic_Minstrel
Developer
Posts: 2236
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: [solved] GUI: dynamic return values

Post by Celtic_Minstrel »

The output for a slider is 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.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
white_haired_uncle
Posts: 1207
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: [solved] GUI: dynamic return values

Post by white_haired_uncle »

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.
User avatar
Celtic_Minstrel
Developer
Posts: 2236
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: [solved] GUI: dynamic return values

Post by Celtic_Minstrel »

Yeah, the widgets page documents (or at least is intended to document) all possible attributes of all widgets.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
Post Reply