mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-05 00:17:40 +00:00

Also made conditions fail if they encountered a syntax or runtime error. This seems the more logical behavior than passing. WML conditional tags were split into their own Lua file. The one in lua/wml/object.lua relies on local variables so was left there.
23 lines
505 B
Lua
23 lines
505 B
Lua
local helper = wesnoth.require "helper"
|
|
|
|
function wesnoth.wml_conditionals.proceed_to_next_scenario(cfg)
|
|
local endlevel_data = wesnoth.get_end_level_data()
|
|
|
|
if not endlevel_data then
|
|
return false
|
|
else
|
|
return endlevel_data.proceed_to_next_level
|
|
end
|
|
end
|
|
|
|
function wesnoth.wml_conditionals.lua(cfg)
|
|
cfg = helper.shallow_literal(cfg)
|
|
local bytecode, message = load(cfg.code or "")
|
|
|
|
if not bytecode then
|
|
error("~lua:" .. message, 0)
|
|
else
|
|
return bytecode(helper.get_child(cfg, "args"))
|
|
end
|
|
end
|