Two new [message] features
- ~LEFT() does the opposite of ~RIGHT(), but takes higher priority; use it to force an image to the left that's normally on the right (eg female silver mage) - image=~RIGHT() means "use normal portrait, but on the right"
This commit is contained in:
parent
20b07c6379
commit
7c37ad57bd
2 changed files with 25 additions and 13 deletions
|
@ -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"
|
||||
profile="portraits/humans/mage-silver+female.png~LEFT()"
|
||||
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]
|
||||
|
|
|
@ -13,16 +13,36 @@ 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 ""
|
||||
if image:find("~RIGHT%(%)") then
|
||||
left_side = false
|
||||
-- The percent signs escape the parentheses for a literal match
|
||||
image = image:gsub("~RIGHT%(%)", "")
|
||||
end
|
||||
|
||||
return image
|
||||
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.
|
||||
left_side = true
|
||||
image = image:gsub("~LEFT%(%)", "")
|
||||
end
|
||||
|
||||
if image == "none" or image == nil then
|
||||
return "", true
|
||||
end
|
||||
|
||||
return image, left_side
|
||||
end
|
||||
|
||||
local function get_caption(cfg, speaker)
|
||||
|
@ -53,17 +73,9 @@ local function get_speaker(cfg)
|
|||
end
|
||||
|
||||
local function message_user_choice(cfg, speaker, options, text_input)
|
||||
local image = get_image(cfg, speaker)
|
||||
local image, left_side = get_image(cfg, speaker)
|
||||
local caption = get_caption(cfg, speaker)
|
||||
|
||||
local left_side = true
|
||||
-- If this doesn't work, might need tostring()
|
||||
if image:find("~RIGHT()") then
|
||||
left_side = false
|
||||
-- The percent signs escape the parentheses for a literal match
|
||||
image = image:gsub("~RIGHT%(%)", "")
|
||||
end
|
||||
|
||||
local msg_cfg = {
|
||||
left_side = left_side,
|
||||
title = caption,
|
||||
|
|
Loading…
Add table
Reference in a new issue