Skip to content

Commit

Permalink
Misc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Dec 30, 2014
1 parent 3acb30e commit 778c840
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions data/lua/wml-tags.lua
Expand Up @@ -295,10 +295,9 @@ local function handle_event_commands(cfg)
local insert_from
if cmd == "insert_tag" then
cmd = arg.name
local from = arg.variable
if not from then
helper.wml_error("[insert_tag] found with no variable= field")
end
local from = arg.variable or
helper.wml_error("[insert_tag] found with no variable= field")

arg = wesnoth.get_variable(from)
if type(arg) ~= "table" then
-- Corner case: A missing variable is replaced
Expand Down Expand Up @@ -336,13 +335,13 @@ wml_actions.command = handle_event_commands
-- the table, using the [] operator, rather than by using the point syntax

wml_actions["if"] = function( cfg )
if wesnoth.eval_conditional( cfg ) then -- evalutate [if] tag
local found_something = 0
if wesnoth.eval_conditional( cfg ) then -- evaluate [if] tag
local found_something = false
for then_child in helper.child_range ( cfg, "then" ) do
handle_event_commands( then_child )
found_something = 1
found_something = true
end
if found_something == 0 then
if not found_something then
if not helper.get_child( cfg, "else", nil ) then
if not helper.get_child( cfg, "elseif", nil ) then
wesnoth.message("WML warning","[if] didn't find any [then], [elseif], or [else] children. Check your {IF_VAR}!")
Expand All @@ -351,22 +350,22 @@ wml_actions["if"] = function( cfg )
end
return -- stop after executing [then] tags
else
local found_something = 0
local found_something = false
for elseif_child in helper.child_range ( cfg, "elseif" ) do
if wesnoth.eval_conditional( elseif_child ) then -- we'll evalutate the [elseif] tags one by one
if wesnoth.eval_conditional( elseif_child ) then -- we'll evaluate the [elseif] tags one by one
for then_tag in helper.child_range( elseif_child, "then" ) do
handle_event_commands( then_tag )
end
return -- stop on first matched condition
end
found_something = 1
found_something = true
end
-- no matched condition, try the [else] tags
for else_child in helper.child_range ( cfg, "else" ) do
handle_event_commands( else_child )
found_something = 1
found_something = true
end
if found_something == 0 then
if not found_something then
if not helper.get_child( cfg, "then", nil ) then
wesnoth.message("WML warning","[if] didn't find any [then], [elseif], or [else] children. Check your {IF_VAR}!")
end
Expand Down Expand Up @@ -715,7 +714,7 @@ function wml_actions.move_unit(cfg)
local to_y = tostring(cfg.to_y or helper.wml_error(coordinate_error))
local fire_event = cfg.fire_event
local muf_force_scroll = cfg.force_scroll
local check_passability = cfg.check_passability; if check_passability == nil then check_passability = true end
local check_passability = cfg.check_passability or true
cfg = helper.literal(cfg)
cfg.to_x, cfg.to_y, cfg.fire_event = nil, nil, nil
local units = wesnoth.get_units(cfg)
Expand Down

0 comments on commit 778c840

Please sign in to comment.