local lamp_table = { --name, color, colorize(hex or color name:intensity(1-255)) --{'Black', 'black', 'black:225'} , {'Blue', 'blue', 'blue:225'} , {'Brown', 'brown', 'brown:225'} , --{'Cyan', 'cyan', 'cyan:200'} , --{'Dark Green', 'dark_green', 'green:225'} , --{'Dark Grey', 'dark_grey', 'black:200'} , {'Green', 'green', '#32cd32:150'} , --{'Grey', 'grey', 'black:100'} , --{'Magenta', 'magenta', 'magenta:200'} , --{'Orange', 'orange', 'orange:225'} , --{'Pink', 'pink', 'pink:225'} , {'Red', 'red', 'red:225'} , --{'Violet', 'violet', 'violet:225'} , {'White', 'white', 'white:1'} , --{'Yellow', 'yellow', 'yellow:225'} , } local lamp_color_list = {} for ii in ipairs (lamp_table) do local color = lamp_table [ii][2] table.insert (lamp_color_list, color) end local lamp_color_set = ocutil.make_set (lamp_color_list) lamp_color_list = nil for i in ipairs (lamp_table) do local name = lamp_table [i][1] local color = lamp_table [i][2] local hex = lamp_table [i][3] minetest.register_node ("mapop:lamp_"..color, { description = "Mapop " .. name .. " Lamp" , tiles = { "mp_lt.png", "mp_lb_middle.png^[colorize:"..hex.."^mp_lb.png", "mp_ls.png^[colorize:"..hex.."^mp_ls_top.png", "mp_ls.png^[colorize:"..hex.."^mp_ls_top.png", "mp_ls.png^[colorize:"..hex.."^mp_ls_top.png", "mp_ls.png^[colorize:"..hex.."^mp_ls_top.png",} , drawtype = "nodebox" , light_source = 14 , paramtype = "facedir" , drop = 'mapop:lamp_off_' .. color , on_rightclick = function (pos, node, player, itemstack, pointed_thing) node.name = "mapop:lamp_off_" .. color minetest.set_node (pos, node) end , groups = { choppy = 2, oddly_breakable_by_hand = 2 , flammable = 2 , not_in_creative_inventory = 1, furniture =1 } , node_box = { type = "fixed" , fixed = { {-0.25, -0.4375, -0.25, 0.25, -0.0625, 0.25} , {-0.375, -0.0625, -0.375, 0.375, 0.5, 0.375} , {-0.1875, -0.4375, -0.1875, 0.1875, -0.5, 0.1875} , } , } , on_punch = function (pos, node, clicker) local item = clicker:get_wielded_item():get_name() if string.sub (item, 1, 4) == "dye:" then local color = string.sub (item, 5) if lamp_color_set [color] ~= nil then node.name = "mapop:lamp_" .. color minetest.set_node (pos, node) end end end , }) minetest.register_node ("mapop:lamp_off_" .. color, { description = "Mapop " .. name.. " Lamp" , tiles = { "mp_lt.png" , "mp_lb_middle.png^[colorize:"..hex.."^mp_lb.png" , "mp_ls.png^[colorize:"..hex.."^mp_ls_top.png" , "mp_ls.png^[colorize:"..hex.."^mp_ls_top.png" , "mp_ls.png^[colorize:"..hex.."^mp_ls_top.png" , "mp_ls.png^[colorize:"..hex.."^mp_ls_top.png" , } , drawtype = "nodebox" , paramtype = "facedir" , on_rightclick = function (pos, node, player, itemstack, pointed_thing) node.name = "mapop:lamp_"..color minetest.set_node (pos, node) end , groups = { choppy=2, oddly_breakable_by_hand=2, flammable=2, furniture=1 } , node_box = { type = "fixed" , fixed = { {-0.25, -0.4375, -0.25, 0.25, -0.0625, 0.25} , {-0.375, -0.0625, -0.375, 0.375, 0.5, 0.375} , {-0.1875, -0.4375, -0.1875, 0.1875, -0.5, 0.1875} , } , } , on_punch = function (pos, node, clicker) local item = clicker:get_wielded_item():get_name() if string.sub (item, 1, 4) == "dye:" then local color = string.sub (item, 5) if lamp_color_set [color] ~= nil then node.name = "mapop:lamp_off_" .. color minetest.set_node (pos, node) end end end , }) end