forked from github/server
Remove remainder of old the tunnel implementation with b:add_action().
This commit is contained in:
parent
5aa3b1161f
commit
281ed3d3e9
|
@ -1,3 +1,4 @@
|
||||||
|
-- Weltentor portal module
|
||||||
local tunnels = {}
|
local tunnels = {}
|
||||||
|
|
||||||
local buildings = {}
|
local buildings = {}
|
||||||
|
@ -24,26 +25,16 @@ local function get_target(param)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function tunnel_action(b, param)
|
local function tunnel_action(b, param)
|
||||||
local r = nil
|
|
||||||
if tonumber(param)~=nil then
|
|
||||||
r = get_region_by_id(tonumber(param))
|
|
||||||
end
|
|
||||||
local units = tunnel_travelers(b)
|
local units = tunnel_travelers(b)
|
||||||
if units~=nil then
|
local rto = get_target(param)
|
||||||
|
if rto and units then
|
||||||
eressea.log.debug("Tunnel from " .. tostring(b) .. " [" .. param .. "]")
|
eressea.log.debug("Tunnel from " .. tostring(b) .. " [" .. param .. "]")
|
||||||
for key, u in pairs(units) do
|
for key, u in pairs(units) do
|
||||||
local rto = r
|
|
||||||
if r==nil then
|
|
||||||
rto = get_target(param)
|
|
||||||
end
|
|
||||||
if rto~=nil then
|
|
||||||
u.region = rto
|
u.region = rto
|
||||||
eressea.log.debug("teleported " .. tostring(u) .. " to " .. tostring(rto))
|
eressea.log.debug("teleported " .. tostring(u) .. " to " .. tostring(rto))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return 1 -- return 0 to destroy
|
|
||||||
end
|
|
||||||
|
|
||||||
function tunnels.init()
|
function tunnels.init()
|
||||||
local r, b
|
local r, b
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
-- create a fixed path to a specific region
|
|
||||||
local function create_path(from, to)
|
|
||||||
local param = tostring(to.uid)
|
|
||||||
local b = building.create(from, "portal")
|
|
||||||
b.name = "Weltentor"
|
|
||||||
b.size = 1
|
|
||||||
b:add_action("tunnel_action", param)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- create a wonky tunnel wth more than one exit
|
|
||||||
local function create_tunnel(from, param)
|
|
||||||
local b = building.create(from, "portal")
|
|
||||||
b.name = "Weltentor"
|
|
||||||
b.size = 1
|
|
||||||
b:add_action("tunnel_action", param)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- make a tunnel from the cursor to the first selected region
|
|
||||||
function mktunnel()
|
|
||||||
local from = gmtool.get_cursor()
|
|
||||||
local to = gmtool.get_selection()()
|
|
||||||
if to~=nil then
|
|
||||||
region.create(from.x, from.y, "glacier")
|
|
||||||
create_tunnel(from, to)
|
|
||||||
gmtool.select(to, 0)
|
|
||||||
gmtool.highlight(to, 1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- turn all selected regions into targets for a wonky tunnel ("tnnL")
|
|
||||||
function mkanchors()
|
|
||||||
for r in gmtool.get_selection() do
|
|
||||||
if not r:get_key("tnnL") then
|
|
||||||
r:set_key("tnnL", true)
|
|
||||||
if r:get_flag(0) then
|
|
||||||
-- RF_CHAOTIC gets removed
|
|
||||||
r:set_flag(0, false)
|
|
||||||
end
|
|
||||||
r:set_resource("peasant", r:get_resource("peasant") + 1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- region.create and prepare all hell-regions to become wonky gates
|
|
||||||
function mkgates()
|
|
||||||
for r in regions() do
|
|
||||||
if r.plane_id==0 and r.terrain=="hell" then
|
|
||||||
create_tunnel(r, "tnnL")
|
|
||||||
region.create(r.x, r.y, "glacier")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in New Issue