questions about Wesnoth-Lua

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

Moderators: Forum Moderators, Developers

Post Reply
denispir
Posts: 163
Joined: March 14th, 2013, 12:26 am

questions about Wesnoth-Lua

Post by denispir » November 6th, 2019, 11:37 am

Hello,

About cfg & __cfg & __literal:
  • Maybe it's just an issue of funny naming:Wwhy is cfg called that way? Why not input or params? Can I safely assume that it is always, and only, params/input stored in a table? (or userdata)
  • What is __cfg?
  • What is, clearly and factually, __literal? And why is it called that way?
Base modules & documentation:
  • I think I remember that the mysterious Wesnoth module is in fact cpp code: correct? But where is it? And can we find some documentation about it? The short lists provided in the LuaWML wiki page's subpages (or LuaAPI), open more questions than they answer... (and no example to help understand)
  • Where is the map module? (same questions as above possibly)
A funny problem:
When a unit is blocked on its path toward a goal, by an ally standing on its "virtual halt" tile, how to determine the 2 neighbour tiles +/- leading forwards? I have found:
wesnoth.map.rotate_right_around_center(loc, center, angle)
but the fact that it expects an "angle" in range 1...6 makes me doubt about its functionality.

Thank you!

User avatar
octalot
Developer
Posts: 407
Joined: July 17th, 2010, 7:40 pm

Re: questions about Wesnoth-Lua

Post by octalot » November 6th, 2019, 1:56 pm

IIUC, the wesnoth module is a table of functions, which can be added to or even overridden. The table is created, and a lot of functions are added in, src/scripting/game_lua_kernel.cpp.

denispir
Posts: 163
Joined: March 14th, 2013, 12:26 am

Re: questions about Wesnoth-Lua

Post by denispir » November 6th, 2019, 3:41 pm

octalot wrote:
November 6th, 2019, 1:56 pm
IIUC, the wesnoth module is a table of functions, which can be added to or even overridden. The table is created, and a lot of functions are added in, src/scripting/game_lua_kernel.cpp.
Thank you! I will have a look.

EDIT: Ok, that's what I was searching for. Unfortunately, it can hardly be useful for my 2 use cases:
  • Understanding better what each func does, or what each structure contains, and the logic behind.
  • Expanding & improving the doc on all that online.
The problem is that it is mainly calls to other C++ code (indeed), and full of inner conventions of the Wesnoth codebase (expected). Thus, just studying the simplest functionality defined there requires a disproportianate efforts, and entails a high risk of misinterpretation.
Conclusion: only involved coders can improve that; or maybe also highly motivated "scriptors" who have done the work of longuish and penible trial & error explorations (on the Wesnoth platform even much more).
Last edited by denispir on November 7th, 2019, 10:51 am, edited 1 time in total.

Tad_Carlucci
Inactive Developer
Posts: 445
Joined: April 24th, 2016, 4:18 pm

Re: questions about Wesnoth-Lua

Post by Tad_Carlucci » November 6th, 2019, 4:07 pm

/s

"cfg" is named that to reduce the amount of work on the keypunch department, and ensure we stay within the 72-column limit for punchcards, to allow us to re-colate them should we drop the card tray.
I forked real life and now I'm getting merge conflicts.

denispir
Posts: 163
Joined: March 14th, 2013, 12:26 am

Re: questions about Wesnoth-Lua

Post by denispir » November 7th, 2019, 10:52 am

Tad_Carlucci wrote:
November 6th, 2019, 4:07 pm
"cfg" is named that to reduce the amount of work on the keypunch department, and ensure we stay within the 72-column limit for punchcards, to allow us to re-colate them should we drop the card tray.
I would then propose "i" as in i/o.

Post Reply