Use wml.array_variables instead of wml.array_access.get/set

This commit is contained in:
Celtic Minstrel 2019-11-16 13:09:04 -05:00
parent 3cadac1124
commit 24b11221cf
9 changed files with 13 additions and 13 deletions

View file

@ -43,7 +43,7 @@ function ca_forest_animals_move:execution(cfg)
-- Get the locations of all the rabbit holes
wesnoth.wml_actions.store_items { variable = 'holes_wml' }
local all_items = wml.array_access.get('holes_wml')
local all_items = wml.array_variables['holes_wml']
wesnoth.wml_actions.clear_variable { name = 'holes_wml' }
-- If cfg.rabbit_hole_img is set, only items with that image or halo count as holes

View file

@ -16,7 +16,7 @@ function ca_forest_animals_new_rabbit:execution(cfg)
-- Get the locations of all items on that map (which could be rabbit holes)
wesnoth.wml_actions.store_items { variable = 'holes_wml' }
local all_items = wml.array_access.get('holes_wml')
local all_items = wml.array_variables['holes_wml']
wesnoth.wml_actions.clear_variable { name = 'holes_wml' }
-- Eliminate all holes that have an enemy within 'rabbit_enemy_distance' hexes

View file

@ -33,7 +33,7 @@ return {
moves = "current",
variable = "tmp_locs"
}
attack_locs = wml.array_access.get("tmp_locs")
attack_locs = wml.array_variables["tmp_locs"]
W.clear_variable { name = "tmp_locs" }
if (#attack_locs > 0) then break end
end

View file

@ -35,7 +35,7 @@ end
local function bandits_found(x,y)
local bandit_types = vars.bandit_types
local bandit_villages = wml.array_access.get("bandit_villages")
local bandit_villages = wml.array_variables["bandit_villages"]
local boss_found = vars.boss_found
local visited = vars.villages_visited
local rand1 = helper.rand("3,4")

View file

@ -247,12 +247,12 @@
if wml.variables.target_enemies == nil then
wml.variables.all_targets = wml.variables.target_loc
else
local target_loc = wml.array_access.get('target_loc')
local targets = wml.array_access.get('target_enemies')
local target_loc = wml.array_variables['target_loc']
local targets = wml.array_variables['target_enemies']
for k, v in pairs(target_loc) do
table.insert(targets, v)
end
wml.array_access.set('all_targets', targets)
wml.array_variables['all_targets'] = targets
end
>>
[/lua]

View file

@ -178,7 +178,7 @@ function wml_actions.foreach(cfg)
end
local array_name = cfg.array or helper.wml_error "[foreach] missing required array= attribute"
local array = wml.array_access.get(array_name)
local array = wml.array_variables[array_name]
if #array == 0 then return end -- empty and scalars unwanted
local item_name = cfg.variable or "this_item"
local this_item = utils.start_var_scope(item_name) -- if this_item is already set
@ -232,7 +232,7 @@ function wml_actions.foreach(cfg)
Note that altering the array via indexing (with the index_var)
is not supported; any such changes will be reverted by this line.
]]
wml.array_access.set(array_name, array)
wml.array_variables[array_name] = array
end
function wml_actions.switch(cfg)

View file

@ -192,7 +192,7 @@ end
--note: when using these, make sure that nothing can throw over the call to end_var_scope
function utils.start_var_scope(name)
local var = wml.array_access.get(name) --containers and arrays
local var = wml.array_variables[name] --containers and arrays
if #var == 0 then var = wml.variables[name] end --scalars (and nil/empty)
wml.variables[name] = nil
return var
@ -201,7 +201,7 @@ end
function utils.end_var_scope(name, var)
wml.variables[name] = nil
if type(var) == "table" then
wml.array_access.set(name, var)
wml.array_variables[name] = var
else
wml.variables[name] = var
end

View file

@ -143,7 +143,7 @@ function wesnoth.wml_actions.set_variable(cfg, variables)
local string_to_join = ''
for i, element in ipairs(wml.array_access.get(array_name)) do
for i, element in ipairs(wml.array_variables[array_name]) do
if element[key_name] ~= nil or (not remove_empty) then
if #string_to_join > 0 then
string_to_join = string_to_join .. separator

View file

@ -12,7 +12,7 @@
#define ASPECT_NOTIFICATION
<<
local expected = wml.array_access.get('expected')
local expected = wml.array_variables['expected']
local aspect = wml.variables['test_attribute']
if ai.aspects[aspect] ~= expected[wesnoth.current.turn].value then
wml.variables['is_valid'] = false