cleaned up some code and added /fixlight command

This commit is contained in:
kaadmy 2015-10-20 11:44:38 -07:00
parent eedbe55a0a
commit 0bc3791b49
4 changed files with 36 additions and 3 deletions

View File

@ -23,6 +23,9 @@ default_privs = interact, shout, spawn, fast, player_skin
# if you're given the inital stuff; a stone pick and 10 torches
give_initial_stuff = false
# if players with interact can use the /fixlight chat command
fixlight_command_enable = true
# if you can name chests when the sign is below the chest; may cause problems
signs_allow_name_above = false

View File

@ -71,8 +71,8 @@ function headbars.attach_hpbar(to)
if bar == nil then return end
local attach_pos = {x = 0, y = 0, z = 0}
attach_pos = {x = 0, y = 9, z = 0}
-- local attach_pos = {x = 0, y = 0, z = 0}
local attach_pos = {x = 0, y = 9, z = 0}
bar:set_attach(to, "", attach_pos, {x = 0, y = 0, z = 0})
bar = bar:get_luaentity()

View File

@ -39,6 +39,36 @@ function util.fixlight(pos1, pos2)
return #nodes
end
if minetest.setting_getbool("fixlight_command_enable") then
minetest.register_chatcommand(
"fixlight",
{
params = "[radius 1-20]",
description = "Fix light in a radius around you",
privs = {interact = true},
func = function(name, param)
local rad = tonumber(param)
if rad == nil or (rad < 1 or rad > 20) then
return false, "Bad param for /fixlight; type /help fixlight"
end
local player = minetest.get_player_by_name(name)
local pos = player:getpos()
pos.x = math.floor(pos.x + 0.5)
pos.y = math.floor(pos.y + 0.5)
pos.z = math.floor(pos.z + 0.5)
local minp = {x = pos.x - rad, y = pos.y - rad, z = pos.z - rad}
local maxp = {x = pos.x + rad, y = pos.y + rad, z = pos.z + rad}
util.fixlight(minp, maxp)
minetest.chat_send_all("*** " .. name .. " has fixed light in a " .. rad .. "m radius at (" .. pos.x .. ", " .. pos.y .. ", " .. pos.z .. ")")
end
})
end
function util.nodefunc(pos1, pos2, name, func)
-- function based off fixlight

View File

@ -61,7 +61,7 @@ local function detach_wielditem(player)
local name = player:get_player_name()
wielditem[name]:remove()
-- wielditem[name] = nil
wielditem[name] = nil
end
minetest.register_on_joinplayer(attach_wielditem)