mirror of
https://github.com/minetest-mods/areas.git
synced 2025-07-04 17:10:26 +02:00
Manual update due to conflict
This adds part of PR #4 and they came from inpos/areas repo, author for the changes is ElementW.
This commit is contained in:
parent
41bba581a2
commit
a23d2bad3a
@ -285,6 +285,26 @@ minetest.register_chatcommand("area_open", {
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("area_openfarming", {
|
||||
params = "<ID>",
|
||||
description = "Toggle an area open (anyone can interact farming) or closed",
|
||||
func = function(name, param)
|
||||
local id = tonumber(param)
|
||||
if not id then
|
||||
return false, "Invalid usage, see /help area_openfarming."
|
||||
end
|
||||
|
||||
if not areas:isAreaOwner(id, name) then
|
||||
return false, "Area "..id.." does not exist"
|
||||
.." or is not owned by you."
|
||||
end
|
||||
local openfarming = not areas.areas[id].openfarming
|
||||
-- Save false as nil to avoid inflating the DB.
|
||||
areas.areas[id].openfarming = openfarming or nil
|
||||
areas:save()
|
||||
return true, ("Area %s to farming."):format(openfarming and "opened" or "closed")
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("move_area", {
|
||||
params = "<ID>",
|
||||
@ -403,3 +423,60 @@ minetest.register_chatcommand("area_info", {
|
||||
end,
|
||||
})
|
||||
|
||||
--MFF DEBUT crabman(17/09/2015 ) respawn player at in special area(event) if a spawn is set.
|
||||
+minetest.register_chatcommand("area_addspawn", {
|
||||
params = "<ID>",
|
||||
privs = areas.adminPrivs,
|
||||
description = "Define special spawn for area",
|
||||
func = function(name, param)
|
||||
local id = param:match("^(%d+)")
|
||||
if not id then
|
||||
return false, "Invalid usage, see /help area_addspawn."
|
||||
end
|
||||
|
||||
id = tonumber(id)
|
||||
if not id then
|
||||
return false, "Error, Param id must be int."
|
||||
end
|
||||
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if not player then
|
||||
return false, "Error, there is not player"
|
||||
end
|
||||
local pos = player:getpos()
|
||||
if not pos then
|
||||
return false, "Error, there is not pos."
|
||||
end
|
||||
|
||||
if not areas.areas[id] then
|
||||
return false, "Area ".. id .." does not exist."
|
||||
end
|
||||
areas.areas[id].spawn = pos
|
||||
areas:save()
|
||||
return true, "spawn of area ".. id .." defined."
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("area_delspawn", {
|
||||
params = "<ID>",
|
||||
privs = areas.adminPrivs,
|
||||
description = "Delete special spawn of area",
|
||||
func = function(name, param)
|
||||
local id = param:match("^(%d+)")
|
||||
if not id then
|
||||
return false, "Invalid usage, see /help area_delspawn."
|
||||
end
|
||||
|
||||
id = tonumber(id)
|
||||
if not id then
|
||||
return false, "Error, Param id must be int."
|
||||
end
|
||||
|
||||
if not areas.areas[id] then
|
||||
return false, "Area ".. id .." does not exist."
|
||||
end
|
||||
areas.areas[id].spawn = nil
|
||||
areas:save()
|
||||
return true, "spawn of area ".. id .." deleted."
|
||||
end
|
||||
})
|
||||
|
Reference in New Issue
Block a user