Use wml.array_variables instead of wml.array_access.get/set
This commit is contained in:
parent
3cadac1124
commit
24b11221cf
9 changed files with 13 additions and 13 deletions
|
@ -43,7 +43,7 @@ function ca_forest_animals_move:execution(cfg)
|
||||||
|
|
||||||
-- Get the locations of all the rabbit holes
|
-- Get the locations of all the rabbit holes
|
||||||
wesnoth.wml_actions.store_items { variable = 'holes_wml' }
|
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' }
|
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
|
-- If cfg.rabbit_hole_img is set, only items with that image or halo count as holes
|
||||||
|
|
|
@ -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)
|
-- Get the locations of all items on that map (which could be rabbit holes)
|
||||||
wesnoth.wml_actions.store_items { variable = 'holes_wml' }
|
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' }
|
wesnoth.wml_actions.clear_variable { name = 'holes_wml' }
|
||||||
|
|
||||||
-- Eliminate all holes that have an enemy within 'rabbit_enemy_distance' hexes
|
-- Eliminate all holes that have an enemy within 'rabbit_enemy_distance' hexes
|
||||||
|
|
|
@ -33,7 +33,7 @@ return {
|
||||||
moves = "current",
|
moves = "current",
|
||||||
variable = "tmp_locs"
|
variable = "tmp_locs"
|
||||||
}
|
}
|
||||||
attack_locs = wml.array_access.get("tmp_locs")
|
attack_locs = wml.array_variables["tmp_locs"]
|
||||||
W.clear_variable { name = "tmp_locs" }
|
W.clear_variable { name = "tmp_locs" }
|
||||||
if (#attack_locs > 0) then break end
|
if (#attack_locs > 0) then break end
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,7 +35,7 @@ end
|
||||||
|
|
||||||
local function bandits_found(x,y)
|
local function bandits_found(x,y)
|
||||||
local bandit_types = vars.bandit_types
|
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 boss_found = vars.boss_found
|
||||||
local visited = vars.villages_visited
|
local visited = vars.villages_visited
|
||||||
local rand1 = helper.rand("3,4")
|
local rand1 = helper.rand("3,4")
|
||||||
|
|
|
@ -247,12 +247,12 @@
|
||||||
if wml.variables.target_enemies == nil then
|
if wml.variables.target_enemies == nil then
|
||||||
wml.variables.all_targets = wml.variables.target_loc
|
wml.variables.all_targets = wml.variables.target_loc
|
||||||
else
|
else
|
||||||
local target_loc = wml.array_access.get('target_loc')
|
local target_loc = wml.array_variables['target_loc']
|
||||||
local targets = wml.array_access.get('target_enemies')
|
local targets = wml.array_variables['target_enemies']
|
||||||
for k, v in pairs(target_loc) do
|
for k, v in pairs(target_loc) do
|
||||||
table.insert(targets, v)
|
table.insert(targets, v)
|
||||||
end
|
end
|
||||||
wml.array_access.set('all_targets', targets)
|
wml.array_variables['all_targets'] = targets
|
||||||
end
|
end
|
||||||
>>
|
>>
|
||||||
[/lua]
|
[/lua]
|
||||||
|
|
|
@ -178,7 +178,7 @@ function wml_actions.foreach(cfg)
|
||||||
end
|
end
|
||||||
|
|
||||||
local array_name = cfg.array or helper.wml_error "[foreach] missing required array= attribute"
|
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
|
if #array == 0 then return end -- empty and scalars unwanted
|
||||||
local item_name = cfg.variable or "this_item"
|
local item_name = cfg.variable or "this_item"
|
||||||
local this_item = utils.start_var_scope(item_name) -- if this_item is already set
|
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)
|
Note that altering the array via indexing (with the index_var)
|
||||||
is not supported; any such changes will be reverted by this line.
|
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
|
end
|
||||||
|
|
||||||
function wml_actions.switch(cfg)
|
function wml_actions.switch(cfg)
|
||||||
|
|
|
@ -192,7 +192,7 @@ end
|
||||||
|
|
||||||
--note: when using these, make sure that nothing can throw over the call to end_var_scope
|
--note: when using these, make sure that nothing can throw over the call to end_var_scope
|
||||||
function utils.start_var_scope(name)
|
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)
|
if #var == 0 then var = wml.variables[name] end --scalars (and nil/empty)
|
||||||
wml.variables[name] = nil
|
wml.variables[name] = nil
|
||||||
return var
|
return var
|
||||||
|
@ -201,7 +201,7 @@ end
|
||||||
function utils.end_var_scope(name, var)
|
function utils.end_var_scope(name, var)
|
||||||
wml.variables[name] = nil
|
wml.variables[name] = nil
|
||||||
if type(var) == "table" then
|
if type(var) == "table" then
|
||||||
wml.array_access.set(name, var)
|
wml.array_variables[name] = var
|
||||||
else
|
else
|
||||||
wml.variables[name] = var
|
wml.variables[name] = var
|
||||||
end
|
end
|
||||||
|
|
|
@ -143,7 +143,7 @@ function wesnoth.wml_actions.set_variable(cfg, variables)
|
||||||
|
|
||||||
local string_to_join = ''
|
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 element[key_name] ~= nil or (not remove_empty) then
|
||||||
if #string_to_join > 0 then
|
if #string_to_join > 0 then
|
||||||
string_to_join = string_to_join .. separator
|
string_to_join = string_to_join .. separator
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
#define ASPECT_NOTIFICATION
|
#define ASPECT_NOTIFICATION
|
||||||
<<
|
<<
|
||||||
local expected = wml.array_access.get('expected')
|
local expected = wml.array_variables['expected']
|
||||||
local aspect = wml.variables['test_attribute']
|
local aspect = wml.variables['test_attribute']
|
||||||
if ai.aspects[aspect] ~= expected[wesnoth.current.turn].value then
|
if ai.aspects[aspect] ~= expected[wesnoth.current.turn].value then
|
||||||
wml.variables['is_valid'] = false
|
wml.variables['is_valid'] = false
|
||||||
|
|
Loading…
Add table
Reference in a new issue