server/scripts/tools/wormholes.lua
Enno Rehling d9457a2488 rewrite of the Lua module system.
At this time, only E2 is working.
Fixing a lot of old code (monster is no longer id 0).
package.paths configured from eressea.ini
install directory configured from eressea.ini
moving building_action into a seaprate module (it's deprecated)
2014-07-26 22:52:25 +02:00

52 lines
1.4 KiB
Lua

-- 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