vultraz's lua questions

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

Moderator: Forum Moderators

Post Reply
User avatar
vultraz
Developer
Posts: 960
Joined: February 7th, 2011, 12:51 pm
Location: Dodging Daleks

Re: vultraz's lua questions

Post by vultraz »

so I have to fill it out with a string like " " depending on the characters it must hold?
Creator of Shadows of Deception (for 1.12) and co-creator of the Era of Chaos (for 1.12/1.13).
SurvivalXtreme rocks!!!
What happens when you get scared half to death...twice?
Exasperation
Posts: 462
Joined: June 8th, 2006, 3:25 am

Re: vultraz's lua questions

Post by Exasperation »

There's probably a simpler way, but that's what I got to work (and I did try a few other things first). It's probably also possible to deal with it using set_dialog_canvas, but I try to avoid using that function if at all possible, and wouldn't be able to help you with it much if you decided to try that (I've gotten set_dialog_canvas to do something useful once, and that was a bit of an ordeal).
User avatar
vultraz
Developer
Posts: 960
Joined: February 7th, 2011, 12:51 pm
Location: Dodging Daleks

Re: vultraz's lua questions

Post by vultraz »

Ok, I'm back with more lua questions. ;)

So, first of all:
Spoiler:
That's part of my item pickup code. For some reason the line

Code: Select all

wesnoth.fire_event(cfg.id)
isn't working.

Here's the WML that uses it:
Spoiler:
The [inventory_item] tag is defined in the item pickup code, and makes a dialog popup. If you decide to take it, the code at the top of the post ^ fires. Then that is supposed to fire the sub-event to do whatever I want (dialog, etc) if you pick the items up, then remove the entire event so the item can't be picked up again. But the sub-event doesn't fire. :S Any ideas?


Secondly, related it items, I need a way to check if an item has been picked up and a unit has it. I could use WML vars (like {VARIABLE item_x_picked yes}), but I'm wondering if there's a simpler way in lua that could look at all the item vars for all characters and see if the item is there?

Array structure is: unit_id -> items
--------------------------------> potions
--------------------------------> weapons
each main unit has that. It probably would be better/neater to use WML vars, but I just want to see if the lua option would be better, first.

Thanks. :)
Creator of Shadows of Deception (for 1.12) and co-creator of the Era of Chaos (for 1.12/1.13).
SurvivalXtreme rocks!!!
What happens when you get scared half to death...twice?
User avatar
Elvish_Hunter
Posts: 1576
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: vultraz's lua questions

Post by Elvish_Hunter »

vultraz wrote:But the sub-event doesn't fire. :S Any ideas?
In some situations, nested events may be a bit problematic. What about trying to move the scen1_key event outside of the moveto event?
vultraz wrote:It probably would be better/neater to use WML vars, but I just want to see if the lua option would be better, first.
The problem is that Lua variables aren't persistent, and are cleared every time that a scenario is reloaded (with an exception in case of Lua AI, but that's explained in mattsc's thread :) ). I know that the code may become a bit more complex, but if you feel like doing so you can use the [variables] array of each unit to store the various weapons/potions/things.
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: vultraz's lua questions

Post by Anonymissimus »

vultraz wrote:That's part of my item pickup code. For some reason the line

Code: Select all

wesnoth.fire_event(cfg.id)
isn't working.
I have only glanced over your post, however, keep in mind that events are fired by name (which is a type actually) and not by unique ids. Since one is free to choose names one can use unique ones however.
Also, nested events which are spawned into the scenario wml from within a certain event callstack cannot be fired by the same callstack; the handler is created only once that the base event has run out. So if you use fire_event or its lua variant it won't have effect. This is true even if you would attempt to fire it *after* executing the [event] tag spawning the event to fire (but still within the same event callstack). I say callstack since events can fire other events; the base event works like a main function in this sense. Glancing some more over your code I guess this is the problem, though some parts are missing.
You could probably solve the problem by spawning the handler for the name=scen1_key event previously (written above) in a separated *toplevel* (base) moveto event.
Enough techbabble.;)
Elvish_Hunter wrote:The problem is that Lua variables aren't persistent, and are cleared every time that a scenario is reloaded (with an exception in case of Lua AI, but that's explained in mattsc's thread :) ).
Also, wesnoth.game_events.on_save/load can be used to inject and reread the data lua variables hold into the savegames, such as mainline does for objectives and items. :)
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
User avatar
vultraz
Developer
Posts: 960
Joined: February 7th, 2011, 12:51 pm
Location: Dodging Daleks

