Performed maintenance for ShadowNinja

* Added .gitignore
* Added compatibility with the IRC plugin

In the process, one minetest.conf setting was renamed, and another removed altogether. Other than that, 0gb.us_game should behave exactly as before.
This commit is contained in:
0gb.us 2013-03-27 23:36:43 -07:00
parent 44266e22c9
commit 40fc9e3f4f
9 changed files with 92 additions and 53 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*~
Thumbs.db

View File

@ -1,6 +1,9 @@
if minetest.get_modpath("landclaim_0gb_us") then
function build_0gb_us.chunk_select(name)
local player = minetest.env:get_player_by_name(name)
if not player then
return
end
local pos = landclaim_0gb_us.get_chunk_center(player:getpos())
if not build_0gb_us.pos[name] then
build_0gb_us.pos[name] = {}

View File

@ -25,6 +25,9 @@ function build_0gb_us.import_as_cobble(name, pos0, pos1, filename)
local file = io.open(filename, "r")
if file then
local player = minetest.env:get_player_by_name(name)
if not player then
return
end
local min, max = build_0gb_us.normalize(pos0, pos1)
for line in file:lines() do
local data = line:split(" ")

View File

@ -147,6 +147,9 @@ build_0gb_us = {
local file = io.open(filename, "r")
if file then
local player = minetest.env:get_player_by_name(name)
if not player then
return
end
local min, max = build_0gb_us.normalize(pos0, pos1)
local update = {}
for line in file:lines() do

View File

@ -1,25 +1,9 @@
if minetest.setting_getbool("sudo.0gb.us") then
minetest.chatcommands.sudo_grant = minetest.chatcommands.grant
minetest.chatcommands.sudo_grant.privs.sudo = true
minetest.chatcommands.sudo_revoke = minetest.chatcommands.revoke
minetest.chatcommands.sudo_revoke.privs.sudo = true
minetest.chatcommands.sudo_teleport = minetest.chatcommands.teleport
minetest.chatcommands.sudo_teleport.privs.sudo = true
minetest.chatcommands.sudo_clearobjects = minetest.chatcommands.clearobjects
minetest.chatcommands.sudo_clearobjects.privs.sudo = true
minetest.register_privilege("sudo", "Can override the safeguards placed on commands")
local privileges = minetest.setting_get("privileges.sudo.0gb.us")
local privileges = minetest.setting_get("privileges.chatcommands.0gb.us")
if privileges then
local grantable = {}
if privileges then
for key, value in pairs(privileges:split(",")) do
grantable[value] = true
end
for key, value in pairs(privileges:split(",")) do
grantable[value] = true
end
minetest.register_chatcommand("grant", {
params = "<name> <privilege>|all",
description = "Give privilege to player",
@ -105,39 +89,52 @@ if minetest.setting_getbool("sudo.0gb.us") then
end
end,
})
minetest.register_chatcommand("teleport", {
params = "<to_name>",
description = "teleport to given player",
privs = {teleport=true},
func = function(name, param)
local location = minetest.env:get_player_by_name(param)
if location then
coords = location:getpos()
player = minetest.env:get_player_by_name(name)
player:setpos(coords)
minetest.chat_send_player(name, "Teleported to "..param..".")
else
minetest.chat_send_player(name, 'Player "'..param..'" not found.')
end
end,
})
minetest.register_chatcommand("clearobjects", {
params = "",
description = "clear all objects in loaded areas",
privs = {server=true},
func = function(name, param)
local player = minetest.env:get_player_by_name(name)
for _, obj in pairs(minetest.env:get_objects_inside_radius({x=0,y=0,z=0}, 1000000)) do
if not obj:is_player() then
obj:punch(player,0, {}, nil)
-- Do NOT replace this with obj:remove()
end
end
end,
})
end
minetest.debug("[sudo_0gb_us]: Plugin loaded from\n"..minetest.get_modpath("sudo_0gb_us"))
minetest.register_chatcommand("teleport", {
params = "<to_name>",
description = "teleport to given player",
privs = {teleport=true},
func = function(name, param)
local location = minetest.env:get_player_by_name(param)
if location then
coords = location:getpos()
player = minetest.env:get_player_by_name(name)
if not player then
return
end
player:setpos(coords)
minetest.chat_send_player(name, "Teleported to "..param..".")
else
minetest.chat_send_player(name, 'Player "'..param..'" not found.')
end
end,
})
minetest.chatcommands["give"] = nil
minetest.chatcommands["giveme"] = nil
minetest.chatcommands["spawnentity"] = nil
if not minetest.get_modpath("logpulverize_0gb_us") then
minetest.chatcommands["pulverize"] = nil
end
minetest.chatcommands["rollback"] = nil
minetest.register_chatcommand("clearobjects", {
params = "",
description = "clear all objects in loaded areas",
privs = {server=true},
func = function(name, param)
local player = minetest.env:get_player_by_name(name)
for _, obj in pairs(minetest.env:get_objects_inside_radius({x=0,y=0,z=0}, 1000000)) do
if not obj:is_player() then
obj:punch(player,0, {}, nil)
-- Do NOT replace this with obj:remove()
end
end
end,
})
minetest.debug("[chatcommands_0gb_us]: Plugin loaded from\n"..minetest.get_modpath("chatcommands_0gb_us"))

View File

@ -6,6 +6,9 @@ minetest.register_chatcommand("drain", {
privs = {drain=true},
func = function(name, param)
local player = minetest.env:get_player_by_name(name)
if not player then
return
end
local pos = player:getpos()
if not landclaim_0gb_us.can_interact(name, pos) then

View File

@ -29,6 +29,9 @@ minetest.register_chatcommand("claim", {
privs = {interact=true},
func = function(name, param)
local player = minetest.env:get_player_by_name(name)
if not player then
return
end
local pos = player:getpos()
pos.y = pos.y + .5 --compensated for Minetest's incorrect y coordinate for player objects
local owner = landclaim_0gb_us.get_owner(pos)
@ -55,6 +58,9 @@ minetest.register_chatcommand("unclaim", {
privs = {interact=true},
func = function(name, param)
local player = minetest.env:get_player_by_name(name)
if not player then
return
end
local pos = player:getpos()
pos.y = pos.y + .5 --compensated for Minetest's incorrect y coordinate for player objects
local owner = landclaim_0gb_us.get_owner(pos)
@ -84,6 +90,9 @@ minetest.register_chatcommand("sharearea", {
privs = {interact=true},
func = function(name, param)
local player = minetest.env:get_player_by_name(name)
if not player then
return
end
local pos = player:getpos()
pos.y = pos.y + .5 --compensated for Minetest's incorrect y coordinate for player objects
local owner = landclaim_0gb_us.get_owner(pos)
@ -114,6 +123,9 @@ minetest.register_chatcommand("unsharearea", {
privs = {interact=true},
func = function(name, param)
local player = minetest.env:get_player_by_name(name)
if not player then
return
end
local pos = player:getpos()
pos.y = pos.y + .5 --compensated for Minetest's incorrect y coordinate for player objects
local owner = landclaim_0gb_us.get_owner(pos)
@ -146,6 +158,9 @@ minetest.register_chatcommand("mayedit", {
local pos = minetest.string_to_pos(param)
if not pos then
local player = minetest.env:get_player_by_name(name)
if not player then
return
end
pos = player:getpos()
pos.y = pos.y + .5 --compensated for Minetest's incorrect y coordinate for player objects
end

View File

@ -3,6 +3,9 @@ minetest.register_chatcommand("claimdebug", {
description = "debug command",
privs = {interact=true},
func = function(name, param)
if not player then
return
end
local player = minetest.env:get_player_by_name(name)
local pos = player:getpos()
pos.y = pos.y + .5 --compensated for Minetest's incorrect y coordinate for player objects

View File

@ -81,6 +81,9 @@ end)
local function warp(name, warp)
if teleport[name][warp] then
local player = minetest.env:get_player_by_name(name)
if not player then
return
end
player:setpos(teleport[name][warp])
minetest.chat_send_player(name, "Teleporting to "..warp)
else
@ -113,6 +116,9 @@ local function setnewwarp(name, warp)
points_0gb_us.add_points(name, price.ore, -price.number)
points_0gb_us.save(name)
local player = minetest.env:get_player_by_name(name)
if not player then
return
end
teleport[name][warp] = player:getpos()
save(name)
minetest.chat_send_player(name, 'Warp point "'..warp..'" added at current location.')
@ -122,6 +128,9 @@ end
local function setwarp(name, warp)
if teleport[name][warp] then
local player = minetest.env:get_player_by_name(name)
if not player then
return
end
teleport[name][warp] = player:getpos()
save(name)
minetest.chat_send_player(name, 'Warp point "'..warp..'" moved to current location.')