Fix indents
This commit is contained in:
parent
3ebd63f4b4
commit
67d32ab274
494
init.lua
494
init.lua
@ -6,161 +6,161 @@ minetest.register_privilege("hidden_one", {description = "Can hide from players.
|
|||||||
|
|
||||||
-- prevents player from jumping
|
-- prevents player from jumping
|
||||||
local function hobble(user, target)
|
local function hobble(user, target)
|
||||||
local player = minetest.get_player_by_name(target)
|
local player = minetest.get_player_by_name(target)
|
||||||
player:set_attribute("hobbled", "true")
|
player:set_attribute("hobbled", "true")
|
||||||
player:set_physics_override({jump = 0})
|
player:set_physics_override({jump = 0})
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_chatcommand("hobble", {
|
minetest.register_chatcommand("hobble", {
|
||||||
params = "<person>",
|
params = "<person>",
|
||||||
privs = {secret=true},
|
privs = {secret=true},
|
||||||
description = "Prevent player jumping.",
|
description = "Prevent player jumping.",
|
||||||
func = function(name, target)
|
func = function(name, target)
|
||||||
local player = minetest.get_player_by_name(target)
|
local player = minetest.get_player_by_name(target)
|
||||||
if player == nil then
|
if player == nil then
|
||||||
minetest.chat_send_player(name,"Player does not exist")
|
minetest.chat_send_player(name,"Player does not exist")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
hobble(name, target)
|
hobble(name, target)
|
||||||
minetest.chat_send_player(target, "Cursed by an admin! No more jumping!")
|
minetest.chat_send_player(target, "Cursed by an admin! No more jumping!")
|
||||||
minetest.chat_send_player(name, "Curse successful!")
|
minetest.chat_send_player(name, "Curse successful!")
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- reduces player movement speed
|
-- reduces player movement speed
|
||||||
local function slowmo(name, target)
|
local function slowmo(name, target)
|
||||||
local player = minetest.get_player_by_name(target)
|
local player = minetest.get_player_by_name(target)
|
||||||
player:set_attribute("slowed", "true")
|
player:set_attribute("slowed", "true")
|
||||||
player:set_physics_override({speed = 0.3})
|
player:set_physics_override({speed = 0.3})
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_chatcommand("slowmo", {
|
minetest.register_chatcommand("slowmo", {
|
||||||
params = "<person>",
|
params = "<person>",
|
||||||
privs = {secret=true},
|
privs = {secret=true},
|
||||||
description = "Reduce player movement speed.",
|
description = "Reduce player movement speed.",
|
||||||
func = function(name, target)
|
func = function(name, target)
|
||||||
local player = minetest.get_player_by_name(target)
|
local player = minetest.get_player_by_name(target)
|
||||||
if player == nil then
|
if player == nil then
|
||||||
minetest.chat_send_player(name,"Player does not exist")
|
minetest.chat_send_player(name,"Player does not exist")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
slowmo(name,target)
|
slowmo(name,target)
|
||||||
minetest.chat_send_player(target, "Cursed by an admin! You feel sloooooow!")
|
minetest.chat_send_player(target, "Cursed by an admin! You feel sloooooow!")
|
||||||
minetest.chat_send_player(name, "Curse successful!")
|
minetest.chat_send_player(name, "Curse successful!")
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- disable sneak glitch for the player
|
-- disable sneak glitch for the player
|
||||||
local function noglitch(name, target)
|
local function noglitch(name, target)
|
||||||
local player = minetest.get_player_by_name(target)
|
local player = minetest.get_player_by_name(target)
|
||||||
player:set_attribute("unglitched", "true")
|
player:set_attribute("unglitched", "true")
|
||||||
player:set_physics_override({sneak = false})
|
player:set_physics_override({sneak = false})
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_chatcommand("noglitch", {
|
minetest.register_chatcommand("noglitch", {
|
||||||
params = "<person>",
|
params = "<person>",
|
||||||
privs = {secret=true},
|
privs = {secret=true},
|
||||||
description = "Disable sneak glitch for a player.",
|
description = "Disable sneak glitch for a player.",
|
||||||
func = function(name, target)
|
func = function(name, target)
|
||||||
local player = minetest.get_player_by_name(target)
|
local player = minetest.get_player_by_name(target)
|
||||||
if player == nil then
|
if player == nil then
|
||||||
minetest.chat_send_player(name,"Player does not exist")
|
minetest.chat_send_player(name,"Player does not exist")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
noglitch(name, target)
|
noglitch(name, target)
|
||||||
minetest.chat_send_player(target, "Cursed by an admin! You feel less glitchy...")
|
minetest.chat_send_player(target, "Cursed by an admin! You feel less glitchy...")
|
||||||
minetest.chat_send_player(name, "Curse successful!")
|
minetest.chat_send_player(name, "Curse successful!")
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- prevent player from changing speed/direction and jumping
|
-- prevent player from changing speed/direction and jumping
|
||||||
local function freeze(name, target)
|
local function freeze(name, target)
|
||||||
local player = minetest.get_player_by_name(target)
|
local player = minetest.get_player_by_name(target)
|
||||||
player:set_attribute("frozen", "true")
|
player:set_attribute("frozen", "true")
|
||||||
player:set_physics_override({jump = 0, speed = 0})
|
player:set_physics_override({jump = 0, speed = 0})
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_chatcommand("freeze", {
|
minetest.register_chatcommand("freeze", {
|
||||||
params = "<person>",
|
params = "<person>",
|
||||||
privs = {secret=true},
|
privs = {secret=true},
|
||||||
description = "Prevent player movement.",
|
description = "Prevent player movement.",
|
||||||
func = function(name, target)
|
func = function(name, target)
|
||||||
local player = minetest.get_player_by_name(target)
|
local player = minetest.get_player_by_name(target)
|
||||||
if player == nil then
|
if player == nil then
|
||||||
minetest.chat_send_player(name,"Player does not exist")
|
minetest.chat_send_player(name,"Player does not exist")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
freeze(name, target)
|
freeze(name, target)
|
||||||
minetest.chat_send_player(target, "Cursed by an admin! You are now frozen!")
|
minetest.chat_send_player(target, "Cursed by an admin! You are now frozen!")
|
||||||
minetest.chat_send_player(name, "Curse successful!")
|
minetest.chat_send_player(name, "Curse successful!")
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- disables minimap for player
|
-- disables minimap for player
|
||||||
local function getlost(name,target)
|
local function getlost(name,target)
|
||||||
local player = minetest.get_player_by_name(target)
|
local player = minetest.get_player_by_name(target)
|
||||||
player:set_attribute("lost", "true")
|
player:set_attribute("lost", "true")
|
||||||
player:hud_set_flags({minimap = false})
|
player:hud_set_flags({minimap = false})
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_chatcommand("getlost", {
|
minetest.register_chatcommand("getlost", {
|
||||||
params = "<person>",
|
params = "<person>",
|
||||||
privs = {secret=true},
|
privs = {secret=true},
|
||||||
description = "Prevent player from using the minimap.",
|
description = "Prevent player from using the minimap.",
|
||||||
func = function(name, target)
|
func = function(name, target)
|
||||||
local player = minetest.get_player_by_name(target)
|
local player = minetest.get_player_by_name(target)
|
||||||
if player == nil then
|
if player == nil then
|
||||||
minetest.chat_send_player(name,"Player does not exist")
|
minetest.chat_send_player(name,"Player does not exist")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
getlost(name,target)
|
getlost(name,target)
|
||||||
minetest.chat_send_player(target, "Cursed by an admin! You will get lost now!")
|
minetest.chat_send_player(target, "Cursed by an admin! You will get lost now!")
|
||||||
minetest.chat_send_player(name, "Curse successful!")
|
minetest.chat_send_player(name, "Curse successful!")
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
-- trigger curse effects when player joins
|
-- trigger curse effects when player joins
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
if player:get_attribute("hobbled") == "true" then
|
if player:get_attribute("hobbled") == "true" then
|
||||||
hobble(name,name)
|
hobble(name,name)
|
||||||
end
|
end
|
||||||
if player:get_attribute("slowed") == "true" then
|
if player:get_attribute("slowed") == "true" then
|
||||||
slowmo(name,name)
|
slowmo(name,name)
|
||||||
end
|
end
|
||||||
if player:get_attribute("unglitched") == "true" then
|
if player:get_attribute("unglitched") == "true" then
|
||||||
noglitch(name,name)
|
noglitch(name,name)
|
||||||
end
|
end
|
||||||
if player:get_attribute("frozen") == "true" then
|
if player:get_attribute("frozen") == "true" then
|
||||||
freeze(name,name)
|
freeze(name,name)
|
||||||
end
|
end
|
||||||
if player:get_attribute("lost") == "true" then
|
if player:get_attribute("lost") == "true" then
|
||||||
getlost(name,name)
|
getlost(name,name)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- reset player physics
|
-- reset player physics
|
||||||
minetest.register_chatcommand("setfree",{
|
minetest.register_chatcommand("setfree",{
|
||||||
params = "<person>",
|
params = "<person>",
|
||||||
privs = {secret=true},
|
privs = {secret=true},
|
||||||
description = "Reset player movement.",
|
description = "Reset player movement.",
|
||||||
func = function(name, target)
|
func = function(name, target)
|
||||||
local player = minetest.get_player_by_name(target)
|
local player = minetest.get_player_by_name(target)
|
||||||
if player == nil then
|
if player == nil then
|
||||||
minetest.chat_send_player(name,"Player does not exist")
|
minetest.chat_send_player(name,"Player does not exist")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
player:set_attribute("hobbled", "")
|
player:set_attribute("hobbled", "")
|
||||||
player:set_attribute("slowed", "")
|
player:set_attribute("slowed", "")
|
||||||
player:set_attribute("unglitched", "")
|
player:set_attribute("unglitched", "")
|
||||||
player:set_attribute("frozen", "")
|
player:set_attribute("frozen", "")
|
||||||
player:set_attribute("lost", "")
|
player:set_attribute("lost", "")
|
||||||
player:set_physics_override({jump = 1, speed = 1, sneak = true})
|
player:set_physics_override({jump = 1, speed = 1, sneak = true})
|
||||||
player:hud_set_flags({minimap = true})
|
player:hud_set_flags({minimap = true})
|
||||||
minetest.chat_send_player(target, "The curse is lifted. You have been set free!")
|
minetest.chat_send_player(target, "The curse is lifted. You have been set free!")
|
||||||
minetest.chat_send_player(name, "The curse is lifted.")
|
minetest.chat_send_player(name, "The curse is lifted.")
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ -171,127 +171,127 @@ local priv_table = {}
|
|||||||
|
|
||||||
-- save table to file
|
-- save table to file
|
||||||
local function table_save()
|
local function table_save()
|
||||||
local data = priv_table
|
local data = priv_table
|
||||||
local f, err = io.open(minetest.get_worldpath() .. "/curse_priv_table.txt", "w")
|
local f, err = io.open(minetest.get_worldpath() .. "/curse_priv_table.txt", "w")
|
||||||
if err then
|
if err then
|
||||||
return err
|
return err
|
||||||
end
|
end
|
||||||
f:write(minetest.serialize(data))
|
f:write(minetest.serialize(data))
|
||||||
f:close()
|
f:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- read saved file
|
-- read saved file
|
||||||
local function table_read()
|
local function table_read()
|
||||||
local f, err = io.open(minetest.get_worldpath() .. "/curse_priv_table.txt", "r")
|
local f, err = io.open(minetest.get_worldpath() .. "/curse_priv_table.txt", "r")
|
||||||
local data = minetest.deserialize(f:read("*a"))
|
local data = minetest.deserialize(f:read("*a"))
|
||||||
f:close()
|
f:close()
|
||||||
return data
|
return data
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.after(3.0, function()
|
minetest.after(3.0, function()
|
||||||
local f, err = io.open(minetest.get_worldpath() .. "/curse_priv_table.txt", "r")
|
local f, err = io.open(minetest.get_worldpath() .. "/curse_priv_table.txt", "r")
|
||||||
if err then
|
if err then
|
||||||
table_save()
|
table_save()
|
||||||
else
|
else
|
||||||
priv_table = table_read()
|
priv_table = table_read()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_shutdown(function()
|
minetest.register_on_shutdown(function()
|
||||||
table_save()
|
table_save()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
-- put a player in the cage
|
-- put a player in the cage
|
||||||
minetest.register_chatcommand("cage", {
|
minetest.register_chatcommand("cage", {
|
||||||
params = "<person>",
|
params = "<person>",
|
||||||
privs = {secret=true},
|
privs = {secret=true},
|
||||||
description = "Put a player in the cage.",
|
description = "Put a player in the cage.",
|
||||||
func = function(warden_name, target_name)
|
func = function(warden_name, target_name)
|
||||||
--prevent self-caging
|
--prevent self-caging
|
||||||
if warden_name == target_name then
|
if warden_name == target_name then
|
||||||
minetest.chat_send_player(warden_name,"You can't cage yourself")
|
minetest.chat_send_player(warden_name,"You can't cage yourself")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- get target player or return
|
-- get target player or return
|
||||||
local target = minetest.get_player_by_name(target_name)
|
local target = minetest.get_player_by_name(target_name)
|
||||||
if not target then
|
if not target then
|
||||||
minetest.chat_send_player(warden_name,"Player does not exist")
|
minetest.chat_send_player(warden_name,"Player does not exist")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- return if already caged
|
-- return if already caged
|
||||||
if target:get_attribute("caged") == "true" then
|
if target:get_attribute("caged") == "true" then
|
||||||
minetest.chat_send_player(warden_name,"This player is already caged")
|
minetest.chat_send_player(warden_name,"This player is already caged")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- get cage position from config or return
|
-- get cage position from config or return
|
||||||
local cagepos = minetest.setting_get_pos("cage_coordinate")
|
local cagepos = minetest.setting_get_pos("cage_coordinate")
|
||||||
if not cagepos then
|
if not cagepos then
|
||||||
minetest.chat_send_player(warden_name, "No cage set...")
|
minetest.chat_send_player(warden_name, "No cage set...")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- add current target privs to table and save to file
|
-- add current target privs to table and save to file
|
||||||
local privs = minetest.get_player_privs(target_name)
|
local privs = minetest.get_player_privs(target_name)
|
||||||
priv_table[target_name] = privs
|
priv_table[target_name] = privs
|
||||||
table_save()
|
table_save()
|
||||||
-- remove all privs but shout and add caged and unglitched
|
-- remove all privs but shout and add caged and unglitched
|
||||||
minetest.set_player_privs(target_name,{shout = true})
|
minetest.set_player_privs(target_name,{shout = true})
|
||||||
target:set_attribute("caged", "true")
|
target:set_attribute("caged", "true")
|
||||||
noglitch(warden_name, target_name)
|
noglitch(warden_name, target_name)
|
||||||
-- move target to cage location
|
-- move target to cage location
|
||||||
target:setpos(cagepos)
|
target:setpos(cagepos)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- free a player from the cage
|
-- free a player from the cage
|
||||||
minetest.register_chatcommand("uncage", {
|
minetest.register_chatcommand("uncage", {
|
||||||
params = "<person>",
|
params = "<person>",
|
||||||
privs = {secret=true},
|
privs = {secret=true},
|
||||||
description = "Free a player from the cage.",
|
description = "Free a player from the cage.",
|
||||||
func = function(warden_name, target_name)
|
func = function(warden_name, target_name)
|
||||||
-- get target player or return
|
-- get target player or return
|
||||||
local target = minetest.get_player_by_name(target_name)
|
local target = minetest.get_player_by_name(target_name)
|
||||||
if not target then
|
if not target then
|
||||||
minetest.chat_send_player(warden_name,"Player does not exist")
|
minetest.chat_send_player(warden_name,"Player does not exist")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- return if not caged
|
-- return if not caged
|
||||||
if target:get_attribute("caged") ~= "true" then
|
if target:get_attribute("caged") ~= "true" then
|
||||||
minetest.chat_send_player(warden_name,"This player is not caged")
|
minetest.chat_send_player(warden_name,"This player is not caged")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- get release position from config or return
|
-- get release position from config or return
|
||||||
local releasepos = minetest.setting_get_pos("release_coordinate")
|
local releasepos = minetest.setting_get_pos("release_coordinate")
|
||||||
if not releasepos then
|
if not releasepos then
|
||||||
minetest.chat_send_player(warden_name, "No release point set...")
|
minetest.chat_send_player(warden_name, "No release point set...")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- get target's original privs from table and restore them
|
-- get target's original privs from table and restore them
|
||||||
local original_privs = priv_table[target_name]
|
local original_privs = priv_table[target_name]
|
||||||
minetest.set_player_privs(target_name,original_privs)
|
minetest.set_player_privs(target_name,original_privs)
|
||||||
-- remove entry for target from table and save to file
|
-- remove entry for target from table and save to file
|
||||||
priv_table[target_name] = nil
|
priv_table[target_name] = nil
|
||||||
table_save()
|
table_save()
|
||||||
-- restore sneak and move target to release point
|
-- restore sneak and move target to release point
|
||||||
target:set_physics_override({sneak = true})
|
target:set_physics_override({sneak = true})
|
||||||
target:set_attribute("unglitched", "")
|
target:set_attribute("unglitched", "")
|
||||||
target:set_attribute("caged", "")
|
target:set_attribute("caged", "")
|
||||||
target:setpos(releasepos)
|
target:setpos(releasepos)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- list caged players
|
-- list caged players
|
||||||
minetest.register_chatcommand("list_caged", {
|
minetest.register_chatcommand("list_caged", {
|
||||||
params = "",
|
params = "",
|
||||||
description = "List all caged players.",
|
description = "List all caged players.",
|
||||||
privs = {server = true},
|
privs = {server = true},
|
||||||
func = function (_, _)
|
func = function (_, _)
|
||||||
local players = ""
|
local players = ""
|
||||||
for player, _ in pairs(priv_table) do
|
for player, _ in pairs(priv_table) do
|
||||||
players = players .. player .. ", "
|
players = players .. player .. ", "
|
||||||
end
|
end
|
||||||
return true, "Currently caged players: " .. players
|
return true, "Currently caged players: " .. players
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ -302,43 +302,43 @@ minetest.register_chatcommand("list_caged", {
|
|||||||
vanished_players = {}
|
vanished_players = {}
|
||||||
|
|
||||||
minetest.register_chatcommand("vanish", {
|
minetest.register_chatcommand("vanish", {
|
||||||
params = "",
|
params = "",
|
||||||
description = "Make user invisible",
|
description = "Make user invisible",
|
||||||
privs = {hidden_one = true},
|
privs = {hidden_one = true},
|
||||||
func = function(user)
|
func = function(user)
|
||||||
local prop
|
local prop
|
||||||
local player = minetest.get_player_by_name(user)
|
local player = minetest.get_player_by_name(user)
|
||||||
vanished_players[user] = not vanished_players[user]
|
vanished_players[user] = not vanished_players[user]
|
||||||
if vanished_players[user] then
|
if vanished_players[user] then
|
||||||
prop = {visual_size = {x = 0, y = 0},
|
prop = {visual_size = {x = 0, y = 0},
|
||||||
collisionbox = {0,0,0,0,0,0}}
|
collisionbox = {0,0,0,0,0,0}}
|
||||||
player:set_nametag_attributes({color = {a = 0, r = 255, g = 255, b = 255}})
|
player:set_nametag_attributes({color = {a = 0, r = 255, g = 255, b = 255}})
|
||||||
else
|
else
|
||||||
-- default player size.
|
-- default player size.
|
||||||
prop = {visual_size = {x = 1, y = 1},
|
prop = {visual_size = {x = 1, y = 1},
|
||||||
collisionbox = {-0.35, -1, -0.35, 0.35, 1, 0.35}}
|
collisionbox = {-0.35, -1, -0.35, 0.35, 1, 0.35}}
|
||||||
player:set_nametag_attributes({color = {a = 255, r = 255, g = 255, b = 255}})
|
player:set_nametag_attributes({color = {a = 255, r = 255, g = 255, b = 255}})
|
||||||
end
|
end
|
||||||
player:set_properties(prop)
|
player:set_properties(prop)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- announcements
|
-- announcements
|
||||||
minetest.register_chatcommand("proclaim", {
|
minetest.register_chatcommand("proclaim", {
|
||||||
params = "<text>",
|
params = "<text>",
|
||||||
description = "Sends text to all players",
|
description = "Sends text to all players",
|
||||||
privs = {server = true},
|
privs = {server = true},
|
||||||
func = function (user, text)
|
func = function (user, text)
|
||||||
if not text
|
if not text
|
||||||
or text == "" then
|
or text == "" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
minetest.chat_send_all(text)
|
minetest.chat_send_all(text)
|
||||||
if minetest.get_modpath("irc") then
|
if minetest.get_modpath("irc") then
|
||||||
if irc.connected and irc.config.send_join_part then
|
if irc.connected and irc.config.send_join_part then
|
||||||
irc:say(text)
|
irc:say(text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user