Skip to content

Commit

Permalink
Add highlight=yes|no to [scroll_to], [scroll_to_unit], [message]
Browse files Browse the repository at this point in the history
Defaults to no in the first two cases, yes in the third
If yes, the target hex is outlined.
  • Loading branch information
CelticMinstrel committed Mar 20, 2016
1 parent 09d4033 commit 1c27caf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelog
Expand Up @@ -6,6 +6,9 @@ Version 1.13.4+dev:
* Fix some issues with [foreach]
* Fix some issues with backstab-like weapon specials
* Support [effect]times=<integer>
* Add highlight=yes|no to [scroll_to], [scroll_to_unit], [message]
Defaults to no in the first two cases, yes in the third
If yes, the target hex is outlined.
* Lua API:
* wesnoth.match_unit can now take a location (rather than a unit) as
the optional third parameter. This will cause the filter to consider
Expand Down
10 changes: 9 additions & 1 deletion data/lua/wml-tags.lua
Expand Up @@ -573,13 +573,21 @@ function wml_actions.scroll_to(cfg)
if not loc then return end
if not utils.optional_side_filter(cfg) then return end
wesnoth.scroll_to_tile(loc[1], loc[2], cfg.check_fogged, cfg.immediate)
if cfg.highlight then
wesnoth.highlight_hex(loc[1], loc[2])
wml_actions.redraw{}
end
end

function wml_actions.scroll_to_unit(cfg)
local u = wesnoth.get_units(cfg)[1]
if not u then return end
if not utils.optional_side_filter(cfg, "for_side", "for_side") then return end
wesnoth.scroll_to_tile(u.x, u.y, cfg.check_fogged, cfg.immediate)
if cfg.highlight then
wesnoth.highlight_hex(u.x, u.y)
wml_actions.redraw{}
end
end

function wml_actions.lock_view(cfg)
Expand All @@ -593,7 +601,7 @@ end
function wml_actions.select_unit(cfg)
local u = wesnoth.get_units(cfg)[1]
if not u then return end
wesnoth.select_hex(u.x, u.y, cfg.highlight, cfg.fire_event)
wesnoth.select_unit(u.x, u.y, cfg.highlight, cfg.fire_event)
end

function wml_actions.unit_overlay(cfg)
Expand Down
2 changes: 2 additions & 0 deletions data/lua/wml/message.lua
Expand Up @@ -206,6 +206,8 @@ function wesnoth.wml_actions.message(cfg)
-- No matching unit found, continue onto the next message
log("No speaker found for [message]", "debug")
return
elseif cfg.highlight == false then
-- Nothing to do here
elseif speaker == "narrator" then
-- Narrator, so deselect units
wesnoth.deselect_hex()
Expand Down

0 comments on commit 1c27caf

Please sign in to comment.