server/src/scripts/eternath.lua

39 lines
735 B
Lua
Raw Normal View History

2005-01-03 22:28:57 +01:00
if gate_exchange==nil then
dofile("gates.lua")
end
local function eternath_travellers(b, maxsize)
2004-07-13 13:48:16 +02:00
local size = maxsize
local units = {}
local u
local first = true
for u in b.units do
if first then
first = false
else
if u.number<=size and u.weight<=u.capacity then
units[u] = u
size = size - u.number
end
end
end
return units
end
2005-01-03 22:28:57 +01:00
local function eternath_exchange(b1, b2, size)
local units1 = eternath_travellers(b1, size)
local units2 = eternath_travellers(b2, size)
2004-07-13 13:48:16 +02:00
2005-01-03 22:28:57 +01:00
gate_exchange(b1, units1, b2, units2)
2004-07-13 13:48:16 +02:00
end
function eternathgate_action(b)
if eternathgate == nil then
eternathgate = b
else
2005-01-03 22:28:57 +01:00
eternath_exchange(eternathgate, b, 10)
2004-07-13 13:48:16 +02:00
end
return 1
end