From 8c6306d0fa4ae5151dcba35256ffa072871621d3 Mon Sep 17 00:00:00 2001 From: rdococ Date: Tue, 1 Aug 2017 16:24:02 +0100 Subject: [PATCH] 1. Removed some useless debug messages. 2. Added meseconveyors, which require power. --- conveyor.lua | 78 +++++++++++++++++- depends.txt | 1 + grate.lua | 10 +-- ...eyor_top.png => rmod_conveyor_top_off.png} | Bin textures/rmod_conveyor_top_off_reversed.png | Bin 0 -> 207 bytes textures/rmod_meseconveyor_overlay_off.png | Bin 0 -> 186 bytes textures/rmod_meseconveyor_overlay_on.png | Bin 0 -> 186 bytes .../rmod_meseconveyor_side_overlay_off.png | Bin 0 -> 210 bytes .../rmod_meseconveyor_side_overlay_on.png | Bin 0 -> 205 bytes 9 files changed, 81 insertions(+), 8 deletions(-) create mode 100644 depends.txt rename textures/{rmod_conveyor_top.png => rmod_conveyor_top_off.png} (100%) create mode 100644 textures/rmod_conveyor_top_off_reversed.png create mode 100644 textures/rmod_meseconveyor_overlay_off.png create mode 100644 textures/rmod_meseconveyor_overlay_on.png create mode 100644 textures/rmod_meseconveyor_side_overlay_off.png create mode 100644 textures/rmod_meseconveyor_side_overlay_on.png diff --git a/conveyor.lua b/conveyor.lua index f7fec89..de4b3d1 100644 --- a/conveyor.lua +++ b/conveyor.lua @@ -39,7 +39,7 @@ minetest.register_node("rmod:conveyor", { "rmod_conveyor_side.png", "rmod_conveyor_side.png", rmod_conveyor_top_animated_2_reversed, rmod_conveyor_top_animated_2 -- You have to reverse one of the faces to go UP, not DOWN. }, - groups = {oddly_breakable_by_hand = 1}, + groups = {oddly_breakable_by_hand = 1, conveyor = 1}, use_texture_alpha = true, paramtype2 = "facedir", }) @@ -73,7 +73,7 @@ minetest.register_globalstep(function (dtime) local name = getname(surface) local def = getdef(surface) - if name == "rmod:conveyor" then -- I might replace this with a group, e.g. def.groups.conveyor, so you can set the speed. + if def.groups.conveyor == 1 then -- I might replace this with a group, e.g. def.groups.conveyor, so you can set the speed. local facing = node.param2 -- Param2 is the facedir as defined above - conveyors face the opposite direction they move you. local direction = minetest.facedir_to_dir(facing) local movement = vector.multiply(direction, {x=1, y=1, z=1}) -- We reversed the facing system recently. @@ -93,7 +93,7 @@ minetest.register_globalstep(function (dtime) local udef = getdef(roundedupos) if newdef.walkable then - if newname == "rmod:conveyor" and newnode.param2 == facing then + if newdef.groups.conveyor == 1 and newnode.param2 == facing then -- Okay, so the entity will be moving into a node. -- But it just so happens that this node is also a conveyor! -- Plus, it's moving in the same direction! @@ -119,3 +119,75 @@ minetest.register_globalstep(function (dtime) end) + +if not minetest.get_modpath("mesecons") then return end -- There's no point of using meseconveyors when mesecons doesn't exist. + +-- I present... Meseconveyors! + +local meseconveyor_rules = { + {x=0, y=0, z=-1}, + {x=1, y=0, z=0}, + {x=-1, y=0, z=0}, + {x=0, y=0, z=1}, + {x=1, y=1, z=0}, + {x=1, y=-1, z=0}, + {x=-1, y=1, z=0}, + {x=-1, y=-1, z=0}, + {x=0, y=1, z=1}, + {x=0, y=-1, z=1}, + {x=0, y=1, z=-1}, + {x=0, y=-1, z=-1}, + {x=0, y=-1, z=0}, +} + +local overlay_off = "^rmod_meseconveyor_overlay_off.png" +local overlay_on = "^rmod_meseconveyor_overlay_on.png" + +local side_overlay_off = "^rmod_meseconveyor_side_overlay_off.png" +local side_overlay_on = "^rmod_meseconveyor_side_overlay_on.png" + +local rmod_meseconveyor_top_off = "rmod_conveyor_top_off.png" .. overlay_off -- Un-animated version of the conveyor texture. +local rmod_meseconveyor_top_off_reversed = "rmod_conveyor_top_off_reversed.png" .. overlay_off -- I probably should just [rotate it. + +local rmod_meseconveyor_top_animated_2 = rmod_conveyor_top_animated_2 +rmod_meseconveyor_top_animated_2.name = rmod_conveyor_top_animated_2.name .. overlay_on + +local rmod_meseconveyor_top_animated_2_reversed = rmod_conveyor_top_animated_2_reversed +rmod_meseconveyor_top_animated_2_reversed.name = rmod_conveyor_top_animated_2_reversed.name .. overlay_on + +minetest.register_node("rmod:meseconveyor_off", { + description = "Meseconveyor", + tiles = { + rmod_meseconveyor_top_off, rmod_meseconveyor_top_off, + "rmod_conveyor_side.png" .. side_overlay_off, "rmod_conveyor_side.png" .. side_overlay_off, + rmod_meseconveyor_top_off_reversed, rmod_meseconveyor_top_off + }, + groups = {oddly_breakable_by_hand = 1, mesecon = 2}, + use_texture_alpha = true, + paramtype2 = "facedir", + mesecons = {effector = { + rules = meseconveyor_rules, + action_on = function (pos, node) + minetest.swap_node(pos, {name = "rmod:meseconveyor_on", param2 = node.param2}) + end, + }} +}) + +minetest.register_node("rmod:meseconveyor_on", { + description = "Active Meseconveyor (you hacker you!)", + tiles = { + rmod_meseconveyor_top_animated_2, rmod_meseconveyor_top_animated_2, + "rmod_conveyor_side.png" .. side_overlay_on, "rmod_conveyor_side.png" .. side_overlay_on, + rmod_meseconveyor_top_animated_2_reversed, rmod_meseconveyor_top_animated_2 + }, + groups = {oddly_breakable_by_hand = 1, conveyor = 1, not_in_creative_inventory = 1, mesecon = 2}, + drop = "rmod:meseconveyor_off", + use_texture_alpha = true, + paramtype2 = "facedir", + mesecons = {effector = { + rules = meseconveyor_rules, + action_off = function (pos, node) + minetest.swap_node(pos, {name = "rmod:meseconveyor_off", param2 = node.param2}) + end, + }} +}) diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..7696547 --- /dev/null +++ b/depends.txt @@ -0,0 +1 @@ +mesecons? diff --git a/grate.lua b/grate.lua index 90cc70d..7bcb706 100644 --- a/grate.lua +++ b/grate.lua @@ -16,7 +16,7 @@ local function grate_step(pos, offset) if not neigh_def then return end -- Unknown nodes can't flow. if not neigh_def.liquidtype then return end -- Non-liquids can't flow at all. - print("Neighbor is liquid.") + --print("Neighbor is liquid.") -- Check its level. local level = neigh_node.param2 % 16 @@ -24,7 +24,7 @@ local function grate_step(pos, offset) if neigh_def.liquidtype == "source" then level = 16 end if level < 2 then return end -- Level < 2 water stops flowing within two blocks. - print("Neighbor is high enough level.") + --print("Neighbor is high enough level.") -- Check the opposing neighbor. local opposite = vector.subtract(pos, offset) @@ -45,17 +45,17 @@ local function grate_step(pos, offset) if opposite_level > level - 2 or opposite_def.liquidtype == "source" then return end end -- Liquids can't flow into higher level liquids. - print("Opposite is floodable.") + --print("Opposite is floodable.") local neigh_flowing = neigh_def.liquid_alternative_flowing if not neigh_flowing then return end -- Improperly configured liquids can't flow. - print("Liquid is configured properly.") + --print("Liquid is configured properly.") minetest.set_node(opposite, { name = neigh_flowing, param1 = neigh_node.param1, - param2 = neigh_node.param2 == 0 and 6 or neigh_node.param2 - 2 + param2 = --[[neigh_node.param2 == 0]]neigh_def.liquidtype == "source" and 6 or neigh_node.param2 - 2 }) end diff --git a/textures/rmod_conveyor_top.png b/textures/rmod_conveyor_top_off.png similarity index 100% rename from textures/rmod_conveyor_top.png rename to textures/rmod_conveyor_top_off.png diff --git a/textures/rmod_conveyor_top_off_reversed.png b/textures/rmod_conveyor_top_off_reversed.png new file mode 100644 index 0000000000000000000000000000000000000000..52ee9e5cdb2e50dc0bb20e08659959bc8d37b361 GIT binary patch literal 207 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPt2P3bA%p^D4BS0a^64!_l=ltB<)VvY~=c3falGGH1 z^30M91$R&1fbd2>aiAh|PZ!4!i_^&_W@i7+pE`BQf$zuP-{#ER%s^mnZXU^2^Wy_! s(t+#i<0Vh9F4mJMJ-C8<#SFVdQ&MBb@06SaiAh4PZ!4!i_^(7E+6_ZztP8FdFw-aVdmC^D-D6nZoCpYK$m>> WVTol~u*VUon!(f6&t;ucLK6T<=`tk% literal 0 HcmV?d00001 diff --git a/textures/rmod_meseconveyor_overlay_on.png b/textures/rmod_meseconveyor_overlay_on.png new file mode 100644 index 0000000000000000000000000000000000000000..fee85d358b52fe9906c7fb26fe499c5bcc1e56ef GIT binary patch literal 186 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPt2P3bM`2T92V?ZIv64!_l=ltB<)VvY~=c3falGGH1 z^30M91$R&1fbd2>aiAh4PZ!4!i_^(J>YE?hGtYeRpSSJ5506MwAhR2)25CZLdHiEBiObAE1aYF-J0b5UwyNotBh zd1gt5g1e`0KzJjcI8c$5r;B5V#p&b(iHrjsXIAQ){qgTvcI@8g9*L%}N8A2)8Zs=m vO3HN)Kkbq!(IaK>f=9tj@uHe0KhVxi(gTe~DWM4fHC;XU literal 0 HcmV?d00001 diff --git a/textures/rmod_meseconveyor_side_overlay_on.png b/textures/rmod_meseconveyor_side_overlay_on.png new file mode 100644 index 0000000000000000000000000000000000000000..d4dce0eb278db228f7f6457bbceaf4df126bfe6d GIT binary patch literal 205 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPt2P2=g>CgEdMnECS64!_l=ltB<)VvY~=c3falGGH1 z^30M91$R&1fbd2>aiAhoPZ!4!i_^&o5*Y_N&it%zerO*!%Ov3IK~v#m2EWoHxBAvi r>%3$jVVZD3(jmubk#CTk0Ruy%u*_k>Ju)Rg0~kDA{an^LB{Ts5446BW literal 0 HcmV?d00001