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

Lua Labs • Re: Converting LUA table to WML array

$
0
0
Looks like you're creating the same array over and over. I'm guessing you're trying to repeatedly append to coordinate_list, but you're just overwriting it.

Perhaps you could tell us what you're trying to accomplish?

If you like working with tables in WML, you could probably just try this at first and look at it in :inspect

Code:

    wesnoth.game_events.on_mouse_move = function(x, y)local u = wesnoth.units.get(17, 3)local path, cost = wesnoth.paths.find_path(u, {3,20}, { ignore_units = true, viewing_side = 0 })        wml.array_access.set("coordinate_list", path)end
Though I suspect what you're trying to do is almost this ("almost" because it's late and I'm not going to test it)

Code:

wesnoth.game_events.on_mouse_move = function(x, y)local u = wesnoth.units.get(17, 3)local path, cost = wesnoth.paths.find_path(u, {3,20}, { ignore_units = true, viewing_side = 0 })        local foo = {}for _, loc in pairs(path) do            table.append(foo, {x = loc[1], y = loc[2]})        end         wml.array_access.set("coordinate_list", foo)end

Statistics: Posted by white_haired_uncle — Today, 6:24 am



Viewing all articles
Browse latest Browse all 2146