Add [message]image_pos=left|right

This is meant to replace ~RIGHT() and also the newer ~LEFT(),
with one exception: ~RIGHT() will still be the standard way to
make a unit's portrait go on the right by default.
This commit is contained in:
Celtic Minstrel 2016-07-15 17:34:15 -04:00
parent 39037a7154
commit 6abd7a6941
3 changed files with 13 additions and 15 deletions

View file

@ -79,6 +79,7 @@ Version 1.13.4+dev:
(This means [advancement], [object], and [trait] tags.)
* All looping tags now give an error if they contain no [do] tag.
(They may contain multiple [do] tags, however.)
* Add [message]image_pos=left|right, which mostly supercedes ~RIGHT()
* AiWML:
* Filters within [micro_ai] can now use $this_unit, which was previously
impossible due to the config being prematurely parsed.

View file

@ -161,7 +161,7 @@ Silver magi are often more physically adept than other magi, and their skills ar
name= _ "female^Silver Mage"
gender=female
image="units/human-magi/silver-mage+female.png"
profile="portraits/humans/mage-silver+female.png~LEFT()"
profile="portraits/humans/mage-silver+female.png"
die_sound={SOUND_LIST:HUMAN_FEMALE_DIE}
{DEFENSE_ANIM "units/human-magi/silver-mage+female-defend.png" "units/human-magi/silver-mage+female.png" {SOUND_LIST:HUMAN_FEMALE_HIT} }
[attack_anim]

View file

@ -11,32 +11,29 @@ end
local function get_image(cfg, speaker)
local image = cfg.image
local left_side = true
if image == "~RIGHT()" then
image = nil
left_side = false
end
if speaker and (image == nil or image == "") then
image = speaker.portrait
end
if image == "none" or image == nil then
return "", true
end
-- Note: This is deprecated except for use to set default alignment in portraits
-- (Move it into the above if statement later)
if image:find("~RIGHT%(%)") then
left_side = false
-- The percent signs escape the parentheses for a literal match
image = image:gsub("~RIGHT%(%)", "")
end
if image:find("~LEFT%(%)") then
-- This currently overrides ~RIGHT()
-- Use if a portrait defaults to ~RIGHT(),
-- or in [unit_type] to force it to left.
if cfg.image_pos == 'left' then
left_side = true
image = image:gsub("~LEFT%(%)", "")
elseif cfg.image_pos == 'right' then
left_side = false
elseif cfg.image_pos ~= nil then
helper.wml_error('Invalid [message]image_pos - should be left or right')
end
if image == "none" or image == nil then
return "", true
end
return image, left_side