From 32e19e86acd4feb875112824991bfa8d948fd3a6 Mon Sep 17 00:00:00 2001 From: Vanessa Dannenberg Date: Fri, 24 Aug 2018 06:11:45 -0400 Subject: update technic, steel, and unified dyes (from my latest code) --- extranodes/depends.txt | 2 + extranodes/init.lua | 116 ++++++++++ .../technic_steel_strut_with_insulator_clip.obj | 246 +++++++++++++++++++++ .../textures/technic_steel_strut_overlay.png | Bin 0 -> 123 bytes steel/depends.txt | 1 + steel/init.lua | 69 +++++- steel/models/steel_cube.obj | 50 +++++ steel/textures/steel_default_steel_block.png | Bin 0 -> 272 bytes steel/textures/steel_strut_overlay.png | Bin 0 -> 123 bytes unifieddyes/API.md | 2 + unifieddyes/init.lua | 181 --------------- 11 files changed, 485 insertions(+), 182 deletions(-) create mode 100644 extranodes/models/technic_steel_strut_with_insulator_clip.obj create mode 100644 extranodes/textures/technic_steel_strut_overlay.png create mode 100644 steel/models/steel_cube.obj create mode 100644 steel/textures/steel_default_steel_block.png create mode 100644 steel/textures/steel_strut_overlay.png diff --git a/extranodes/depends.txt b/extranodes/depends.txt index 15b9ef5..4dcb99e 100644 --- a/extranodes/depends.txt +++ b/extranodes/depends.txt @@ -4,3 +4,5 @@ concrete unifieddyes? intllib? moreblocks? +steel? +streetsmod? diff --git a/extranodes/init.lua b/extranodes/init.lua index f6ab93a..4e2e335 100644 --- a/extranodes/init.lua +++ b/extranodes/init.lua @@ -146,6 +146,33 @@ local iclipfence_def = { sounds = default.node_sound_stone_defaults(), } +local sclip_tex = { + "technic_insulator_clip.png", + { name = "strut.png^steel_strut_overlay.png", color = "white" }, + { name = "strut.png", color = "white" } +} + +if minetest.registered_nodes["streets:steel_support"] then + sclip_tex = { + "technic_insulator_clip.png", + { name = "streets_support.png^technic_steel_strut_overlay.png", color = "white" }, + { name = "streets_support.png", color = "white" } + } +end + +local sclip_def = { + description = "Steel strut with insulator/cable clip", + drawtype = "mesh", + mesh = "technic_steel_strut_with_insulator_clip.obj", + tiles = sclip_tex, + paramtype = "light", + paramtype2 = "wallmounted", + is_ground_content = false, + sounds = default.node_sound_stone_defaults(), + groups = { choppy=1, cracky=1 }, + backface_culling = false +} + if minetest.get_modpath("unifieddyes") then iclip_def.paramtype2 = "colorwallmounted" iclip_def.palette = "unifieddyes_palette_colorwallmounted.png" @@ -158,10 +185,18 @@ if minetest.get_modpath("unifieddyes") then iclipfence_def.palette = "unifieddyes_palette_extended.png" iclipfence_def.on_construct = unifieddyes.on_construct iclipfence_def.groups = {fence=1, choppy=1, snappy=1, oddly_breakable_by_hand=1, ud_param2_colorable = 1} + + sclip_def.paramtype2 = "colorwallmounted" + sclip_def.palette = "unifieddyes_palette_colorwallmounted.png" + sclip_def.after_place_node = function(pos, placer, itemstack, pointed_thing) + unifieddyes.fix_rotation(pos, placer, itemstack, pointed_thing) + end + sclip_def.groups = {choppy=1, cracky=1, ud_param2_colorable = 1} end minetest.register_node(":technic:insulator_clip", iclip_def) minetest.register_node(":technic:insulator_clip_fencepost", iclipfence_def) +minetest.register_node(":technic:steel_strut_with_insulator_clip", sclip_def) minetest.register_craft({ output = "technic:insulator_clip", @@ -181,6 +216,39 @@ minetest.register_craft({ } }) +if minetest.registered_nodes["steel:strut_mount"] then + minetest.register_craft({ + output = "technic:steel_strut_with_insulator_clip", + recipe = { + {"technic:insulator_clip_fencepost"}, + {"steel:strut_mount"} + } + }) +end + +if minetest.registered_nodes["steel:strut"] then + minetest.register_craft({ + output = "technic:steel_strut_with_insulator_clip", + recipe = { + {"technic:insulator_clip_fencepost"}, + {"steel:strut"}, + {"default:steel_ingot"} + } + }) + +end + +if minetest.registered_nodes["streets:steel_support"] then + minetest.register_craft({ + output = "technic:steel_strut_with_insulator_clip", + recipe = { + {"technic:insulator_clip_fencepost"}, + {"streets:steel_support"}, + {"default:steel_ingot"} + } + }) +end + if minetest.get_modpath("unifieddyes") then unifieddyes.register_color_craft({ @@ -205,4 +273,52 @@ if minetest.get_modpath("unifieddyes") then } }) + unifieddyes.register_color_craft({ + output = "technic:steel_strut_with_insulator_clip", + palette = "wallmounted", + type = "shapeless", + neutral_node = "", + recipe = { + "technic:steel_strut_with_insulator_clip", + "MAIN_DYE" + } + }) + + if minetest.registered_nodes["steel:strut_mount"] then + unifieddyes.register_color_craft({ + output = "technic:steel_strut_with_insulator_clip", + palette = "wallmounted", + neutral_node = "", + recipe = { + { "technic:insulator_clip_fencepost", "MAIN_DYE" }, + { "steel:strut_mount", "" }, + } + }) + end + + if minetest.registered_nodes["steel:strut"] then + unifieddyes.register_color_craft({ + output = "technic:steel_strut_with_insulator_clip", + palette = "wallmounted", + neutral_node = "", + recipe = { + { "technic:insulator_clip_fencepost", "MAIN_DYE" }, + { "steel:strut", "" }, + { "default:steel_ingot", "" } + } + }) + end + + if minetest.registered_nodes["streets:steel_support"] then + unifieddyes.register_color_craft({ + output = "technic:steel_strut_with_insulator_clip", + palette = "wallmounted", + neutral_node = "technic:steel_strut_with_insulator_clip", + recipe = { + { "technic:insulator_clip_fencepost", "MAIN_DYE" }, + { "streets:steel_support", "" }, + { "default:steel_ingot", "" } + } + }) + end end diff --git a/extranodes/models/technic_steel_strut_with_insulator_clip.obj b/extranodes/models/technic_steel_strut_with_insulator_clip.obj new file mode 100644 index 0000000..7226d1e --- /dev/null +++ b/extranodes/models/technic_steel_strut_with_insulator_clip.obj @@ -0,0 +1,246 @@ +# Blender v2.79 (sub 0) OBJ File: 'technic steel strut with insulator clip.blend' +# www.blender.org +o Cube_Cube_Material.001 +v -0.375000 0.500532 -0.250000 +v -0.249997 0.562500 -0.249997 +v 0.249997 0.562500 -0.249997 +v 0.375000 0.500532 -0.250000 +v 0.249997 0.562500 0.249997 +v 0.375000 0.500532 0.250000 +v -0.249997 0.562500 0.249997 +v -0.375000 0.500532 0.250000 +v 0.187500 0.562500 -0.187500 +v -0.168668 0.718750 0.168668 +v 0.168668 0.718750 0.168668 +v 0.187500 0.750000 0.187500 +v -0.187500 0.750000 0.187500 +v 0.168668 0.718750 -0.168668 +v 0.187500 0.750000 -0.187500 +v -0.168668 0.718750 -0.168668 +v -0.187500 0.750000 -0.187500 +v 0.250000 0.750000 -0.250000 +v 0.250000 0.750000 0.250000 +v -0.250000 0.750000 -0.250000 +v -0.250000 1.250000 -0.250000 +v 0.250000 1.250000 -0.250000 +v 0.250000 1.250000 0.250000 +v -0.250000 1.250000 0.250000 +v -0.250000 0.750000 0.250000 +v -0.168668 0.593750 0.168668 +v 0.168668 0.593750 0.168668 +v 0.187500 0.625000 0.187500 +v -0.187500 0.625000 0.187500 +v 0.168668 0.593750 -0.168668 +v 0.187500 0.625000 -0.187500 +v -0.168668 0.593750 -0.168668 +v -0.187500 0.625000 -0.187500 +v -0.168668 0.656250 0.168668 +v 0.168668 0.656250 0.168668 +v 0.187500 0.687500 0.187500 +v -0.187500 0.687500 0.187500 +v 0.168668 0.656250 -0.168668 +v 0.187500 0.687500 -0.187500 +v -0.168668 0.656250 -0.168668 +v -0.187500 0.687500 -0.187500 +v 0.187500 0.562500 0.187500 +v -0.187500 0.562500 0.187500 +v -0.187500 0.562500 -0.187500 +v -0.499468 -0.499468 -0.499468 +v -0.499468 0.500000 -0.499468 +v 0.499468 -0.499468 -0.499468 +v -0.499468 -0.499468 0.499468 +v -0.499468 0.500000 0.499468 +v 0.499468 -0.499468 0.499468 +v 0.499468 0.500000 -0.499468 +v 0.499468 0.500000 0.499468 +vt 1.000000 0.875000 +vt 0.937500 0.750000 +vt 0.937500 0.250000 +vt 1.000000 0.125000 +vt 0.250000 0.875000 +vt 0.250000 0.750000 +vt 0.750000 0.750000 +vt 0.750000 0.875000 +vt 0.000000 0.125000 +vt 0.062500 0.250000 +vt 0.062500 0.750000 +vt 0.000000 0.875000 +vt 0.750000 0.250000 +vt 0.687500 0.687500 +vt 0.687500 0.312500 +vt 0.312500 0.687500 +vt 0.250000 0.250000 +vt 0.312500 0.312500 +vt 0.331332 1.218750 +vt 0.668668 1.218750 +vt 0.687500 1.250000 +vt 0.312500 1.250000 +vt 0.531250 0.666667 +vt 0.531250 0.333333 +vt 0.500000 0.312500 +vt 0.500000 0.687500 +vt 0.531250 0.333333 +vt 0.531250 0.666667 +vt 0.500000 0.687500 +vt 0.500000 0.312500 +vt 0.331332 1.218750 +vt 0.668668 1.218750 +vt 0.687500 1.250000 +vt 0.312500 1.250000 +vt 0.687500 0.312500 +vt 0.750000 0.250000 +vt 0.750000 0.750000 +vt 0.687500 0.687500 +vt 0.500000 0.250000 +vt 0.500000 0.750000 +vt 0.000000 0.750000 +vt 0.000000 0.250000 +vt 0.500000 0.250000 +vt 0.000000 0.250000 +vt 0.000000 0.750000 +vt 0.500000 0.750000 +vt 0.500000 0.250000 +vt 0.500000 0.750000 +vt 0.000000 0.750000 +vt 0.000000 0.250000 +vt 0.000000 0.250000 +vt 0.500000 0.750000 +vt 0.250000 0.250000 +vt 0.750000 0.250000 +vt 0.750000 0.750000 +vt 0.250000 0.750000 +vt 0.250000 0.750000 +vt 0.312500 0.687500 +vt 0.250000 0.250000 +vt 0.312500 0.312500 +vt 0.250000 0.125000 +vt 0.750000 0.125000 +vt 0.331332 1.093750 +vt 0.668668 1.093750 +vt 0.687500 1.125000 +vt 0.312500 1.125000 +vt 0.656250 0.666667 +vt 0.656250 0.333333 +vt 0.625000 0.312500 +vt 0.625000 0.687500 +vt 0.656250 0.333333 +vt 0.656250 0.666667 +vt 0.625000 0.687500 +vt 0.625000 0.312500 +vt 0.331332 1.093750 +vt 0.668668 1.093750 +vt 0.687500 1.125000 +vt 0.312500 1.125000 +vt 0.331332 1.156250 +vt 0.668668 1.156250 +vt 0.687500 1.187500 +vt 0.312500 1.187500 +vt 0.593750 0.666667 +vt 0.593750 0.333333 +vt 0.562500 0.312500 +vt 0.562500 0.687500 +vt 0.593750 0.333333 +vt 0.593750 0.666667 +vt 0.562500 0.687500 +vt 0.562500 0.312500 +vt 0.331332 1.156250 +vt 0.668668 1.156250 +vt 0.687500 1.187500 +vt 0.312500 1.187500 +vt 0.312500 1.062500 +vt 0.687500 1.062500 +vt 0.687500 0.312500 +vt 0.687500 0.312500 +vt 0.687500 0.687500 +vt 0.312500 1.062500 +vt 0.687500 1.062500 +vt 0.000000 0.750000 +vt 0.000000 0.250000 +vt 1.000000 0.250000 +vt 1.000000 0.750000 +vt 1.000000 1.000000 +vt -0.000000 1.000000 +vt 0.000000 -0.000000 +vt 1.000000 -0.000000 +vt 1.000000 1.000000 +vt -0.000000 1.000000 +vt 0.000000 -0.000000 +vt 1.000000 -0.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 1.000000 -0.000000 +vt 1.000000 1.000000 +vt 1.000000 1.000000 +vt 0.000000 0.000000 +vt -0.000000 0.000000 +vn 0.0000 0.0000 -1.0000 +vn 0.4442 0.8960 -0.0000 +vn 0.0000 0.0000 1.0000 +vn 0.0000 1.0000 -0.0000 +vn 0.0000 -0.5161 0.8565 +vn 0.8565 -0.5161 0.0000 +vn -0.8565 -0.5161 0.0000 +vn 0.0000 -0.5161 -0.8565 +vn -0.0000 -1.0000 -0.0000 +vn 1.0000 -0.0000 0.0000 +vn -1.0000 0.0000 -0.0000 +vn -0.4442 0.8960 -0.0000 +vn -0.0000 0.5161 0.8565 +vn 0.8565 0.5161 -0.0000 +vn -0.8565 0.5161 -0.0000 +vn 0.0000 0.5161 -0.8565 +g Cube_Cube_Material.001_Cube_Cube_Material.001_clip +s 1 +f 1/1/1 2/2/1 3/3/1 4/4/1 +f 4/5/2 3/6/2 5/7/2 6/8/2 +f 6/9/3 5/10/3 7/11/3 8/12/3 +f 7/13/4 5/7/4 42/14/4 43/15/4 +f 5/7/4 3/6/4 9/16/4 42/14/4 +f 2/17/4 7/13/4 43/15/4 44/18/4 +f 3/6/4 2/17/4 44/18/4 9/16/4 +f 10/19/5 11/20/5 12/21/5 13/22/5 +f 11/23/6 14/24/6 15/25/6 12/26/6 +f 16/27/7 10/28/7 13/29/7 17/30/7 +f 14/31/8 16/32/8 17/33/8 15/34/8 +f 15/35/9 18/36/9 19/37/9 12/38/9 +f 20/39/1 21/40/1 22/41/1 18/42/1 +f 18/43/10 22/44/10 23/45/10 19/46/10 +f 19/47/3 23/48/3 24/49/3 25/50/3 +f 21/51/11 20/39/11 25/52/11 24/49/11 +f 21/53/4 24/54/4 23/55/4 22/56/4 +f 12/38/9 19/37/9 25/57/9 13/58/9 +f 13/58/9 25/57/9 20/59/9 17/60/9 +f 17/60/9 20/59/9 18/36/9 15/35/9 +f 2/17/12 1/61/12 8/62/12 7/13/12 +f 26/63/5 27/64/5 28/65/5 29/66/5 +f 27/67/6 30/68/6 31/69/6 28/70/6 +f 32/71/7 26/72/7 29/73/7 33/74/7 +f 30/75/8 32/76/8 33/77/8 31/78/8 +f 34/79/5 35/80/5 36/81/5 37/82/5 +f 35/83/6 38/84/6 39/85/6 36/86/6 +f 40/87/7 34/88/7 37/89/7 41/90/7 +f 38/91/8 40/92/8 41/93/8 39/94/8 +f 37/82/13 36/81/13 11/20/13 10/19/13 +f 36/86/14 39/85/14 14/24/14 11/23/14 +f 41/90/15 37/89/15 10/28/15 16/27/15 +f 39/94/16 41/93/16 16/32/16 14/31/16 +f 43/95/13 42/96/13 27/64/13 26/63/13 +f 42/14/14 9/97/14 30/68/14 27/67/14 +f 44/98/15 43/99/15 26/72/15 32/71/15 +f 9/100/16 44/101/16 32/76/16 30/75/16 +f 29/66/13 28/65/13 35/80/13 34/79/13 +f 28/70/14 31/69/14 38/84/14 35/83/14 +f 33/74/15 29/73/15 34/88/15 40/87/15 +f 31/78/16 33/77/16 40/92/16 38/91/16 +f 8/102/9 1/103/9 4/104/9 6/105/9 +g Cube_Cube_Material.001_Cube_Cube_Material.001_sides_with_band +s off +f 47/106/10 51/107/10 52/108/10 50/109/10 +f 48/110/11 49/111/11 46/112/11 45/113/11 +f 47/114/9 50/115/9 48/116/9 45/117/9 +f 51/118/4 46/112/4 49/111/4 52/119/4 +g Cube_Cube_Material.001_Cube_Cube_Material.001_sides_without_band +f 45/113/1 46/120/1 51/107/1 47/121/1 +f 50/109/3 52/119/3 49/111/3 48/122/3 diff --git a/extranodes/textures/technic_steel_strut_overlay.png b/extranodes/textures/technic_steel_strut_overlay.png new file mode 100644 index 0000000..fd5bcb2 Binary files /dev/null and b/extranodes/textures/technic_steel_strut_overlay.png differ diff --git a/steel/depends.txt b/steel/depends.txt index 5643dca..105a865 100644 --- a/steel/depends.txt +++ b/steel/depends.txt @@ -3,3 +3,4 @@ streets? homedecor? protector? node_ownership? +unifieddyes? diff --git a/steel/init.lua b/steel/init.lua index 0b1ef0c..72aa92b 100644 --- a/steel/init.lua +++ b/steel/init.lua @@ -100,8 +100,11 @@ minetest.register_node("steel:plate_rusted", { sounds = default.node_sound_stone_defaults(), }) +local base_tex = "strut.png" + if minetest.registered_nodes["streets:steel_support"] then minetest.register_alias("steel:strut","streets:steel_support") + base_tex = "streets_support.png" else minetest.register_node("steel:strut", { drawtype = "glasslike", @@ -114,6 +117,26 @@ else }) minetest.register_alias("streets:steel_support","steel:strut") end + +minetest.register_node("steel:strut_mount", { + description = "Strut with mount", + drawtype = "mesh", + mesh = "steel_cube.obj", + tiles = { + base_tex, + base_tex, + base_tex.."^steel_strut_overlay.png", + base_tex.."^steel_strut_overlay.png", + base_tex.."^steel_strut_overlay.png", + base_tex.."^steel_strut_overlay.png", + }, + is_ground_content = true, + paramtype= "light", + paramtype2 = "wallmounted", + groups = {choppy=1,cracky=1}, + sounds = default.node_sound_stone_defaults(), +}) + minetest.register_node("steel:grate_soft", { description = "Soft Steel Grate", drawtype = "fencelike", @@ -266,6 +289,22 @@ minetest.register_craft({ {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}, } }) + +minetest.register_craft({ + output = 'steel:strut_mount', + recipe = { + {'steel:strut', 'default:steel_ingot'}, + } +}) + +minetest.register_craft({ + output = 'steel:strut_mount', + recipe = { + {'streets:steel_support', 'default:steel_ingot'}, + } +}) + + --remelting recipes minetest.register_craft({ @@ -317,6 +356,34 @@ minetest.register_craft({ } }) +if minetest.get_modpath("unifieddyes") then + -- Colorize default:steel_block + + minetest.register_node("steel:steel_block", { + description = "Steel block (colorized)", + tiles = {"steel_default_steel_block.png"}, + paramtype = "light", + paramtype2 = "color", + is_ground_content = false, + palette = "unifieddyes_palette_extended.png", + groups = {cracky=1, level=2, ud_param2_colorable=1, not_in_creative_inventory=1}, + on_construct = unifieddyes.on_construct, + sounds = default.node_sound_metal_defaults(), + }) + minetest.override_item("default:steelblock", { + palette = "unifieddyes_palette_extended.png", + groups = {cracky=1, level=2, ud_param2_colorable=1}, + }) - + unifieddyes.register_color_craft({ + output = "steel:steel_block", + palette = "extended", + neutral_node = "default:steelblock", + type = "shapeless", + recipe = { + "NEUTRAL_NODE", + "MAIN_DYE", + } + }) +end diff --git a/steel/models/steel_cube.obj b/steel/models/steel_cube.obj new file mode 100644 index 0000000..349ca31 --- /dev/null +++ b/steel/models/steel_cube.obj @@ -0,0 +1,50 @@ +# Blender v2.79 (sub 0) OBJ File: 'simple-cube.blend' +# www.blender.org +o Cube_Cube.001 +v 0.499468 -0.499468 -0.499468 +v 0.499468 0.499468 -0.499468 +v 0.499468 -0.499468 0.499468 +v 0.499468 0.499468 0.499468 +v -0.499468 -0.499468 -0.499468 +v -0.499468 0.499468 -0.499468 +v -0.499468 -0.499468 0.499468 +v -0.499468 0.499468 0.499468 +vt 1.000000 1.000000 +vt -0.000000 1.000000 +vt 0.000000 -0.000000 +vt 1.000000 0.000000 +vt 0.000000 -0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt -0.000000 1.000000 +vt 0.000000 1.000000 +vt -0.000000 0.000000 +vt 1.000000 -0.000000 +vt 1.000000 1.000000 +vt 1.000000 -0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt -0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt -0.000000 1.000000 +vt 0.000000 -0.000000 +vn 0.0000 1.0000 0.0000 +vn 0.0000 -1.0000 0.0000 +vn -1.0000 0.0000 0.0000 +vn 1.0000 0.0000 0.0000 +vn 0.0000 0.0000 1.0000 +vn 0.0000 0.0000 -1.0000 +g Cube_Cube.001_top +s off +f 8/1/1 4/2/1 2/3/1 6/4/1 +g Cube_Cube.001_bottom +f 3/5/2 7/6/2 5/7/2 1/8/2 +g Cube_Cube.001_right +f 7/6/3 8/1/3 6/9/3 5/10/3 +g Cube_Cube.001_left +f 1/11/4 2/12/4 4/2/4 3/5/4 +g Cube_Cube.001_back +f 3/13/5 4/14/5 8/15/5 7/16/5 +g Cube_Cube.001_front +f 5/17/6 6/18/6 2/19/6 1/20/6 diff --git a/steel/textures/steel_default_steel_block.png b/steel/textures/steel_default_steel_block.png new file mode 100644 index 0000000..c8f80be Binary files /dev/null and b/steel/textures/steel_default_steel_block.png differ diff --git a/steel/textures/steel_strut_overlay.png b/steel/textures/steel_strut_overlay.png new file mode 100644 index 0000000..fd5bcb2 Binary files /dev/null and b/steel/textures/steel_strut_overlay.png differ diff --git a/unifieddyes/API.md b/unifieddyes/API.md index 9072a22..decf76d 100644 --- a/unifieddyes/API.md +++ b/unifieddyes/API.md @@ -152,3 +152,5 @@ If your mod never has never used Unified Dyes at all, in short, do the following If your colored node is based on someone else's neutral node, for example if you made a mod that creates multiple colors of minetest_game's default clay, you may find it best to create a single "stand-in" node that's identical to the neutral node, but named for your mod, hidden from the creative inventory, and has a properly-prepared grayscale texture image in addition to the above keys. Use the neutral node and the custom hidden node as in the above craft helper call. Then use minetest.override_item() to add the on_construct and palette keys and the ud_param2_colorable group to that "someone else's" node. * You will need to write a run-only-once LBM to convert your old statically-colored nodes to use hardware coloring. See above for functions that will help reduce the work required for this part. + +If your mod has no colorable items, and you wish to expand it accordingly, follow the above "never used" section, skipping the "remove/delete this and that" items, and of course omitting the LBM. diff --git a/unifieddyes/init.lua b/unifieddyes/init.lua index dd4b5e0..5619199 100644 --- a/unifieddyes/init.lua +++ b/unifieddyes/init.lua @@ -597,180 +597,6 @@ function unifieddyes.getpaletteidx(color, palette_type) end end -function unifieddyes.on_use(itemstack, player, pointed_thing) - local stackname = itemstack:get_name() - local playername = player:get_player_name() - - if pointed_thing and pointed_thing.type == "node" and unifieddyes.select_node(pointed_thing) then - if minetest.is_protected(unifieddyes.select_node(pointed_thing), playername) - and not minetest.check_player_privs(playername, "protection_bypass") then - minetest.chat_send_player(playername, "Sorry, someone else owns that spot.") - return - end - end - - if pointed_thing and pointed_thing.type == "object" then - pointed_thing.ref:punch(player, 0, itemstack:get_tool_capabilities()) - return player:get_wielded_item() -- punch may modified the wielded item, load the new and return it - end - - if not (pointed_thing and pointed_thing.type == "node") then return end -- if "using" the dye on nothing at all (e.g. air) - - local pos = minetest.get_pointed_thing_position(pointed_thing) - local node = minetest.get_node(pos) - - local nodedef = minetest.registered_nodes[node.name] - - if not nodedef then return end -- target was an unknown node, just bail out - - -- if the node has an on_punch defined, bail out and call that instead, unless "sneak" is pressed. - if not player:get_player_control().sneak then - local onpunch = nodedef.on_punch(pos, node, player, pointed_thing) - if onpunch then - return onpunch - end - end - - -- if the target is unknown, has no groups defined, or isn't UD-colorable, just bail out - if not (nodedef and nodedef.groups and nodedef.groups.ud_param2_colorable) then - minetest.chat_send_player(playername, "That node can't be colored.") - return - end - - local newnode = nodedef.ud_replacement_node - local palette_type - - if nodedef.palette == "unifieddyes_palette_extended.png" then - palette_type = "extended" - elseif nodedef.palette == "unifieddyes_palette.png" then - palette_type = false - elseif nodedef.paramtype2 == "colorfacedir" then - palette_type = true - elseif nodedef.paramtype2 == "colorwallmounted" then - palette_type = "wallmounted" - end - - if minetest.is_protected(pos, playername) and not minetest.check_player_privs(playername, {protection_bypass=true}) then - minetest.record_protection_violation(pos, playername) - return - end - - local pos2 = unifieddyes.select_node(pointed_thing) - local paletteidx, hue = unifieddyes.getpaletteidx(stackname, palette_type) - - if paletteidx then - - local meta = minetest.get_meta(pos) - local prevdye = meta:get_string("dye") - local inv = player:get_inventory() - - if not (inv:contains_item("main", prevdye) and creative_mode) and minetest.registered_items[prevdye] then - if inv:room_for_item("main", prevdye) then - inv:add_item("main", prevdye) - else - minetest.add_item(pos, prevdye) - end - end - - meta:set_string("dye", stackname) - - if prevdye == stackname then - local a,b = string.find(stackname, ":") - minetest.chat_send_player(playername, "That node is already "..string.sub(stackname, a + 1).."." ) - return - elseif not creative_mode then - itemstack:take_item() - end - - node.param2 = paletteidx - - local oldpaletteidx, oldhuenum = unifieddyes.getpaletteidx(prevdye, palette_type) - local oldnode = minetest.get_node(pos) - - local oldhue = nil - for _, i in ipairs(unifieddyes.HUES) do - if string.find(oldnode.name, "_"..i) and not - ( string.find(oldnode.name, "_redviolet") and i == "red" ) then - oldhue = i - break - end - end - - if newnode then -- this path is used when the calling mod want to supply a replacement node - if palette_type == "wallmounted" then - node.param2 = paletteidx + (minetest.get_node(pos).param2 % 8) - elseif palette_type == true then -- it's colorfacedir - if oldhue ~=0 then -- it's colored, not grey - if oldhue ~= nil then -- it's been painted before - if hue ~= 0 then -- the player's wielding a colored dye - newnode = string.gsub(newnode, "_"..oldhue, "_"..unifieddyes.HUES[hue]) - else -- it's a greyscale dye - newnode = string.gsub(newnode, "_"..oldhue, "_grey") - end - else -- it's never had a color at all - if hue ~= 0 then -- and if the wield is greyscale, don't change the node name - newnode = string.gsub(newnode, "_grey", "_"..unifieddyes.HUES[hue]) - end - end - else - if hue ~= 0 then -- greyscale dye on greyscale node = no hue change - newnode = string.gsub(newnode, "_grey", "_"..unifieddyes.HUES[hue]) - end - end - node.param2 = paletteidx + (minetest.get_node(pos).param2 % 32) - else -- it's the 89-color palette, or the extended palette - node.param2 = paletteidx - end - node.name = newnode - minetest.swap_node(pos, node) - if palette_type == "extended" then - meta:set_string("palette", "ext") - end - if not creative_mode then - return itemstack - end - else -- this path is used when you're just painting an existing node, rather than replacing one. - newnode = oldnode -- note that here, newnode/oldnode are a full node, not just the name. - if palette_type == "wallmounted" then - newnode.param2 = paletteidx + (minetest.get_node(pos).param2 % 8) - elseif palette_type == true then -- it's colorfacedir - if oldhue then - if hue ~= 0 then - newnode.name = string.gsub(newnode.name, "_"..oldhue, "_"..unifieddyes.HUES[hue]) - else - newnode.name = string.gsub(newnode.name, "_"..oldhue, "_grey") - end - elseif string.find(minetest.get_node(pos).name, "_grey") and hue ~= 0 then - newnode.name = string.gsub(newnode.name, "_grey", "_"..unifieddyes.HUES[hue]) - end - newnode.param2 = paletteidx + (minetest.get_node(pos).param2 % 32) - else -- it's the 89-color palette, or the extended palette - newnode.param2 = paletteidx - end - minetest.swap_node(pos, newnode) - if palette_type == "extended" then - meta:set_string("palette", "ext") - end - if not creative_mode then - return itemstack - end - end - else - local a,b = string.find(stackname, ":") - if a then - minetest.chat_send_player(playername, "That node can't be colored "..string.sub(stackname, a + 1).."." ) - end - end -end - --- re-define default dyes slightly, to add on_use - -for _, color in ipairs(default_dyes) do - minetest.override_item("dye:"..color, { - on_use = unifieddyes.on_use - }) -end - -- build a table to convert from classic/89-color palette to extended palette -- the first five entries are for the old greyscale - white, light, grey, dark, black @@ -825,7 +651,6 @@ for _, h in ipairs(unifieddyes.HUES_EXTENDED) do if minetest.registered_items["dye:"..val..hue] then minetest.override_item("dye:"..val..hue, { inventory_image = "unifieddyes_dye.png^[colorize:#"..color..":200", - on_use = unifieddyes.on_use }) else if (val..hue) ~= "medium_orange" @@ -834,7 +659,6 @@ for _, h in ipairs(unifieddyes.HUES_EXTENDED) do description = S(desc), inventory_image = "unifieddyes_dye.png^[colorize:#"..color..":200", groups = { dye=1, not_in_creative_inventory=1 }, - on_use = unifieddyes.on_use }) end end @@ -857,7 +681,6 @@ for _, h in ipairs(unifieddyes.HUES_EXTENDED) do description = S(desc.." (low saturation)"), inventory_image = "unifieddyes_dye.png^[colorize:#"..color..":200", groups = { dye=1, not_in_creative_inventory=1 }, - on_use = unifieddyes.on_use }) minetest.register_alias("unifieddyes:"..val..hue.."_s50", "dye:"..val..hue.."_s50") end @@ -878,7 +701,6 @@ for y = 1, 14 do -- colors 0 and 15 are black and white, default dyes description = S(desc), inventory_image = "unifieddyes_dye.png^[colorize:#"..rgb..":200", groups = { dye=1, not_in_creative_inventory=1 }, - on_use = unifieddyes.on_use }) minetest.register_alias("unifieddyes:"..name, "dye:"..name) end @@ -886,19 +708,16 @@ end minetest.override_item("dye:grey", { inventory_image = "unifieddyes_dye.png^[colorize:#888888:200", - on_use = unifieddyes.on_use }) minetest.override_item("dye:dark_grey", { inventory_image = "unifieddyes_dye.png^[colorize:#444444:200", - on_use = unifieddyes.on_use }) minetest.register_craftitem(":dye:light_grey", { description = S("Light grey Dye"), inventory_image = "unifieddyes_dye.png^[colorize:#cccccc:200", groups = { dye=1, not_in_creative_inventory=1 }, - on_use = unifieddyes.on_use }) unifieddyes.base_color_crafts = { -- cgit v1.2.3