-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinit.lua
More file actions
43 lines (35 loc) · 1018 Bytes
/
init.lua
File metadata and controls
43 lines (35 loc) · 1018 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
--[[
-- Jail mod by ShadowNinja
--]]
jails = {
jails = {},
filename = minetest.get_worldpath() .. "/jails.lua",
default = 0,
announce = minetest.setting_getbool("jails.announce"),
teleportDelay = tonumber(minetest.setting_get("jails.teleport_delay")) or 30,
}
local modPath = minetest.get_modpath(minetest.get_current_modname()) .. DIR_DELIM
dofile(modPath .. "api.lua")
dofile(modPath .. "commands.lua")
minetest.register_privilege("jailer", "Can jail players")
local function keepInJail(player)
local jailName, jail = jails:getJail(player:get_player_name())
if jail then
player:setpos(jail.pos)
return true -- Don't spawn normaly
end
end
minetest.register_on_joinplayer(keepInJail)
minetest.register_on_respawnplayer(keepInJail)
local stepTime = 0
minetest.register_globalstep(function(dtime)
stepTime = stepTime + dtime
if stepTime < jails.teleportDelay then
return
end
stepTime = 0
for _, player in pairs(minetest.get_connected_players()) do
keepInJail(player)
end
end)
jails:load()