Lua upgrade: integer indices

As of version 5.3, Lua converts a number which as an integer value to add ".0" to the end.

Updating mainline to avoid the issue.
This commit is contained in:
Gregory A Lundberg 2016-10-21 20:22:48 -05:00
parent 93f95f1d4c
commit edacf922fb
4 changed files with 23 additions and 23 deletions

View file

@ -27,8 +27,8 @@ function wml_actions.spread_bandit_villages(cfg)
for i = 0, (count - 1) do
village_i = helper.rand("1.."..#villages)
wesnoth.set_variable("bandit_villages["..i.."].x", villages[village_i][1])
wesnoth.set_variable("bandit_villages["..i.."].y", villages[village_i][2])
wesnoth.set_variable(string.format("bandit_villages[%d].x", i), villages[village_i][1])
wesnoth.set_variable(string.format("bandit_villages[%d].y", i), villages[village_i][2])
table.remove(villages, village_i)
end
end
@ -75,7 +75,7 @@ function wml_actions.bandit_village_capture(cfg)
for i=1,#bandit_villages do
if bandit_villages[i].x == x and bandit_villages[i].y == y then
wesnoth.set_variable("bandit_villages["..(i - 1).."]")
wesnoth.set_variable(string.format("bandit_villages[%d]", i - 1))
local visited = wesnoth.get_variable("villages_visited")
wesnoth.set_variable("villages_visited", visited + 1)

View file

@ -73,13 +73,13 @@ function wesnoth.wml_actions.persistent_carryover_store(cfg)
--TODO: apply carryover multipler and carryover bonus.
V["side_store.gold"] = side.gold
for i = 1, V["side_store.unit.length"] do
V["side_store.unit[" .. (i - 1) .. "].x"] = nil
V["side_store.unit[" .. (i - 1) .. "].y"] = nil
V["side_store.unit[" .. (i - 1) .. "].hitpoints"] = nil
V["side_store.unit[" .. (i - 1) .. "].moves"] = nil
V["side_store.unit[" .. (i - 1) .. "].side"] = nil
V["side_store.unit[" .. (i - 1) .. "].goto_x"] = nil
V["side_store.unit[" .. (i - 1) .. "].goto_y"] = nil
V[string.format("side_store.unit[%d].x", i - 1)] = nil
V[string.format("side_store.unit[%d].y", i - 1)] = nil
V[string.format("side_store.unit[%d].hitpoints", i - 1)] = nil
V[string.format("side_store.unit[%d].moves", i - 1)] = nil
V[string.format("side_store.unit[%d].side", i - 1)] = nil
V[string.format("side_store.unit[%d].goto_x", i - 1)] = nil
V[string.format("side_store.unit[%d].goto_y", i - 1)] = nil
end
wml_actions.set_global_variable {
namespace = cfg.scenario_id,
@ -114,16 +114,16 @@ function wesnoth.wml_actions.persistent_carryover_unstore(cfg)
end
end
for i = 1, V["side_store.unit.length"] do
V["side_store.unit[" .. (i - 1) .. "].side"] = num
local u = wesnoth.get_unit(V["side_store.unit[" .. (i - 1) .. "].id"])
V[string.format("side_store.unit[%d].side", i - 1)] = num
local u = wesnoth.get_unit(V[string.format("side_store.unit[%d].id", i - 1)])
if u then
V["side_store.unit[" .. (i - 1) .. "].x"] = u.x
V["side_store.unit[" .. (i - 1) .. "].y"] = u.y
V[string.format("side_store.unit[%d].x", i - 1)] = u.x
V[string.format("side_store.unit[%d].y", i - 1)] = u.y
u:extract()
end
wml_actions.unstore_unit {
variable = "side_store.unit[" .. (i - 1) .. "]",
variable = string.format("side_store.unit[%d]", i - 1),
find_vacant = false,
check_passability = false,
advance = false,

View file

@ -103,7 +103,7 @@ function helper.modify_unit(filter, vars)
kill = true
})
for i = 0, wesnoth.get_variable("LUA_modify_unit.length") - 1 do
local u = "LUA_modify_unit[" .. i .. "]"
local u = string.format("LUA_modify_unit[%d]", i)
for k, v in pairs(vars) do
wesnoth.set_variable(u .. '.' .. k, v)
end

View file

@ -191,14 +191,14 @@ local function create_timed_spaws(interval, num_spawns, base_gold_amount, gold_i
break
end
end
wesnoth.set_variable("timed_spawn[" .. (spawn_number - 1) .. "]", {
wesnoth.set_variable(string.format("timed_spawn[%d]", spawn_number - 1), {
units = math.ceil(units),
turn = turn,
gold = helper.round(gold * configure_gold_factor),
pool_num = random_spawn_numbers[spawn_number],
})
else
wesnoth.set_variable("timed_spawn[" .. (spawn_number - 1) .. "]", {
wesnoth.set_variable(string.format("timed_spawn[%d]", spawn_number - 1), {
units = units_amount + 1,
turn = turn,
gold = gold,
@ -248,8 +248,8 @@ local function final_spawn()
return
end
local spawn_index = wesnoth.random(spawns_left) - 1
local spawn = wesnoth.get_variable("fixed_spawn[" .. spawn_index .. "]")
wesnoth.set_variable("fixed_spawn[" .. spawn_index .. "]")
local spawn = wesnoth.get_variable(string.format("fixed_spawn[%d]", spawn_index))
wesnoth.set_variable(string.format("fixed_spawn[%d]", spawn_index))
local types = {}
for tag in wesnoth.child_range(spawn, "type") do
table.insert(types, tag.type)
@ -392,7 +392,7 @@ on_event("prestart", function()
if weather_to_dispense[index].turns_left <= 0 then
table.remove(weather_to_dispense, index)
end
wesnoth.set_variable("weather_event[" .. event_num .. "]", {
wesnoth.set_variable(string.format("weather_event[%d]", event_num), {
turn = turn,
weather_id = weather_id,
})
@ -401,7 +401,7 @@ on_event("prestart", function()
-- Second snow happens half the time.
if weather_id == "snowfall" and heavy_snowfall_turns_left >= 0 and wesnoth.random(2) == 2 then
num_turns = get_weather_duration(heavy_snowfall_turns_left)
wesnoth.set_variable("weather_event[" .. event_num .. "]", {
wesnoth.set_variable(string.format("weather_event[%d]", event_num), {
turn = turn,
weather_id = "heavy snowfall",
})
@ -411,7 +411,7 @@ on_event("prestart", function()
end
-- Go back to clear weather.
num_turns = get_weather_duration(clear_turns_left)
wesnoth.set_variable("weather_event[" .. event_num .. "]", {
wesnoth.set_variable(string.format("weather_event[%d]", event_num), {
turn = turn,
weather_id = "clear",
})