use lua filter in {ABILITY_TELEPORT}

this way it no longer uses variable substitution

Fixes #1281
This commit is contained in:
gfgtdf 2017-06-13 22:39:33 +02:00
parent 96fecea66d
commit 80d27b4584
3 changed files with 19 additions and 13 deletions

View File

@ -8,6 +8,7 @@
wesnoth.dofile 'lua/backwards-compatibility.lua'
wesnoth.dofile 'lua/wml-tags.lua'
wesnoth.dofile 'lua/feeding.lua'
wesnoth.dofile 'lua/teleport_filter.lua'
>>
[/lua]

View File

@ -201,25 +201,15 @@ Any units adjacent to this unit will fight as if it were dusk when it is night,
description= _ "This unit may teleport between any two empty villages owned by its side using one of its moves."
[tunnel]
id=village_teleport
[source]
terrain=*^V*
owner_side=$teleport_unit.side
[not]
[filter]
[not]
id=$teleport_unit.id
[/not]
[/filter]
[/not]
lua_function="teleport_source_filter"
[/source]
[target]
terrain=*^V*
owner_side=$teleport_unit.side
[not]
[filter]
[/filter]
[/not]
lua_function="teleport_target_filter"
[/target]
[filter]

View File

@ -0,0 +1,15 @@
function teleport_source_filter(x, y)
if wesnoth.get_village_owner(x, y) ~= wesnoth.get_variable("teleport_unit.side") then
return false
end
local blocking_unit = wesnoth.get_unit(x, y)
return (not blocking_unit) or blocking_unit.id == wesnoth.get_variable("teleport_unit.id")
end
function teleport_target_filter(x, y)
if wesnoth.get_village_owner(x, y) ~= wesnoth.get_variable("teleport_unit.side") then
return false
end
local blocking_unit = wesnoth.get_unit(x, y)
return not blocking_unit
end