summaryrefslogtreecommitdiff
path: root/ilights/init.lua
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-01-31 19:39:31 -0500
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-01-31 19:39:31 -0500
commit39f5cba27eef35877c91291f518974f34130fcb6 (patch)
tree117a9d1b7d4ee5f78f73e1216e982c366ed9ecc6 /ilights/init.lua
parent2922421f4a88e56a0a1c819f62bf2bc287835388 (diff)
downloaddreambuilder_modpack-39f5cba27eef35877c91291f518974f34130fcb6.tar
dreambuilder_modpack-39f5cba27eef35877c91291f518974f34130fcb6.tar.gz
dreambuilder_modpack-39f5cba27eef35877c91291f518974f34130fcb6.tar.bz2
dreambuilder_modpack-39f5cba27eef35877c91291f518974f34130fcb6.tar.xz
dreambuilder_modpack-39f5cba27eef35877c91291f518974f34130fcb6.zip
Huge update - lots of mods:
areas, biome_lib, blox, bobblocks, boost_cart, homedecor, mobs, coloredwood, ilights, inbox, item_tweaks, moreblocks, moreores, pipeworks, plasticbox, signs_lib, stainedglass, roads, unifieddyes, vines, worldedit, xban2, maybe some others I didn't think about ;-)
Diffstat (limited to 'ilights/init.lua')
-rw-r--r--ilights/init.lua173
1 files changed, 114 insertions, 59 deletions
diff --git a/ilights/init.lua b/ilights/init.lua
index ca2db24..96f2d3e 100644
--- a/ilights/init.lua
+++ b/ilights/init.lua
@@ -1,5 +1,6 @@
-- Industrial lights mod by DanDuncombe
-- License: CC-By-Sa
+-- rewritten by VanessaE to use param2 colorization
ilights = {}
@@ -19,71 +20,125 @@ end
ilights.modpath = minetest.get_modpath("ilights")
+-- Helper function to work around an engine bug
+
+function ilights.fix_rotation(pos, placer, itemstack, pointed_thing)
+ local node = minetest.get_node(pos)
+ local yaw = placer:get_look_yaw()
+ local dir = minetest.yaw_to_dir(yaw-1.5)
+ local pitch = placer:get_look_vertical()
+
+ local fdir = minetest.dir_to_wallmounted(dir)
+
+ if pitch < -(math.pi/4) then
+ fdir = 0
+ elseif pitch > math.pi/4 then
+ fdir = 1
+ end
+ minetest.swap_node(pos, { name = node.name, param2 = fdir })
+end
+
+
-- The important stuff!
-ilights.types = {
- {"white", "White", "#ffffff" },
- {"grey", "Grey", "#a0a0a0" },
- {"black", "Black", "#000000" },
- {"red", "Red", "#ff0000" },
- {"yellow", "Yellow", "#ffff00" },
- {"green", "Green", "#00ff00" },
- {"cyan", "Cyan", "#00ffff" },
- {"blue", "Blue", "#0000ff" },
- {"magenta", "Magenta", "#ff00ff" },
- {"orange", "Orange", "#ff8000" },
- {"violet", "Violet", "#8000ff" },
- {"dark_grey", "Dark Grey", "#404040" },
- {"dark_green", "Dark Green", "#008000" },
- {"pink", "Pink", "#ffb0ff" },
- {"brown", "Brown", "#604000" },
+local lamp_cbox = {
+ type = "wallmounted",
+ wall_top = { -11/32, -4/16, -11/32, 11/32, 8/16, 11/32 },
+ wall_bottom = { -11/32, -8/16, -11/32, 11/32, 4/16, 11/32 },
+ wall_side = { -8/16, -11/32, -11/32, 4/16, 11/32, 11/32 }
}
-local lamp_cbox = {
- type = "fixed",
- fixed = { -11/32, -8/16, -11/32, 11/32, 4/16, 11/32 }
+minetest.register_node("ilights:light", {
+ description = "Industrial Light",
+ drawtype = "mesh",
+ mesh = "ilights_lamp.obj",
+ tiles = {
+ { name = "ilights_lamp_base.png", color = 0xffffffff },
+ { name = "ilights_lamp_cage.png", color = 0xffffffff },
+ "ilights_lamp_bulb.png",
+ { name = "ilights_lamp_bulb_base.png", color = 0xffffffff },
+ "ilights_lamp_lens.png"
+ },
+ use_texture_alpha = true,
+ groups = {cracky=3},
+ paramtype = "light",
+ paramtype2 = "colorwallmounted",
+ palette = "unifieddyes_palette_colorwallmounted.png",
+ light_source = 14,
+ selection_box = lamp_cbox,
+ node_box = lamp_cbox,
+ after_place_node = ilights.fix_rotation,
+ after_dig_node = unifieddyes.after_dig_node,
+ on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
+ unifieddyes.on_rightclick(pos, node, clicker,
+ itemstack, pointed_thing, "ilights:light", "wallmounted")
+ end,
+})
+
+minetest.register_craft({
+ output = "ilights:light 3",
+ recipe = {
+ { "", "default:steel_ingot", "" },
+ { "", "default:glass", "" },
+ { "default:steel_ingot", "default:torch", "default:steel_ingot" }
+ },
+})
+
+-- convert old static nodes to param2 coloring
+
+ilights.colors = {
+ "white",
+ "grey",
+ "black",
+ "red",
+ "yellow",
+ "green",
+ "cyan",
+ "blue",
+ "magenta",
+ "orange",
+ "violet",
+ "dark_grey",
+ "dark_green",
+ "pink",
+ "brown"
}
-for _, row in ipairs(ilights.types) do
- local name = row[1]
- local desc = row[2]
- local colordef = row[3]
-
- -- Node Definition
-
- minetest.register_node("ilights:light_"..name, {
- description = desc.." Industrial Light",
- drawtype = "mesh",
- mesh = "ilights_lamp.obj",
- tiles = {
- "ilights_lamp_base.png",
- "ilights_lamp_cage.png",
- "ilights_lamp_bulb.png^[colorize:"..colordef..":200",
- "ilights_lamp_bulb_base.png",
- "ilights_lamp_lens.png^[colorize:"..colordef.."20:75"
- },
- use_texture_alpha = true,
- groups = {cracky=3},
- paramtype = "light",
- paramtype2 = "facedir",
- light_source = 14,
- selection_box = lamp_cbox,
- collision_box = lamp_cbox,
- on_place = minetest.rotate_node
- })
-
- 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" }
- },
- })
+ilights.old_static_nodes = {}
- end
+for _, i in ipairs (ilights.colors) do
+ table.insert(ilights.old_static_nodes, "ilights:light_"..i)
end
+minetest.register_lbm({
+ name = "ilights:convert",
+ label = "Convert ilights static nodes to use param2 color",
+ run_at_every_load = true,
+ nodenames = ilights.old_static_nodes,
+ action = function(pos, node)
+ local name = node.name
+ local color = string.sub(name, string.find(name, "_") + 1)
+ local paletteidx = unifieddyes.getpaletteidx("unifieddyes:"..color, "wallmounted")
+ local old_fdir = math.floor(node.param2 / 4)
+ local param2
+
+ if old_fdir == 5 then
+ new_fdir = 0
+ elseif old_fdir == 1 then
+ new_fdir = 5
+ elseif old_fdir == 2 then
+ new_fdir = 4
+ elseif old_fdir == 3 then
+ new_fdir = 3
+ elseif old_fdir == 4 then
+ new_fdir = 2
+ elseif old_fdir == 0 then
+ new_fdir = 1
+ end
+ param2 = paletteidx + new_fdir
+
+ minetest.set_node(pos, { name = "ilights:light", param2 = param2 })
+ local meta = minetest.get_meta(pos)
+ meta:set_string("dye", "unifieddyes:"..color)
+ end
+})