mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-16 18:31:32 +00:00
use lua filter in {ABILITY_TELEPORT}
this way it no longer uses variable substitution Fixes #1281
This commit is contained in:
parent
96fecea66d
commit
80d27b4584
@ -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]
|
||||
|
||||
|
@ -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]
|
||||
|
15
data/lua/teleport_filter.lua
Normal file
15
data/lua/teleport_filter.lua
Normal 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
|
Loading…
x
Reference in New Issue
Block a user