Re: vultraz's lua questions

Post by vultraz »

Ok, thanks for the suggestions. I'll see what works :)
Elvish_Hunter wrote:
vultraz wrote: It probably would be better/neater to use WML vars, but I just want to see if the lua option would be better, first.
The problem is that Lua variables aren't persistent, and are cleared every time that a scenario is reloaded (with an exception in case of Lua AI, but that's explained in mattsc's thread ). I know that the code may become a bit more complex, but if you feel like doing so you can use the [variables] array of each unit to store the various weapons/potions/things.
You mean, instead of (base var is manually made):

Rhyan.items.bla

I'd use (base var from [store_unit]):

Rhyan_store.variables.items.bla?

I think I ran that past Espreon once, and he mentioned something wrong with it, but I forgot...I'll have to check. :P
Creator of Shadows of Deception (for 1.12) and co-creator of the Era of Chaos (for 1.12/1.13).
SurvivalXtreme rocks!!!
What happens when you get scared half to death...twice?
User avatar
vultraz
Developer
Posts: 960
Joined: February 7th, 2011, 12:51 pm
Location: Dodging Daleks

Re: vultraz's lua questions

Post by vultraz »

Ok, I have another problem. (@Elvish_Hunter: I talked to you about this on IRC a couple weeks back, and you said PM you about it, but I didn't get a chance to :P )

Code: Select all

---
-- Used to see if a character has been found and developed
--
-- [check_for_character]
--   ... Unit stats ...
-- [/check_for_character]
---
function wml_actions.check_for_character(cfg)
	for i, unit in ipairs(wesnoth.get_units( { side = 1 } )) do
		if wesnoth.match_unit( unit, { id = cfg.id } ) then
		else
			--cfg.placement = "leader"
			wml_actions.unit( cfg )
		end
        
		if wesnoth.get_variable(unit.id .. ".class") == "none" then
			wesnoth.set_variable("char_devel_temp_id", unit.id)
			wesnoth.fire_event("herodevel")
		end
	end
end
It's supposed to create the unit specified inside the tag, and then fire the herodevel event to develop said unit. Usage:

Code: Select all

        [check_for_character]
            # wmllint: recognize Norethial
            id=Norethial
            name= _ "Norethial"
            type=Elvish Sorceress
            gender=female
            role=hero
            {IS_HERO}
            placement=leader
        [/check_for_character]

        [check_for_character]
            # wmllint: recognize Galamor
            id=Galamor
            name= _ "Galamor"
            type=Dwarvish Scout
            role=hero
            {IS_HERO}
            placement=leader
        [/check_for_character]
But for some reason it results in 5 dwarves and 3 elves appearing and the herodevel event not firing both times.... Only one other unit for side 1 exists at the time. Any idea?
Creator of Shadows of Deception (for 1.12) and co-creator of the Era of Chaos (for 1.12/1.13).
SurvivalXtreme rocks!!!
What happens when you get scared half to death...twice?
User avatar
Elvish_Hunter
Posts: 1576
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: vultraz's lua questions

Post by Elvish_Hunter »

vultraz wrote:(@Elvish_Hunter: I talked to you about this on IRC a couple weeks back, and you said PM you about it, but I didn't get a chance to )
I remember. :)
vultraz wrote:But for some reason it results in 5 dwarves and 3 elves appearing and the herodevel event not firing both times.... Only one other unit for side 1 exists at the time. Any idea?
Let me check...

Code: Select all

---
-- Used to see if a character has been found and developed
--
-- [check_for_character]
--   ... Unit stats ...
-- [/check_for_character]
---
function wml_actions.check_for_character(cfg)
	for i, unit in ipairs(wesnoth.get_units( { side = 1 } )) do
		if wesnoth.match_unit( unit, { id = cfg.id } ) then
		else
			--cfg.placement = "leader"
			wml_actions.unit( cfg )
		end
        
		if wesnoth.get_variable(unit.id .. ".class") == "none" then
			wesnoth.set_variable("char_devel_temp_id", unit.id)
			wesnoth.fire_event("herodevel")
		end
	end
end
How many units there are on side 1? With such a cycle, every time that a unit on side 1 that does not have the specified ID is found, a new unit is created. Is that supposed to happen? :?
Perhaps you want to check if a certain unit is on the field, and if not create it. In that case, the way to go is wesnoth.eval_conditional:

Code: Select all

if not wesnoth.eval_conditional( { { "have_unit", { side = 1, id = cfg.id } } } )
With this solution, your code becomes:

Code: Select all

function wml_actions.check_for_character(cfg)
	if not wesnoth.eval_conditional( { { "have_unit", { side = 1, id = cfg.id } } } ) then
		wml_actions.unit( cfg )
	end
        
	if wesnoth.get_variable(cfg.id .. ".class") == "none" then
		wesnoth.set_variable("char_devel_temp_id", cfg.id)
		wesnoth.fire_event("herodevel")
	end
end
Also, the variable ".class" is correctly initialized to "none"? If your idea is to handle it as a boolean, you can use:

Code: Select all

if not wesnoth.get_variable(cfg.id .. ".class") then
under the condition that it'll work only if the variable does not yet exists (value nil) or has value no (value false). "none" will be considered a string, and true as such.
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
User avatar
vultraz
Developer
Posts: 960
Joined: February 7th, 2011, 12:51 pm
Location: Dodging Daleks

Re: vultraz's lua questions

Post by vultraz »

Elvish_Hunter wrote:How many units there are on side 1? With such a cycle, every time that a unit on side 1 that does not have the specified ID is found, a new unit is created. Is that supposed to happen?
There's one before running this.
Elvish_Hunter wrote:under the condition that it'll work only if the variable does not yet exists (value nil) or has value no (value false). "none" will be considered a string, and true as such.
So, 'no' and 'false' work the same, right?

Anyway, thanks for the new code. I'll test it as soon as I can :D

I do have another question, though. For my inventory, I have checkboxes next to each item so the player could select more than one to use or drop, etc. So I need to keep a live list of the indexes of the listbox options currently checked. Shadowmaster suggested:
Shadowmaster wrote: [20:07] <shadowm> the principle I stated above was to assign different dynamic callbacks to each checkbox
[20:07] <shadowm> each one using the corresponding row number as a constant somewhere
[20:09] <shadowm> this principle is more or less what Boost.bind implements in C++; languages like Perl have built-in syntax to create function-like objects on the fly like that (e.g. closures)
[20:09] <shadowm> I _think_ Lua can do it too.
I have (in the pre_show function):

Code: Select all

local checked_items = ""
		local temp_current_print_index = 1

		-- Prints personal items list
		local personal_inv_list_data = {}
		inventory_category_scan("items", personal_inv_list_data)
		inventory_category_scan("weapons", personal_inv_list_data)
		inventory_category_scan("potions", personal_inv_list_data)
		for i = 1, #personal_inv_list_data do
			wesnoth.set_dialog_value(personal_inv_list_data[i].image, "inventory_list_personal", i, "list_image")
			wesnoth.set_dialog_value(personal_inv_list_data[i].name, "inventory_list_personal", i, "list_name")

			wesnoth.set_dialog_callback(function() checked_items .. temp_current_print_index end, "list_checkbox")

			temp_current_print_index = temp_current_print_index + 1
		end

		-- Prints shared items list
		u_id = "shared_inventory"
		local shared_inv_list_data = {}
		inventory_category_scan("items", shared_inv_list_data)
		inventory_category_scan("weapons", shared_inv_list_data)
		inventory_category_scan("potions", shared_inv_list_data)
		for i = 1, #shared_inv_list_data do
			wesnoth.set_dialog_value(shared_inv_list_data[i].image, "inventory_list_shared", i, "list_image")
			wesnoth.set_dialog_value(shared_inv_list_data[i].name, "inventory_list_shared", i, "list_name")

			wesnoth.set_dialog_callback(function() checked_items .. temp_current_print_index end, "list_checkbox")

			temp_current_print_index = "nil"
		end
But I realize that might add the index number to the list, but it does nothing to remove one. So...how would I keep a live list? Would having the numbers in an array and somehow adding and removing entries as necessary work? But even then I'm not sure how to work that... :hmm:

Exasperation said a wesnoth.get_widget_value set to the whole listbox would return the index of the currently selected item, and it seems checking a checkbox selects an item, causing the select callback to activate, and the function it calls has said wesnoth.get_widget_value. So we get the index, I'm just not sure how to deal with it.
Whole preshow function:
I would ask Exasperation, but it seems he's gone MIA. :augh:
Creator of Shadows of Deception (for 1.12) and co-creator of the Era of Chaos (for 1.12/1.13).
SurvivalXtreme rocks!!!
What happens when you get scared half to death...twice?
User avatar
Elvish_Hunter
Posts: 1576
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: vultraz's lua questions

Post by Elvish_Hunter »

vultraz wrote:So, 'no' and 'false' work the same, right?
Not exactly. "no" in a WML variable is passed as false to Lua. But "no" in a Lua variable is a string, and strings are always true in Lua!
vultraz wrote:But I realize that might add the index number to the list, but it does nothing to remove one. So...how would I keep a live list? Would having the numbers in an array and somehow adding and removing entries as necessary work? But even then I'm not sure how to work that... Exasperation said a wesnoth.get_widget_value set to the whole listbox would return the index of the currently selected item, and it seems checking a checkbox selects an item, causing the select callback to activate, and the function it calls has said wesnoth.get_widget_value. So we get the index, I'm just not sure how to deal with it.
In other GUI toolkits (and when I talk about other toolkits, I always refer to Tkinter/ttk because it's the only that I know - at least for now), a listbox can be used to select multiple items, by using the Shift or Ctrl keys - but Tk has proper radiobuttons. In WML, listboxes are almost always used to simulate radiobuttons. This means that you can select only one option per time. If you want to be able to get the value of several checkbuttons, you have to assign an ID to each checkbutton.
The approach suggested by Exasperation may work, except for a loophole: what if the user selects again a checkbutton in order to deselect - unmark - it?
The safest solution will be knowing each checkbutton ID, and reading its value with get_dialog_value.
vultraz wrote:I would ask Exasperation, but it seems he's gone MIA.
Did you already PMed him?
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
User avatar
vultraz
Developer
Posts: 960
Joined: February 7th, 2011, 12:51 pm
Location: Dodging Daleks

Re: vultraz's lua questions

Post by vultraz »

Hum....well...is there a way to assign a unique is to each checkbox?I just have one row defined, and the game created the rest in the for loop: :hmm:

Code: Select all

local item_list_personal = T.listbox { id = "inventory_list_personal",
				               definition = "default",
				               vertical_scrollbar_mode = "always",
					       T.header { T.row { T.column { grow_factor = 1, horizontal_grow = "true", border = "all", border_size = 5, 
									     T.label { definition = "default", id = "check_sort", linked_group = "checkbox", label = "" } },
								  T.column { grow_factor = 1, horizontal_grow = "true", border = "all", border_size = 5, 
									     T.label { definition = "default", id = "image_sort", linked_group = "image", label = "" } },
								  T.column { grow_factor = 1, horizontal_grow = "true", border = "all", border_size = 5,
									     T.button { definition = "default", id = "personal_name_sort", linked_group = "name", label = "Name" } },
								  T.column { grow_factor = 1, horizontal_grow = "true", border = "all", border_size = 5,
									     T.label { definition = "default", id = "quantity_sort", linked_group = "quantity", label = "Quantity" } },
								  T.column { grow_factor = 1, horizontal_grow = "true", border = "all", border_size = 5,
									     T.label { definition = "default", id = "active_sort", linked_group = "active", label = "Active" } },
								  T.column { grow_factor = 1, horizontal_grow = "true", border = "all", border_size = 5,
									     T.label { definition = "default", id = "p_inv_duration_sort", linked_group = "inv_duration", label = "Effect type" } } } },
				               T.list_definition { T.row { T.column { vertical_grow = "true",
								 	              horizontal_grow = "true",
									              T.toggle_panel { top_border = 20,
												       T.grid { T.row { T.column { grow_factor = 1, horizontal_grow = "true", border = "all", border_size = 5,
					  											   T.toggle_button { id = "list_checkbox", definition = "default", linked_group = "checkbox" } },
			       											        T.column { grow_factor = 1, horizontal_grow = "true", border = "all", border_size = 5,
					 											   T.image { id = "list_image", definition = "default", linked_group = "name" } },
														        T.column { grow_factor = 1, horizontal_grow = "true", border = "all", border_size = 5,
					  											   T.label { id = "list_name", definition = "title", linked_group = "name" } },
														        T.column { grow_factor = 1, horizontal_grow = "true", border = "all", border_size = 5,
																   T.label { id = "list_quantity", definition = "default", linked_group = "quantity", label = "0" } },																		      	T.column { grow_factor = 1, horizontal_grow = "true", border = "all", border_size = 5,
																   T.label { id = "list_active", definition = "default", linked_group = "active", label = "yes" } },
															T.column { grow_factor = 1, horizontal_grow = "true", border = "all", border_size = 5,
																   T.label { id = "list_effect_type", definition = "default", linked_group = "inv_duration", label = "continuous" } } } } } } } } }
Also, the herodevel event in that code from up above doesn't fire. I set the initial value of the vars to 'no':

Code: Select all

#define UNIT_ARRAYS _UNIT
    {VARIABLE {_UNIT}.class no}
    {VARIABLE {_UNIT}.alignment no}
    {VARIABLE {_UNIT}.spcability no}

    #{VARIABLE {_UNIT}.abilities ()}
    #{VARIABLE {_UNIT}.enchacements ()}
    #{VARIABLE {_UNIT}.weapon_specials ()}
    #{VARIABLE {_UNIT}.terrain_upgrades ()}
    #{VARIABLE {_UNIT}.weapons ()}
    #{VARIABLE {_UNIT}.potions ()}
    #{VARIABLE {_UNIT}.stances ()}
    #{VARIABLE {_UNIT}.items ()}
#enddef
But for some reason it doesn't fire. Code:

Code: Select all

function wml_actions.check_for_character(cfg)
	if not wesnoth.eval_conditional( { { "have_unit", { side = 1, id = cfg.id } } } ) then
		wml_actions.unit( cfg )
	end
        
	if not wesnoth.get_variable(cfg.id .. ".class") then
		wesnoth.set_variable("char_devel_temp_id", cfg.id)
		wesnoth.fire_event("herodevel")
	end
end
Elvish_Hunter wrote:
vultraz wrote: I would ask Exasperation, but it seems he's gone MIA.
Did you already PMed him?
I PMed him a few weeks ago, no response, and he hasn't been on IRC recently:
[20:52] <vultraz> wesbot: seen Exasperation
[20:52] <wesbot> vultraz: The person with the nick Exasperation last spoke 58d 6h ago. 57d 10h ago they were seen quitting on the channel #wesnoth with the message: Client Quit
Creator of Shadows of Deception (for 1.12) and co-creator of the Era of Chaos (for 1.12/1.13).
SurvivalXtreme rocks!!!
What happens when you get scared half to death...twice?
User avatar
Elvish_Hunter
Posts: 1576
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: vultraz's lua questions

Post by Elvish_Hunter »

vultraz wrote:Hum....well...is there a way to assign a unique is to each checkbox?
I suppose that there is one. The problem is that widgets' IDs can be assigned only at the moment of the creation - that is, when you have a T.list_data tag, and I see that there isn't one. Without an ID, we cannot rely on set_dialog_value. I'd try removing id from

Code: Select all

[quote="vultraz"] T.toggle_button { id = "list_checkbox", definition = "default", linked_group = "checkbox" } },[/quote]
and I'd try, instead of creating the various items in the preshow, collecting all the variables at the start of the whole tag (I suppose that you created something like wml_actions... , so the line after wml_actions) in a list_data variable:

Code: Select all

local list_data = {}
      for i = 1, #shared_inv_list_data do

         table.insert(list_data, {image=shared_inv_list_data[i].image,
                                        name=shared_inv_list_data[i].name,
                                        id=shared_inv_list_data[i].id} )
Of course, there are high chances that my code above doesn't work, but this is mainly to make understandable what I said before.
Anyway, I just downloaded NX-RPG from Sourceforge, and I hope to be more precise in a few days - that is, if real life allows me.
vultraz wrote:Also, the herodevel event in that code from up above doesn't fire. I set the initial value of the vars to 'no':
I see that, in the first scenario, you're calling said tag in the victory event. I'm not sure, but I think that, once that victory is fired, no other event can be fired - at least, this is the first time that I ever see another event called by a victory event, so I cannot be sure. Try moving the [check_for_character] tag in the "start" or "side 1 turn 1" event of the first scenario, and let me know.
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
User avatar
vultraz
Developer
Posts: 960
Joined: February 7th, 2011, 12:51 pm
Location: Dodging Daleks

Re: vultraz's lua questions

Post by vultraz »

How would doing that help me give each checkbox a unique id? I don't get it. And how would each having a unique id help?
Elvish_Hunter wrote:Try moving the [check_for_character] tag in the "start" or "side 1 turn 1" event of the first scenario, and let me know.
Same result; so event fire. Put it in a 'side 1 turn 1' event. And something else interesting. I have first time select events initiated during the prestart for the units on side one. The one for the existing character/unit (Rhyan) fires, as do the ones for the other two (Galamor + Norethial), but only if you find those units on the map. The select event doesn't fire for the Galamor + Norethial created by [check_for_character[, even though the stats are (pretty sure) identical to the [unit] tag that creates the units you find on the map. :hmm:
Last edited by vultraz on March 24th, 2012, 6:21 am, edited 2 times in total.
Creator of Shadows of Deception (for 1.12) and co-creator of the Era of Chaos (for 1.12/1.13).
SurvivalXtreme rocks!!!
What happens when you get scared half to death...twice?
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: vultraz's lua questions

Post by Anonymissimus »

vultraz wrote:And how would each having a unique id help?
I don't follow the thread; but unique ids for widgets are very helpful when you need to set/get widget values. Otherwise you would also need to give some "path" to specify the widget further.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
User avatar
Elvish_Hunter
Posts: 1576
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: vultraz's lua questions

Post by Elvish_Hunter »

Anonymissimus wrote:unique ids for widgets are very helpful when you need to set/get widget values
Not exactly: IDs are mandatory, otherwise a widget is just a unuseful decoration.
So, vultraz, I tested on a small toggle panel. My conclusion is that it does not support selecting more than one item at the same time, sorry.
I also found a bug (at least I suppose that it is one; I need to create a testcase and report it), that closes the campaign when a toggle_panel without an image widget is used:

Code: Select all

Image does not fit the canvas.

Condition 'static_cast<int>(h) >= 0' failed at src/gui/auxiliary/canvas.cpp:1079 in function 'draw'. Extra development information: Image 'misc/selection2-border-left.png', h = -3.
But maybe not all hope is lost. What do you think of this?
Checkbuttons.png
Checkbuttons.png (158.05 KiB) Viewed 6378 times
The only way that I found working is the one that you can see above. I'm attaching the code.

Code: Select all

function wml_actions.test_panel (cfg)
	local dialog = { T.helptip { id="tooltip_large" }, -- mandatory field
				T.tooltip { id="tooltip_large" }, -- mandatory field
				maximum_height = 600,
				maximum_width = 800,
				T.grid {
					T.row { T.column { T.toggle_button { id = "the_toggle1" } },
					        T.column { T.label { id = "the_label1", label = "One" } },
	       					T.column { T.image { id = "the_icon1", label = "items/book1.png" } }
					      },
					T.row { T.column { T.toggle_button { id = "the_toggle2" } },
					        T.column { T.label { id = "the_label2", label = "Two" } },
	       					T.column { T.image { id = "the_icon2", label = "items/book2.png" } }
					      },
					T.row { T.column { T.toggle_button { id = "the_toggle3" } },
					        T.column { T.label { id = "the_label3", label = "Three" } },
	       					T.column { T.image { id = "the_icon3", label = "items/book3.png" } }
					      },
					T.row { T.column { T.toggle_button { id = "the_toggle4" } },
					        T.column { T.label { id = "the_label4", label = "Four" } },
	       					T.column { T.image { id = "the_icon4", label = "items/book4.png" } }
					      },
					T.row { T.column { T.toggle_button { id = "the_toggle5" } },
					        T.column { T.label { id = "the_label5", label = "Five" } },
	       					T.column { T.image { id = "the_icon5", label = "items/book5.png" } }
					      },
					} }
	wesnoth.show_dialog (dialog)
end
Perhaps creating a grid = {} and using table.insert() to add all the rows you may be able to obtain what you want - but I cannot guarantee anything.
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
Post Reply