ilights/init.lua
Vanessa Ezekowitz 3bec84cd84 Add full 6dfacedir compatibility
Also add protecting checking, infinite stack checking, and
more complex recipe with a higher yield.
2013-10-13 13:58:07 -04:00

86 lines
2.4 KiB
Lua

-- Industrial lights mod by DanDuncombe
-- License: CC-By-Sa
ilights = {}
if minetest.get_modpath("unified_inventory") or not minetest.setting_getbool("creative_mode") then
ilights.expect_infinite_stacks = false
else
ilights.expect_infinite_stacks = true
end
ilights.modpath = minetest.get_modpath("ilights")
dofile(ilights.modpath.."/ownership.lua")
dofile(ilights.modpath.."/lib_6d.lua")
ilights.types = {
{"white", "White"},
{"grey", "Grey"},
{"black", "Black"},
{"red", "Red"},
{"yellow", "Yellow"},
{"green", "Green"},
{"cyan", "Cyan"},
{"blue", "Blue"},
{"magenta", "Magenta"},
{"orange", "Orange"},
{"violet", "Violet"},
{"dark_grey", "Dark Grey"},
{"dark_green", "Dark Green"},
{"pink", "Pink", "pink"},
{"brown", "Brown", "brown"},
}
for _, row in ipairs(ilights.types) do
local name = row[1]
local desc = row[2]
-- Node Definition
minetest.register_node("ilights:light_"..name, {
drawtype = "nodebox",
description = desc.." Industrial Light",
tiles = {"ilight_"..name.."_top.png",
"ilight_base.png",
"ilight_"..name.."_side.png"},
groups = {cracky=3},
paramtype = "light",
paramtype2 = "facedir",
light_source = 15,
node_box = {
type = "fixed",
fixed = {
{-4/16,-7/16,-4/16,4/16,3/16,4/16}, --Bulb
{-6/16,-8/16,-6/16,6/16,-7/16,6/16}, --Base
{-3/16,-7/16,-5/16,-2/16,4/16,5/16}, --Wire
{2/16,-7/16,-5/16,3/16,4/16,5/16}, --Wire
{-5/16,-7/16,-3/16,5/16,4/16,-2/16}, --Wire
{5/16,-7/16,2/16,-5/16,4/16,3/16}, --Wire
{-5/16,0/16,-5/16,5/16,1/16,5/16}, --Side Wire
{-5/16,-5/16,-5/16,5/16,-4/16,5/16}, --Side Wire
},
},
on_place = function(itemstack, placer, pointed_thing)
if not ilights:node_is_owned(pointed_thing.under, placer)
and not ilights:node_is_owned(pointed_thing.above, placer) then
lib_6d:rotate_and_place(itemstack, placer, pointed_thing, ilights.expect_infinite_stacks)
end
return itemstack
end
})
if name then
--Choose craft material
minetest.register_craft({
output = "ilights:light_"..name.." 3",
recipe = {
{ "", "default:steel_ingot", "" },
{ "dye:"..name, "default:glass", "dye:"..name },
{ "default:steel_ingot", "default:torch", "default:steel_ingot" }
},
})
end
end