Lua Table Converter

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

Moderator: Forum Moderators

Post Reply
Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

Lua Table Converter

Post by Choicerer »

Hi all,
Porting my Randomizer to Lua and then realising global variables aren't stored in the savefile forced me to come up with this lua table converter.
I hope you can find it useful, here is the description from Readme.md:
This script converts between regular lua and lua wml tables. It is inteded to be used to convert lua tables with any number of subtables indexed by indices, keys or both to WML and back while preserving the original structure.
It will only work for wml tables that are prefixed by a [1] index, that is any subtables must go inside that [1] and it must be the only top index. The rationale for this is that there must be a consistent way of preserving lua table structure, so that after converting a lua table to wml and back, we end up with the exact same table. This is the only way this can be accomplished, if you have a wml table with multiple top indices, you will want to run helper.get_variable_array on it, anyway.
Get it here:
https://github.com/Choicerer/Wesnoth_Ta ... verter.lua
Post Reply