From 971d4f3867dc5e5b637e352234775a4cdb69f2b8 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 10 Feb 2017 15:38:53 +0100 Subject: [PATCH] 3D redstone torches --- mods/mcl_torches/init.lua | 32 ++++--- .../textures/jeija_torches_off.png | Bin 165 -> 225 bytes .../textures/jeija_torches_off_ceiling.png | Bin 166 -> 0 bytes .../textures/jeija_torches_off_side.png | Bin 243 -> 0 bytes .../textures/jeija_torches_on.png | Bin 174 -> 407 bytes .../textures/jeija_torches_on_ceiling.png | Bin 174 -> 0 bytes .../textures/jeija_torches_on_inv.png | Bin 0 -> 266 bytes .../textures/jeija_torches_on_side.png | Bin 284 -> 0 bytes mods/redstone/mesecons_torch/depends.txt | 1 + mods/redstone/mesecons_torch/init.lua | 79 ++++++++---------- 10 files changed, 57 insertions(+), 55 deletions(-) delete mode 100644 mods/redstone/mesecons_textures/textures/jeija_torches_off_ceiling.png delete mode 100644 mods/redstone/mesecons_textures/textures/jeija_torches_off_side.png delete mode 100644 mods/redstone/mesecons_textures/textures/jeija_torches_on_ceiling.png create mode 100644 mods/redstone/mesecons_textures/textures/jeija_torches_on_inv.png delete mode 100644 mods/redstone/mesecons_textures/textures/jeija_torches_on_side.png diff --git a/mods/mcl_torches/init.lua b/mods/mcl_torches/init.lua index 2fedbb79..c7595c3a 100644 --- a/mods/mcl_torches/init.lua +++ b/mods/mcl_torches/init.lua @@ -5,9 +5,9 @@ mcl_torches = {} -mcl_torches.register_torch = function(substring, description, icon, mesh_floor, mesh_wall, tiles, light, groups, sounds) - local itemstring = "mcl_torches:"..substring - local itemstring_wall = "mcl_torches:"..substring.."_wall" +mcl_torches.register_torch = function(substring, description, icon, mesh_floor, mesh_wall, tiles, light, groups, sounds, moredef) + local itemstring = minetest.get_current_modname()..":"..substring + local itemstring_wall = minetest.get_current_modname()..":"..substring.."_wall" if light == nil then light = 14 end if mesh_floor == nil then mesh_floor = "mcl_torches_torch_floor.obj" end @@ -18,7 +18,7 @@ mcl_torches.register_torch = function(substring, description, icon, mesh_floor, groups.torch = 1 groups.dig_by_water = 1 - minetest.register_node(itemstring, { + local floordef = { description = description, drawtype = "mesh", mesh = mesh_floor, @@ -63,25 +63,31 @@ mcl_torches.register_torch = function(substring, description, icon, mesh_floor, -- Prevent placement of ceiling torches return itemstack elseif wdir == 1 then - retval = fakestack:set_name("mcl_torches:torch") + retval = fakestack:set_name(itemstring) else - retval = fakestack:set_name("mcl_torches:torch_wall") + retval = fakestack:set_name(itemstring_wall) end if not retval then return itemstack end itemstack = minetest.item_place(fakestack, placer, pointed_thing, wdir) - itemstack:set_name("mcl_torches:torch") + itemstack:set_name(itemstring) return itemstack end - }) + } + if moredef ~= nil then + for k,v in pairs(moredef) do + floordef[k] = v + end + end + minetest.register_node(itemstring, floordef) local groups_wall = table.copy(groups) groups_wall.torch = 2 - minetest.register_node(itemstring_wall, { + local walldef = { drawtype = "mesh", mesh = mesh_wall, tiles = tiles, @@ -99,7 +105,13 @@ mcl_torches.register_torch = function(substring, description, icon, mesh_floor, wall_side = {-0.5, -0.5, -0.1, -0.2, 0.1, 0.1}, }, sounds = sounds, - }) + } + if moredef ~= nil then + for k,v in pairs(moredef) do + walldef[k] = v + end + end + minetest.register_node(itemstring_wall, walldef) end mcl_torches.register_torch("torch", "Torch", "default_torch_on_floor.png", diff --git a/mods/redstone/mesecons_textures/textures/jeija_torches_off.png b/mods/redstone/mesecons_textures/textures/jeija_torches_off.png index 55e99750fef97101715da030bd7eb6fba3d2de0f..df3c1220dc30d377d625ec6ee75c57445feb8c9e 100644 GIT binary patch literal 225 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANL}D?D8sLn00*|M>sk{;)$* zTOfOnRl*g<#e5Q_2PTv{NCaqeR6Be;QOs~A$yYI%evUEI zQH}X=L#OMyg466r7$(^b literal 165 zcmeAS@N?(olHy`uVBq!ia0y~yU=U@o4p-UY VD{Ye_7#J8BJYD@<);T3K0RSX1Iluq_ diff --git a/mods/redstone/mesecons_textures/textures/jeija_torches_off_ceiling.png b/mods/redstone/mesecons_textures/textures/jeija_torches_off_ceiling.png deleted file mode 100644 index 004589d3ac73ca7fa8aab5ae9e7e5d8251d25223..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 166 zcmeAS@N?(olHy`uVBq!ia0y~yU=UhcD zNB%Eom;85pd0XcMMI9X-p0+F@9udhyM~)mR_;-!_6wlB9|LvO_S6MJ0z4!3Jg9Uf2 z@9(Q!d}c!Y{yM`yzrXhzIkWuOArZIl|4|3Q3n>Xd-XA>R5NS0rJt5&ivIMKMI0M7Z Y-4bOhHS)9=7#J8lUHx3vIVCg!0AwseSO5S3 diff --git a/mods/redstone/mesecons_textures/textures/jeija_torches_off_side.png b/mods/redstone/mesecons_textures/textures/jeija_torches_off_side.png deleted file mode 100644 index c5ab4a815d8bdb24f6394ab916f63f0b94821af1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 243 zcmeAS@N?(olHy`uVBq!ia0y~yU=U%AJ_7TJ=&U7S9`!ZKYOZa#oPHoul~*8ySKzE;n3vv zEeRH`Z97(W{H$b{x-0ASAAf$snZ6UtYjQ&7sEO~c@%&=^>wVU`9X*Q-3bzNCoaZ*L z6nwGZpZp9i^FWaW+kOREeZ05J^-Hg8jReCZlmDWB53ey}U|?YIboFyt=akR{02a1n AR{#J2 diff --git a/mods/redstone/mesecons_textures/textures/jeija_torches_on.png b/mods/redstone/mesecons_textures/textures/jeija_torches_on.png index 28e98a33add42e2d92cfc96be5e2de133bc0b73c..71c538c75c0f88e471b200b150c91fb9a369c058 100644 GIT binary patch literal 407 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANL}jKx9jP7LeL$-HD>U|>t~ zc6VXuX4uK_({T3I+YAg0oCO|{#S9GG!XV7ZFl&wk0|NtliKnkC`$Hx!J~899=^7pk z42-bMCpMQ%xUeq( z=c>y~*8Try%e4BjynP+Sfb;Y1nP+pb>+r_x`8>-pq=7wXp0QEi0h5FUT5S59|Ns6r zFHm&Id_L{Xtq+IZhEFhAU~ypWqtoSaK}+NrHkm{<-MA96m4ShQ!PC{xWt~$(695($ Bo2~!= literal 174 zcmeAS@N?(olHy`uVBq!ia0y~yU=Uvv=r9#q+7%6yZb_+wko#3@2zlZuypf2X)qBx|kQrwB7A4!I(mH-D_Z eKmT=gu6T8d$tQ)M_9_ev3=E#GelF{r5}E*^l|NPh diff --git a/mods/redstone/mesecons_textures/textures/jeija_torches_on_ceiling.png b/mods/redstone/mesecons_textures/textures/jeija_torches_on_ceiling.png deleted file mode 100644 index 45fa2d904d45dbb4953bdcfb23904999aef963d5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 174 zcmeAS@N?(olHy`uVBq!ia0y~yU=U4ZLn00*|M>sk{;)$* zTOfOnRl*g<#e5Q*_FRm;ieW zCvhy;&HV3b^-Wvu$LHYJ@_ONncRLqYoqTA|@%vWx-|fahG8XJhSZDI|Fsq5} zJftfx!0w}0D1Sqs!IB|m=jNTa4p=ax7;3Pv9bqhf&2&KVLCP{KgFu4^d^4h+S#H?L z@T`IHG^;{);>`>9A~IR55~6mB+x*Do6=gfesBoJ72;+%BhC|HH7`$yGyJQ#`7XO}a Vw&a^cG6MqxgQu&X%Q~loCIHtqXY&96 literal 0 HcmV?d00001 diff --git a/mods/redstone/mesecons_textures/textures/jeija_torches_on_side.png b/mods/redstone/mesecons_textures/textures/jeija_torches_on_side.png deleted file mode 100644 index 3894ecd30bbc54777aa9f4307df95ee04af571e8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 284 zcmeAS@N?(olHy`uVBq!ia0y~yU=UznU=ZYBV_;xhyg~*f@YvJEF{I*F@{j-j?U^}@ z1rkKuqpu}<{q^R!-KW&BkSX}V>1Y2XwBGQh{-2!0CiL&$|D`;BtkY*moGs@nJb!6( z$iM!}EE0VsS5F*R-LQZ&LiEq?H%fi?Ti){gudnzmb8zJY3Gvs8k(#?eG1rw+*NaUslU-GEQUthXlrpnjghtZGWEoe^)p3UpkBA(#f)H7vDvxW;V9{ qpX)2C!R-)k{4?X$aVA9`hQ*Uv?s)wR|H{C?z~JfX=d#Wzp$PyU>VUWa diff --git a/mods/redstone/mesecons_torch/depends.txt b/mods/redstone/mesecons_torch/depends.txt index acaa9241..72327aba 100644 --- a/mods/redstone/mesecons_torch/depends.txt +++ b/mods/redstone/mesecons_torch/depends.txt @@ -1 +1,2 @@ mesecons +mcl_torches diff --git a/mods/redstone/mesecons_torch/init.lua b/mods/redstone/mesecons_torch/init.lua index 8c901d76..efb22aed 100644 --- a/mods/redstone/mesecons_torch/init.lua +++ b/mods/redstone/mesecons_torch/init.lua @@ -41,51 +41,34 @@ minetest.register_craft({ {"mcl_core:stick"},} }) -local torch_selectionbox = -{ - type = "wallmounted", - wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1}, - wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1}, - wall_side = {-0.5, -0.1, -0.1, -0.5+0.6, 0.1, 0.1}, -} +mcl_torches.register_torch("mesecon_torch_off", "Mesecon Torch (off)", "jeija_torches_off.png", + "mcl_torches_torch_floor.obj", "mcl_torches_torch_wall.obj", + {"jeija_torches_off.png"}, + 0, + {dig_immediate=3, dig_by_water=1, not_in_creative_inventory=1}, + mcl_core.node_sound_wood_defaults(), + { + mesecons = {receptor = { + state = mesecon.state.off, + rules = torch_get_output_rules + }}, + drop = "mesecons_torch:mesecon_torch_on", + } +) -minetest.register_node("mesecons_torch:mesecon_torch_off", { - drawtype = "torchlike", - tiles = {"jeija_torches_off.png", "jeija_torches_off_ceiling.png", "jeija_torches_off_side.png"}, - inventory_image = "jeija_torches_off.png", - paramtype = "light", - walkable = false, - paramtype2 = "wallmounted", - is_ground_content = false, - selection_box = torch_selectionbox, - groups = {dig_immediate = 3, dig_by_water=1, not_in_creative_inventory = 1}, - drop = "mesecons_torch:mesecon_torch_on", - mesecons = {receptor = { - state = mesecon.state.off, - rules = torch_get_output_rules - }} -}) - -minetest.register_node("mesecons_torch:mesecon_torch_on", { - drawtype = "torchlike", - tiles = {"jeija_torches_on.png", "jeija_torches_on_ceiling.png", "jeija_torches_on_side.png"}, - inventory_image = "jeija_torches_on.png", - wield_image = "jeija_torches_on.png", - stack_max = 64, - paramtype = "light", - sunlight_propagates = true, - walkable = false, - paramtype2 = "wallmounted", - is_ground_content = false, - selection_box = torch_selectionbox, - groups = {dig_immediate=3, dig_by_water=1}, - light_source = 7, - description="Redstone Torch", - mesecons = {receptor = { - state = mesecon.state.on, - rules = torch_get_output_rules - }}, -}) +mcl_torches.register_torch("mesecon_torch_on", "Mesecon Torch", "jeija_torches_on_inv.png", + "mcl_torches_torch_floor.obj", "mcl_torches_torch_wall.obj", + {"jeija_torches_on.png"}, + 7, + {dig_immediate=3, dig_by_water=1}, + mcl_core.node_sound_wood_defaults(), + { + mesecons = {receptor = { + state = mesecon.state.on, + rules = torch_get_output_rules + }} + } +) minetest.register_node("mesecons_torch:redstoneblock", { description = "Block of Redstone", @@ -117,7 +100,7 @@ minetest.register_craft({ }) minetest.register_abm({ - nodenames = {"mesecons_torch:mesecon_torch_off","mesecons_torch:mesecon_torch_on"}, + nodenames = {"mesecons_torch:mesecon_torch_off","mesecons_torch:mesecon_torch_off_wall","mesecons_torch:mesecon_torch_on","mesecons_torch:mesecon_torch_on_wall"}, interval = 1, chance = 1, action = function(pos, node) @@ -133,10 +116,16 @@ minetest.register_abm({ if node.name == "mesecons_torch:mesecon_torch_on" then mesecon:swap_node(pos, "mesecons_torch:mesecon_torch_off") mesecon:receptor_off(pos, torch_get_output_rules(node)) + elseif node.name == "mesecons_torch:mesecon_torch_on_wall" then + mesecon:swap_node(pos, "mesecons_torch:mesecon_torch_off_wall") + mesecon:receptor_off(pos, torch_get_output_rules(node)) end elseif node.name == "mesecons_torch:mesecon_torch_off" then mesecon:swap_node(pos, "mesecons_torch:mesecon_torch_on") mesecon:receptor_on(pos, torch_get_output_rules(node)) + elseif node.name == "mesecons_torch:mesecon_torch_off_wall" then + mesecon:swap_node(pos, "mesecons_torch:mesecon_torch_on_wall") + mesecon:receptor_on(pos, torch_get_output_rules(node)) end end })