Skip to content

Commit

Permalink
WML: Add [show_if] usage in [objectives] subtag [gold_carryover]
Browse files Browse the repository at this point in the history
  • Loading branch information
sigurdfdragon authored and GregoryLundberg committed Nov 30, 2017
1 parent 8b52668 commit d6d15e4
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions data/lua/wml/objectives.lua
Expand Up @@ -103,29 +103,32 @@ local function generate_objectives(cfg)
end

for obj in helper.child_range(cfg, "gold_carryover") do
local gold_carryover_bullet = obj.bullet or bullet
local r = obj.red or 255
local g = obj.green or 255
local b = obj.blue or 192

if obj.bonus ~= nil then
if obj.bonus then
gold_carryover = color_prefix(r, g, b) .. gold_carryover_bullet .. "<small>" .. _"Early finish bonus." .. "</small></span>\n"
else
gold_carryover = color_prefix(r, g, b) .. gold_carryover_bullet .. "<small>" .. _"No early finish bonus." .. "</small></span>\n"
local show_if = helper.get_child(obj, "show_if")
if not show_if or wesnoth.eval_conditional(show_if) then
local gold_carryover_bullet = obj.bullet or bullet
local r = obj.red or 255
local g = obj.green or 255
local b = obj.blue or 192

if obj.bonus ~= nil then
if obj.bonus then
gold_carryover = color_prefix(r, g, b) .. gold_carryover_bullet .. "<small>" .. _"Early finish bonus." .. "</small></span>\n"
else
gold_carryover = color_prefix(r, g, b) .. gold_carryover_bullet .. "<small>" .. _"No early finish bonus." .. "</small></span>\n"
end
end
end

if obj.carryover_percentage then
local carryover_amount_string = ""
if obj.carryover_percentage then
local carryover_amount_string = ""

if obj.carryover_percentage == 0 then
carryover_amount_string = _"No gold carried over to the next scenario."
else
carryover_amount_string = string.format(tostring(_ "%d%% of gold carried over to the next scenario."), obj.carryover_percentage)
end
if obj.carryover_percentage == 0 then
carryover_amount_string = _"No gold carried over to the next scenario."
else
carryover_amount_string = string.format(tostring(_ "%d%% of gold carried over to the next scenario."), obj.carryover_percentage)
end

gold_carryover = gold_carryover .. color_prefix(r, g, b) .. gold_carryover_bullet .. "<small>" .. carryover_amount_string .. "</small></span>\n"
gold_carryover = gold_carryover .. color_prefix(r, g, b) .. gold_carryover_bullet .. "<small>" .. carryover_amount_string .. "</small></span>\n"
end
end
end

Expand Down

0 comments on commit d6d15e4

Please sign in to comment.