53 lines
1.3 KiB
Lua
53 lines
1.3 KiB
Lua
rgt_realms = {
|
|
realms = {
|
|
void = {
|
|
name = "void",
|
|
label = "Void",
|
|
sky = {
|
|
type = "plain",
|
|
base_color = "#000"
|
|
}
|
|
},
|
|
surface = {
|
|
name = "surface",
|
|
label = "Surface",
|
|
min = vector.new(-31000, -5000, -31000),
|
|
max = vector.new(31000, 1000, 31000),
|
|
-- TODO: Find a better way to handle admin realm transitions.
|
|
waypoint = vector.new(0, 30, 0),
|
|
}
|
|
}
|
|
}
|
|
local ns = rgt_realms
|
|
|
|
function ns.register_realm(def)
|
|
ns.realms[def.name] = def
|
|
end
|
|
|
|
function ns.get_realm_at_pos(pos)
|
|
for name, x in pairs(ns.realms) do
|
|
if name ~= "void" and vector.in_area(pos, x.min, x.max) then
|
|
return name
|
|
end
|
|
end
|
|
return "void"
|
|
end
|
|
|
|
function ns.update_realm(m)
|
|
local realm = ns.realms[ns.get_realm_at_pos(m.object:get_pos())]
|
|
m.object:set_sky(realm.sky)
|
|
end
|
|
|
|
function ns.check_position(m)
|
|
|
|
end
|
|
|
|
|
|
minetest.register_chatcommand("realm", {
|
|
func = function(name, args)
|
|
if ns.realms[args] and args ~= "void" then
|
|
minetest.get_player_by_name(name):set_pos(ns.realms[args].waypoint or (ns.realms[args].min +(ns.realms[args].max -ns.realms[args].min) /2))
|
|
ns.update_realm(rgt.players[name])
|
|
end
|
|
end
|
|
})
|