local debug = false local spacelight = default.space_light_generic local tick = 0 minetest.register_globalstep (function (dtime) tick = tick + 1 if tick < 5 then return end tick = 0 for _, player in ipairs (minetest.get_connected_players()) do local pos = player:getpos() if pos.y >= 0 and upper_realms.is_outer_space (pos.y) then local minp = vector.round (vector.subtract (pos, 8)) local maxp = vector.round (vector.add (pos, 8)) local vm = minetest.get_voxel_manip() local e1, e2 = vm:read_from_map (minp, maxp) local area = VoxelArea:new { MinEdge=e1, MaxEdge=e2 } local ltdata = vm:get_light_data() local chg = false local asun local info -- The "+ 1" used in the following code block is a work-around for an -- apparent bug in the MT mapgen API. for ii in area:iterp (minp, maxp) do local sun = ltdata [ii] % 0x10 local nat = ltdata [ii] - sun if nat < ((spacelight + 0) * 0x10) then ltdata [ii] = ((spacelight + 1) * 0x10) + sun asun = sun chg = true if debug then info = nat .. " " .. sun end end end if chg then if debug then ocutil.log ("spacelight " .. info) end -- "vm:update_liquids()" should be omitted here. It seems to cause -- more problems than it solves. vm:set_light_data (ltdata) vm:write_to_map (false) -- The following code updates just one node, at the player's position, -- in a different way. This may or may not help. local node = minetest.get_node (pos) if node.name ~= "ignore" then node.param1 = ((spacelight + 1) * 0x10) + asun minetest.set_node (pos, node) end end end end end)