From 7b5dacbec3c228e0c1a20bae830abe93b547ef77 Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Sun, 12 Jul 2015 13:53:09 +1100 Subject: [PATCH] UtBS: unified dehydration and stunned theme status icon checks --- .../Under_the_Burning_Suns/_main.cfg | 19 +------------- .../Under_the_Burning_Suns/lua/theme.lua | 25 +++++++++++++++++++ .../utils/dehydration-utils.cfg | 24 ------------------ 3 files changed, 26 insertions(+), 42 deletions(-) create mode 100644 data/campaigns/Under_the_Burning_Suns/lua/theme.lua diff --git a/data/campaigns/Under_the_Burning_Suns/_main.cfg b/data/campaigns/Under_the_Burning_Suns/_main.cfg index 37192b69148e..f2740706c8bc 100644 --- a/data/campaigns/Under_the_Burning_Suns/_main.cfg +++ b/data/campaigns/Under_the_Burning_Suns/_main.cfg @@ -167,24 +167,7 @@ {UTBS_INCLUDE scenarios} [lua] - code=<< - local _ = wesnoth.textdomain "wesnoth-utbs" - local old_unit_status = wesnoth.theme_items.unit_status - - function wesnoth.theme_items.unit_status() - local u = wesnoth.get_displayed_unit() - if not u then return {} end - local s = old_unit_status() - - if u.status.stunned then - table.insert(s, { "element", { image = "misc/stunned-status-icon.png", - tooltip = _"stunned: This unit is stunned. It cannot enforce its Zone of Control." - } } ) - end - - return s - end - >> + code="wesnoth.require 'campaigns/Under_the_Burning_Suns/lua/theme.lua'" [/lua] #endif diff --git a/data/campaigns/Under_the_Burning_Suns/lua/theme.lua b/data/campaigns/Under_the_Burning_Suns/lua/theme.lua new file mode 100644 index 000000000000..f1e0647f19dd --- /dev/null +++ b/data/campaigns/Under_the_Burning_Suns/lua/theme.lua @@ -0,0 +1,25 @@ +-- #textdomain wesnoth-utbs + +local _ = wesnoth.textdomain "wesnoth-utbs" +local old_unit_status = wesnoth.theme_items.unit_status + +function wesnoth.theme_items.unit_status() + local u = wesnoth.get_displayed_unit() + if not u then return {} end + local s = old_unit_status() + + if u.status.dehydrated then + table.insert(s, { "element", { + image = "misc/dehydration-status.png", + tooltip = _ "dehydrated: This unit is dehydrated. It will lose 4 HP and have its damage reduced by 1 each turn during the day unless prevented by healers or cured by water at an oasis.\n\nUnits cannot be killed or deal no damage as a result of dehydration." + } }) + end + + if u.status.stunned then + table.insert(s, { "element", { image = "misc/stunned-status-icon.png", + tooltip = _ "stunned: This unit is stunned. It cannot enforce its Zone of Control." + } } ) + end + + return s +end diff --git a/data/campaigns/Under_the_Burning_Suns/utils/dehydration-utils.cfg b/data/campaigns/Under_the_Burning_Suns/utils/dehydration-utils.cfg index 5ba22ba91ab0..18bf54458008 100644 --- a/data/campaigns/Under_the_Burning_Suns/utils/dehydration-utils.cfg +++ b/data/campaigns/Under_the_Burning_Suns/utils/dehydration-utils.cfg @@ -187,30 +187,6 @@ Hd, Dd*, Dd^E*, Rd #enddef # # Events # - -[event] - name=preload - first_time_only=no - [lua] - code=<< - local _ = wesnoth.textdomain "wesnoth-utbs" - local old_unit_status = wesnoth.theme_items.unit_status - function wesnoth.theme_items.unit_status() - local u = wesnoth.get_displayed_unit() - if not u then return {} end - local s = old_unit_status() - if u.status.dehydrated then - table.insert(s, { "element", { - image = "misc/dehydration-status.png", - tooltip = _"dehydrated: This unit is dehydrated. It will lose 4 HP and have its damage reduced by 1 each turn during the day unless prevented by healers or cured by water at an oasis.\n\nUnits cannot be killed or deal no damage as a result of dehydration." - } }) - end - return s - end - >> - [/lua] -[/event] - [event] name=prestart