Lua code: replace deprecated wesnoth.get_all_vars() calls

(cherry-picked from commit 64f7ad2560)
This commit is contained in:
mattsc 2018-05-11 07:22:58 -07:00
parent 8a4d1ad145
commit a0decde7b9
2 changed files with 4 additions and 3 deletions

View file

@ -236,11 +236,12 @@ if wesnoth.kernel_type() == "Game Lua Kernel" then
--[========[Basic variable access]========] --[========[Basic variable access]========]
-- Get all variables via wml.all_variables (read-only) -- Get all variables via wml.all_variables (read-only)
local get_all_vars_local = wesnoth.get_all_vars
setmetatable(wml, { setmetatable(wml, {
__metatable = "WML module", __metatable = "WML module",
__index = function(self, key) __index = function(self, key)
if key == 'all_variables' then if key == 'all_variables' then
return wesnoth.get_all_vars() return get_all_vars_local()
end end
return rawget(self, key) return rawget(self, key)
end, end,

View file

@ -12,7 +12,7 @@
[lua] [lua]
code = << local a,b,c = false,false,false code = << local a,b,c = false,false,false
for k,v in pairs(wesnoth.get_all_vars()) do for k,v in pairs(wml.all_variables) do
if k == "A" then if k == "A" then
a = true a = true
elseif (k == "B") and (v == 10) then elseif (k == "B") and (v == 10) then
@ -40,7 +40,7 @@
[lua] [lua]
code = << local a,b,c = false,false,false code = << local a,b,c = false,false,false
for k,v in pairs(wesnoth.get_all_vars()) do for k,v in pairs(wml.all_variables) do
if k == "A" then if k == "A" then
a = true a = true
elseif (k == "B") and (v == 10) then elseif (k == "B") and (v == 10) then