Skip to content

Commit

Permalink
Lua code: replace deprecated wesnoth.get_all_vars() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsc committed May 13, 2018
1 parent 51b2dbe commit acf4269
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion data/lua/core.lua
Expand Up @@ -236,11 +236,12 @@ if wesnoth.kernel_type() == "Game Lua Kernel" then
--[========[Basic variable access]========]

-- Get all variables via wml.all_variables (read-only)
local get_all_vars_local = wesnoth.get_all_vars
setmetatable(wml, {
__metatable = "WML module",
__index = function(self, key)
if key == 'all_variables' then
return wesnoth.get_all_vars()
return get_all_vars_local()
end
return rawget(self, key)
end,
Expand Down
4 changes: 2 additions & 2 deletions data/test/scenarios/test_clear.cfg
Expand Up @@ -12,7 +12,7 @@

[lua]
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
a = true
elseif (k == "B") and (v == 10) then
Expand Down Expand Up @@ -40,7 +40,7 @@

[lua]
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
a = true
elseif (k == "B") and (v == 10) then
Expand Down

0 comments on commit acf4269

Please sign in to comment.