[solved] two [grid] tags

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

Moderator: Forum Moderators

white_haired_uncle
Posts: 1239
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: [solved] two [grid] tags

Post by white_haired_uncle »

Hmm. I can look at

Code: Select all

                dialog.my_tb.on_modified = function() 
                        if dialog.my_tb.text == " " then dialog:close() end
and it's pretty clear what's going to happen.

After reading through that thread several times, I think I see what utils.handle_event_commands is supposed to do (though good luck finding it on the wiki unless you know exactly what to search for). And I have absolutely no idea how that example is going to cause the gui to close because the user hit the space bar.

Might be incredibly useful, once you figure it out, but I wouldn't call it simplified. And perhaps it is simple if you already know what it is and how to use it, but just to look at it for the first time, not so much.
Speak softly, and carry Doombringer.
User avatar
Ravana
Forum Moderator
Posts: 3038
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: [solved] two [grid] tags

Post by Ravana »

wml-utils part is reference how to test this code, it has nothing to do with dialogs.
User avatar
Celtic_Minstrel
Developer
Posts: 2255
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: [solved] two [grid] tags

Post by Celtic_Minstrel »

white_haired_uncle wrote: April 27th, 2024, 4:19 pm (though good luck finding it on the wiki unless you know exactly what to search for).
Why is that? Is there something that could be done to make it easier to find?
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
ZombieKnight
Posts: 218
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: [solved] two [grid] tags

Post by ZombieKnight »

Ehm... I've been LONG looking for something like dialog.on_key.space = dialog:close()
I had saurian in profile before, but I've merged my discord profile with forum one...
User avatar
ZombieKnight
Posts: 218
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: [solved] two [grid] tags

Post by ZombieKnight »

Btw
Turned out that implementing speaker(non-narrator)
Isn't so simple...
How does message store unit and how to make it again in lua custom_dialog?
I had saurian in profile before, but I've merged my discord profile with forum one...
white_haired_uncle
Posts: 1239
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: [solved] two [grid] tags

Post by white_haired_uncle »

Celtic_Minstrel wrote: April 27th, 2024, 5:36 pm
white_haired_uncle wrote: April 27th, 2024, 4:19 pm (though good luck finding it on the wiki unless you know exactly what to search for).
Why is that? Is there something that could be done to make it easier to find?
Based on this:
# lua wesnoth.require("wml-utils").handle_event_commands(wml.load("~add-ons/EventLoader/action.cfg"))
I did a wiki search for 'handle_event_commands' which came back with nothing. I then did a search on brave for 'handle_event_commands site:wesnoth.org'
which got me to https://wiki.wesnoth.org/LuaAPI/wml-uti ... t_commands. Back to the wiki, I found that I could find that page only if I searched for 'utils.handle_event_commands'.

https://wiki.wesnoth.org/LuaAPI/wml-utils says
All examples on this page will assume it has been loaded by:

local utils = wesnoth.require "wml-utils"
which I think is the problem. I would change the documentation to use just handle_event_commands, and then add the require and use utils.handle_event_commands in the examples.
Speak softly, and carry Doombringer.
User avatar
Ravana
Forum Moderator
Posts: 3038
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: [solved] two [grid] tags

Post by Ravana »

That is why I created https://wiki.wesnoth.org/Template:Lua_Functions for https://wiki.wesnoth.org/LuaAPI as documentation where you can actually use search.

I say again that handle_event_commands has nothing to do with current topic about grids and closing. It is way how to run wml such as [lua] midscenario with debug command.
User avatar
Celtic_Minstrel
Developer
Posts: 2255
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: [solved] two [grid] tags

Post by Celtic_Minstrel »

Ravana wrote: April 27th, 2024, 7:52 pm It is way how to run wml such as [lua] midscenario with debug command.
Or rather, it is the function to run arbitrary ActionWML for any reason whatsoever.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
white_haired_uncle
Posts: 1239
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: [solved] two [grid] tags

Post by white_haired_uncle »

Celtic_Minstrel wrote: April 27th, 2024, 8:27 pm
Ravana wrote: April 27th, 2024, 7:52 pm It is way how to run wml such as [lua] midscenario with debug command.
Or rather, it is the function to run arbitrary ActionWML for any reason whatsoever.
Arbitrary ActionWML which could be stored in a file and read (repeatedly) at runtime, allowing you to change WML without the whole F5-restart stuff? That was the impression I got from the linked thread.
Ravana wrote: April 27th, 2024, 4:44 pm wml-utils part is reference how to test this code, it has nothing to do with dialogs.
Okay, that makes more sense. You removed the callback that dealt with hitting the space bar to close (click_dismiss doesn't do that, does it, just mouse click I thought?), and added the wml-utils, so I assumed that the wml-utils... somehow was a replacement for the callback which confused me to no end.
Speak softly, and carry Doombringer.
Post Reply