Wesnoth Lua Pack: Development Thread

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: Wesnoth Lua Pack: Development Thread

Post by vultraz »

Without looking at the code, I can say if [scatter_units] is using get_locations, the fix (on 1.13.x only, however) would be to add an { include_borders = no } key to the WML table.
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
Celtic_Minstrel
Developer
Posts: 2158
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Wesnoth Lua Pack: Development Thread

Post by Celtic_Minstrel »

Sorry, I do not have a test case available. (And I'm running this on 1.12.)
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
Elvish_Hunter
Posts: 1575
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Wesnoth Lua Pack: Development Thread

Post by Elvish_Hunter »

Thanks anyway, I'll work on a solution to fix it on 1.12.
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
Celtic_Minstrel
Developer
Posts: 2158
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Wesnoth Lua Pack: Development Thread

Post by Celtic_Minstrel »

...come to think of it, it also might've been an off-map location (eg x=0). Still, even if that was it, it's reasonable to get WLP to put up a better error message, right?
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
Celtic_Minstrel
Developer
Posts: 2158
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Wesnoth Lua Pack: Development Thread

Post by Celtic_Minstrel »

So, is this still alive? It might be nice to have it as an includable resource pack in 1.14.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
Elvish_Hunter
Posts: 1575
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Wesnoth Lua Pack: Development Thread

Post by Elvish_Hunter »

Celtic_Minstrel wrote: March 19th, 2018, 1:15 am So, is this still alive?
As soon as I manage to port it and all my other add-ons to 1.14. I just passed a few heavy months...
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)
Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

Re: Wesnoth Lua Pack: Development Thread

Post by Choicerer »

Great idea, I wish I'd known about this earlier.
Well, in 1.14 the tooltip for unit names is broken (I should report it on Github), so this is a very basic function to decrease the fontsize if the unit name is too long (part of Better Names, now):

Code: Select all

local old_unit_name = wesnoth.theme_items.unit_name
function wesnoth.theme_items.unit_name()
	local u = wesnoth.get_displayed_unit()
	if not u then return {} end
	local t = old_unit_name()
	if string.len(t[1][2]["text"]) > 21 then --14 characters +7 chars of formatting code
		t[1][2]["text"] = "<span size='small'>"..t[1][2]["text"].."</span>"
	end
	return t
end
Of course you could get more inventive with this, filtering for how many upper case characters there are, since they take more space. The <span size='small'> font size could probably be slightly enlarged too.

Second thing you might find useful:
viewtopic.php?f=58&t=48233

EDIT: BTW, I know you guys use this approach for other elements, too. And sadly some translations extend those strings and then they get cut off, even though they might be more important than this one, for example the side number in Polish. I think this approach would work better.
User avatar
Elvish_Hunter
Posts: 1575
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Wesnoth Lua Pack: Development Thread

Post by Elvish_Hunter »

Just a quick message to let you know that I moved the development of the WLP from Wesnoth-UMC-Dev to GitHub. The new repo is here: https://github.com/Elvish-Hunter/Wesnoth_Lua_Pack.
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
Celtic_Minstrel
Developer
Posts: 2158
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Wesnoth Lua Pack: Development Thread

Post by Celtic_Minstrel »

Nice! Maybe I'll open a PR later to update deprecated things.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
Elvish_Hunter
Posts: 1575
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Wesnoth Lua Pack: Development Thread

Post by Elvish_Hunter »

After a lot of work (40 commits on GitHub!) I can finally announce that I just uploaded version 1.8.0 of the Wesnoth Lua Pack on the 1.14 add-ons server.
While there isn't any new WML tag, a lot of work has been done on the two main GUI debug tags. I also converted the documentation from HTML (I just don't have the time any more to keep up with web programming) to Markdown.

As always, don't forget to report any bug that you find; even better, you can open an issue on GitHub, or make a pull request if you want.

PS. While working on the WLP, I found out that there's another widget that I could've used, called [menu_button]. However, it seems like there's no way to set up a list of values in the dropdown menu, so menu buttons (aka comboboxes) are virtually unusable from Lua. Have I got it right?
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
Celtic_Minstrel
Developer
Posts: 2158
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Wesnoth Lua Pack: Development Thread

Post by Celtic_Minstrel »

That's a very good question... I know it would be possible to use a regular button as a menu button in Lua (create a button whose callback opens a popup menu), but I don't remember how actual menu buttons specified their options. I think there might be a way but I'm not sure.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
vultraz
Developer
Posts: 960
Joined: February 7th, 2011, 12:51 pm
Location: Dodging Daleks

Re: Wesnoth Lua Pack: Development Thread

Post by vultraz »

IIRC, it's just with [option] tags under [menu_button] if you want to set them up from the dialog config. The actual C++ implementation uses a vector of configs... not sure if that was ever exposed to Lua.
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
Celtic_Minstrel
Developer
Posts: 2158
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Wesnoth Lua Pack: Development Thread

Post by Celtic_Minstrel »

So if that's correct, it would mean you can use menu buttons from Lua but probably can't alter their list of options once the dialog is being shown (you can only alter them before it's shown by editing the config).

I guess that's yet another thing to add to the API at some point.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
denispir
Posts: 184
Joined: March 14th, 2013, 12:26 am

Re: Wesnoth Lua Pack: Development Thread

Post by denispir »

Elvish_Hunter wrote: August 9th, 2018, 10:25 am Just a quick message to let you know that I moved the development of the WLP from Wesnoth-UMC-Dev to GitHub. The new repo is here: https://github.com/Elvish-Hunter/Wesnoth_Lua_Pack.
Hello Elvish_Hunter,
You should update the first post of this thread with this new link, else people won't be able to jelp you with the WLP ;-).
Also, the link to the docs (https://wiki.wesnoth.org/WLPDocs) given somewhere else is broken: you may add the new one to the first message as well.
And while you are at it, also place in the first message a direct link to download the pack, if there is any (I had to copy-paste individual lua files I wanted from the github dev repo, found no download ???).

EDIT: About downloading the pack: I just read this a few messages above, by Elvish_Hunter:
... I just uploaded version 1.8.0 of the Wesnoth Lua Pack on the 1.14 add-ons server.
So, we can just get it there! :-) Checked. Please, just say so in the first message of the thread...
User avatar
Elvish_Hunter
Posts: 1575
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Wesnoth Lua Pack: Development Thread

Post by Elvish_Hunter »

denispir wrote: October 28th, 2019, 4:26 am You should update the first post of this thread with this new link, else people won't be able to jelp you with the WLP ;-).
Done.
denispir wrote: October 28th, 2019, 4:26 am Also, the link to the docs (https://wiki.wesnoth.org/WLPDocs) given somewhere else is broken: you may add the new one to the first message as well.
There isn't really a new link to the documentation, because everything is documented with a few Markdown files inside the add-on.
denispir wrote: October 28th, 2019, 4:26 am So, we can just get it there! :-) Checked. Please, just say so in the first message of the thread...
Done, and thank you for commenting!
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