Quantcast
Channel: The Battle for Wesnoth Forums
Viewing all articles
Browse latest Browse all 1980

Lua Labs • [solved] Updating side variables from LUA script.

$
0
0
In Wesnoth 1.18.2, in my scenario WML, for some sides I have the following variables section:

Code:

    [variables]        [tactics]            [tactic]                role=assassin                count=0                weigth=3            [/tactic]            [tactic]                role=hunter                count=0                weight=2            [/tactic]            [tactic] # no particular role                count=0                weight=1            [/tactic]            total_counts=0            total_weights=6        [/tactics]    [/variables]    [/tactics]
When I'm trying to access these variable from a LUA script, this seems to work, although not exactly like the documentation describes it. https://wiki.wesnoth.org/VariablesWML#T ... les.5D_tag states that:
An array variable with given name foo is assigned using several [foo] tags, where the first tag describes foo[0], the second foo[1], ...
However, when I access:

Code:

wesnoth.sides[4].variables.tactics
,
I get:

Code:

{{'tactic', {role='assassin',count=0,weight=3}},{'tactic', {role=hunter,count=0,weight=2}},{'tactic',{weight=1,count=0}},total_counts=0,total_weights=6}
I believe this is the right representation of the variables' WML, but reading the documentation I was expecting to get:

Code:

{{role='assassin',count=0,weight=3},{role=hunter,count=0,weight=2},{count=0,weight=1}}
If the output of the query is correct, I believe the documentation should be made more clear on what user should expect.

The real problem, however, is that I cannot find a way to update any of the variables (either from LUA console or through a script). The values seem to be read-only for LUA. I can update them the deprecated way, using wesnoth.set_side_variable function, in which case the array seems to be addressed like the documentation describes, i.e. I can access the first tactic's counter with "tactics.tactic[0].count".

So to sum up, the new way of accessing these variables seems to either be buggy or insufficiently documented. Can someone shed some light on the matter, please?

Statistics: Posted by Sventimir — Yesterday, 1:24 pm



Viewing all articles
Browse latest Browse all 1980

Trending Articles