I, like many people, want brighter lights, and got sick of all the people answering "well, 14 is the max". Here's what I came up with so far:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_node("mini_sun:glow", {
drawtype = "airlike",
walkable = false,
pointable = false,
diggable = false,
climbable = false,
buildable_to = true,
light_source = 14,
paramtype = light
})
minetest.register_craft({
output = '"mini_sun:source" 2',
recipe = {
{'default:glass', 'default:glass', 'default:glass'},
{'default:glass', 'default:torch', 'default:glass'},
{'default:glass', 'default:glass', 'default:glass'},
}
})
minetest.register_node("mini_sun:source", {
tiles = { "mini_sun.png" },
drawtype = "glasslike",
groups = { cracky=3, oddly_breakable_by_hand=3 },
--sounds = default.node_sound_glass_defaults(),
drop = "mini_sun:source",
light_source = 14,
paramtype = light,
on_construct = function(pos)
for nx = pos.x-3, pos.x+3 do
for ny = pos.y-3, pos.y+3 do
for nz = pos.z-3, pos.z+3 do
local npos = {x=nx, y=ny, z=nz}
if minetest.get_node(npos).name == "air" then
minetest.add_node(npos, {name = "mini_sun:glow"})
end
end
end
end
end,
on_destruct = function(pos)
for nx = pos.x-3, pos.x+3 do
for ny = pos.y-3, pos.y+3 do
for nz = pos.z-3, pos.z+3 do
local npos = {x=nx, y=ny, z=nz}
if minetest.get_node(npos).name == "mini_sun:glow" then
minetest.remove_node(npos)
end
end
end
end
end
})
This has two interesting problems (so far).
The more important issue is that it's noticeably slow, even on my overpowered machine. By noticeably, I mean the lights don't all come on a once. Now you might say, "well, you add them sequentially, so what do you expect?" My question is twofold. Is there a way to have all the light generating nodes go on at once (as much as possible)? Is there a reason this loop of 27 add_node calls is so slow (with version 4.7) that I can watch it stagger through them?
The less critical issue has to do with removing the nodes. If two mini sun source nodes are placed near each other, they remove each other's glow nodes when destructed. I know, I know, "that's what you told them to do" you say. Okay, well how do I avoid that? Is there a way of implementing node hierarchies perhaps? Or maybe some other tactic to handle this scenario?