init
This commit is contained in:
commit
53466eed17
18 changed files with 687 additions and 0 deletions
37
nodes.lua
Normal file
37
nodes.lua
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
-- 1. LAMPEN-REGISTRIERUNG
|
||||
function smart_light.register_lamp_control(node_name)
|
||||
local def = minetest.registered_nodes[node_name]
|
||||
if not def then return end
|
||||
|
||||
local levels = { off = 0, low = 6, mid = 8, high = 12, max = 15 }
|
||||
local shadows = {}
|
||||
local base_name = node_name:gsub(":", "_")
|
||||
|
||||
local function cleanup_after_dig(pos, oldnode, oldmetadata)
|
||||
local area = oldmetadata.fields.sl_area
|
||||
local chan = oldmetadata.fields.sl_chan
|
||||
if area and chan then
|
||||
smart_light.unregister_light(pos, area, chan)
|
||||
end
|
||||
end
|
||||
|
||||
for suffix, light_val in pairs(levels) do
|
||||
local shadow_name = ":smart_light:" .. base_name .. "_" .. suffix
|
||||
local shadow_def = table.copy(def)
|
||||
shadow_def.light_source = light_val
|
||||
shadow_def.groups = table.copy(def.groups or {})
|
||||
shadow_def.groups.not_in_creative_inventory = 1
|
||||
shadow_def.drop = node_name
|
||||
shadow_def.after_dig_node = cleanup_after_dig
|
||||
minetest.register_node(shadow_name, shadow_def)
|
||||
shadows[suffix] = "smart_light:" .. base_name .. "_" .. suffix
|
||||
smart_light.shadow_to_original["smart_light:" .. base_name .. "_" .. suffix] = node_name
|
||||
end
|
||||
|
||||
minetest.override_item(node_name, {
|
||||
after_dig_node = cleanup_after_dig
|
||||
})
|
||||
|
||||
shadows["on"] = node_name
|
||||
smart_light.original_to_shadows[node_name] = shadows
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue