Here's a mod that allows you to make lights that will glow accordingly to the average level of light surrounding the lamp.
It's very useful as a decorative item: the darker it gets the brighter the lamp will be, and when the sun comes up the lamp stops glowing.
The recipe: one torch surrounded by glass.
Dependencies: default
Since I'm not an artist, I don't provide textures (sorry for that) but I had interesting ideas if you feel like creating the textures yourself:
- The block wears successively 14 textures (there are 14 levels of enlightment), so you can make them so they show a specific hour (like a clock).
- You can make the textures more and more bright as their id (the number of the file name) increases to add realism.
The threshold variables are just a trick I used so that the block emits the same amount of light during more then one cycle.
Code: Select all
local LANTERN_NODES = {}
local LIGHT_THRESHOLD_NIGHT = 4
local LIGHT_THRESHOLD_DAY = 10
for i = 0, LIGHT_MAX do
table.insert(LANTERN_NODES, 'magic_lantern:magic_lantern_' .. i)
end
-- Functions
minetest.register_abm({
nodenames = LANTERN_NODES,
interval = 6,
chance = 1,
action = function(pos, node, _, __)
local aname = node.name
minetest.env:remove_node(pos)
local l = minetest.env:get_node_light(pos, nil) - 1
if l == nil then
l = 0
end
if l < LIGHT_THRESHOLD_NIGHT then
l = 0
elseif l > LIGHT_THRESHOLD_DAY then
l = LIGHT_MAX
end
local nname = 'magic_lantern:magic_lantern_' .. (LIGHT_MAX - l)
minetest.env:add_node(pos, { name = nname })
end
})
-- Nodes
for i, ml in ipairs(LANTERN_NODES) do
minetest.register_node(ml, {
tile_images = { 'magic_lantern_' .. (i - 1) .. '.png' },
inventory_image = 'magic_lantern_' .. (i - 1) .. '.png',
drawtype = 'glasslike',
paramtype = "light",
walkable = true,
sunlight_propagates = true,
light_source = i - 1,
material = minetest.digprop_glasslike(2.0),
furnace_burntime = 4,
})
end
-- Crafts
minetest.register_craft({
output = 'NodeItem "magic_lantern:magic_lantern_0" 1',
recipe = {
{'node "default:glass" 1', 'node "default:glass" 1', 'node "default:glass" 1'},
{'node "default:glass" 1', 'node "default:torch" 1', 'node "default:glass" 1'},
{'node "default:glass" 1', 'node "default:glass" 1', 'node "default:glass" 1'},
},
})



The screenshots are not really convincing because I used the same texture for all the sprites, but like I said you will probably get a better effect if you can draw good looking textures (don't hesitate to post your textures in this thread !).
Do-whatever-you-want-with-my-code license.
Download on mediafire
Feedback appreciated.