From 92ef7c3b9a8b9abd5adfcb931d0bc43bbdf9c3b5 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 14 Dec 2019 23:42:17 +0100 Subject: [PATCH] Simplify rotation of pillar-like nodes --- mods/ITEMS/mcl_core/nodes_misc.lua | 7 +++++++ mods/ITEMS/mcl_core/nodes_trees.lua | 8 ++++++++ mods/ITEMS/mcl_end/building.lua | 7 +++++++ mods/ITEMS/mcl_farming/pumpkin.lua | 8 ++++++++ mods/ITEMS/mcl_farming/wheat.lua | 7 +++++++ mods/ITEMS/mcl_nether/depends.txt | 1 + mods/ITEMS/mcl_nether/init.lua | 6 ++++++ mods/ITEMS/screwdriver/init.lua | 24 ++++++++++++++++++++++++ 8 files changed, 68 insertions(+) diff --git a/mods/ITEMS/mcl_core/nodes_misc.lua b/mods/ITEMS/mcl_core/nodes_misc.lua index 8d204fa955..800d7442a4 100644 --- a/mods/ITEMS/mcl_core/nodes_misc.lua +++ b/mods/ITEMS/mcl_core/nodes_misc.lua @@ -1,6 +1,12 @@ -- Other nodes local S = minetest.get_translator("mcl_core") +local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil +local on_rotate +if mod_screwdriver then + on_rotate = screwdriver.rotate_3way +end + minetest.register_node("mcl_core:bone_block", { description = S("Bone Block"), _doc_items_longdesc = S("Bone blocks are decorative blocks and a compact storage of bone meal."), @@ -10,6 +16,7 @@ minetest.register_node("mcl_core:bone_block", { on_place = mcl_util.rotate_axis, groups = {pickaxey=1, building_block=1, material_stone=1}, sounds = mcl_sounds.node_sound_stone_defaults(), + on_rotate = on_rotate, _mcl_blast_resistance = 10, _mcl_hardness = 2, }) diff --git a/mods/ITEMS/mcl_core/nodes_trees.lua b/mods/ITEMS/mcl_core/nodes_trees.lua index 433ae03ad4..92d2a7cd38 100644 --- a/mods/ITEMS/mcl_core/nodes_trees.lua +++ b/mods/ITEMS/mcl_core/nodes_trees.lua @@ -1,6 +1,12 @@ -- Tree nodes: Wood, Wooden Planks, Sapling, Leaves local S = minetest.get_translator("mcl_core") +local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil +local on_rotate +if mod_screwdriver then + on_rotate = screwdriver.rotate_3way +end + -- Register tree trunk (wood) and bark local register_tree_trunk = function(subname, description_trunk, description_bark, longdesc, tile_inner, tile_bark) minetest.register_node("mcl_core:"..subname, { @@ -13,6 +19,7 @@ local register_tree_trunk = function(subname, description_trunk, description_bar stack_max = 64, groups = {handy=1,axey=1, tree=1, flammable=2, building_block=1, material_wood=1}, sounds = mcl_sounds.node_sound_wood_defaults(), + on_rotate = on_rotate, _mcl_blast_resistance = 10, _mcl_hardness = 2, }) @@ -27,6 +34,7 @@ local register_tree_trunk = function(subname, description_trunk, description_bar groups = {handy=1,axey=1, bark=1, flammable=2, building_block=1, material_wood=1}, sounds = mcl_sounds.node_sound_wood_defaults(), is_ground_content = false, + on_rotate = on_rotate, _mcl_blast_resistance = 10, _mcl_hardness = 2, }) diff --git a/mods/ITEMS/mcl_end/building.lua b/mods/ITEMS/mcl_end/building.lua index 31b4bd553d..696a227625 100644 --- a/mods/ITEMS/mcl_end/building.lua +++ b/mods/ITEMS/mcl_end/building.lua @@ -1,6 +1,12 @@ -- Building blocks and decorative nodes local S = minetest.get_translator("mcl_end") +local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil +local on_rotate +if mod_screwdriver then + on_rotate = screwdriver.rotate_3way +end + minetest.register_node("mcl_end:end_stone", { description = S("End Stone"), _doc_items_longdesc = doc.sub.items.temp.build, @@ -47,6 +53,7 @@ minetest.register_node("mcl_end:purpur_pillar", { tiles = {"mcl_end_purpur_pillar_top.png", "mcl_end_purpur_pillar_top.png", "mcl_end_purpur_pillar.png"}, groups = {pickaxey=1, building_block=1, material_stone=1, purpur_block=1}, sounds = mcl_sounds.node_sound_stone_defaults(), + on_rotate = on_rotate, _mcl_blast_resistance = 30, _mcl_hardness = 1.5, }) diff --git a/mods/ITEMS/mcl_farming/pumpkin.lua b/mods/ITEMS/mcl_farming/pumpkin.lua index 8c87447ca8..dae762ad01 100644 --- a/mods/ITEMS/mcl_farming/pumpkin.lua +++ b/mods/ITEMS/mcl_farming/pumpkin.lua @@ -1,5 +1,11 @@ local S = minetest.get_translator("mcl_farming") +local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil +local on_rotate +if mod_screwdriver then + on_rotate = screwdriver.rotate_simple +end + -- Seeds minetest.register_craftitem("mcl_farming:pumpkin_seeds", { description = S("Pumpkin Seeds"), @@ -93,6 +99,7 @@ local pumpkin_base_def = { tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png"}, groups = {handy=1,axey=1, plant=1,building_block=1, dig_by_piston=1, enderman_takable=1}, sounds = mcl_sounds.node_sound_wood_defaults(), + on_rotate = on_rotate, _mcl_blast_resistance = 5, _mcl_hardness = 1, } @@ -134,6 +141,7 @@ minetest.register_node("mcl_farming:pumpkin_face_light", { mobs_mc.tools.check_iron_golem_summon(pos) mobs_mc.tools.check_snow_golem_summon(pos) end, + on_rotate = on_rotate, _mcl_blast_resistance = 5, _mcl_hardness = 1, }) diff --git a/mods/ITEMS/mcl_farming/wheat.lua b/mods/ITEMS/mcl_farming/wheat.lua index 1a65d1d16f..4c8800da31 100644 --- a/mods/ITEMS/mcl_farming/wheat.lua +++ b/mods/ITEMS/mcl_farming/wheat.lua @@ -130,6 +130,12 @@ minetest.register_craftitem("mcl_farming:bread", { on_secondary_use = minetest.item_eat(5), }) +local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil +local on_rotate +if mod_screwdriver then + on_rotate = screwdriver.rotate_3way +end + minetest.register_node("mcl_farming:hay_block", { description = S("Hay Bale"), _doc_items_longdesc = S("Hay bales are decorative blocks made from wheat."), @@ -141,6 +147,7 @@ minetest.register_node("mcl_farming:hay_block", { on_place = mcl_util.rotate_axis, groups = {handy=1, flammable=2, building_block=1, fall_damage_add_percent=-80}, sounds = mcl_sounds.node_sound_leaves_defaults(), + on_rotate = on_rotate, _mcl_blast_resistance = 2.5, _mcl_hardness = 0.5, }) diff --git a/mods/ITEMS/mcl_nether/depends.txt b/mods/ITEMS/mcl_nether/depends.txt index 273e76e1da..96f253aa0e 100644 --- a/mods/ITEMS/mcl_nether/depends.txt +++ b/mods/ITEMS/mcl_nether/depends.txt @@ -5,3 +5,4 @@ walkover mcl_death_messages? doc_items doc? +screwdriver? diff --git a/mods/ITEMS/mcl_nether/init.lua b/mods/ITEMS/mcl_nether/init.lua index 62c5dc4168..f183fcc02f 100644 --- a/mods/ITEMS/mcl_nether/init.lua +++ b/mods/ITEMS/mcl_nether/init.lua @@ -1,6 +1,11 @@ local S = minetest.get_translator("mcl_nether") local mod_death_messages = minetest.get_modpath("mcl_death_messages") +local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil +local on_rotate +if mod_screwdriver then + on_rotate = screwdriver.rotate_3way +end minetest.register_node("mcl_nether:glowstone", { description = S("Glowstone"), @@ -201,6 +206,7 @@ minetest.register_node("mcl_nether:quartz_pillar", { tiles = {"mcl_nether_quartz_pillar_top.png", "mcl_nether_quartz_pillar_top.png", "mcl_nether_quartz_pillar_side.png"}, groups = {pickaxey=1, quartz_block=1,building_block=1, material_stone=1}, sounds = mcl_sounds.node_sound_stone_defaults(), + on_rotate = on_rotate, _mcl_blast_resistance = 4, _mcl_hardness = 0.8, }) diff --git a/mods/ITEMS/screwdriver/init.lua b/mods/ITEMS/screwdriver/init.lua index 28d2c12a1c..7fad2bdcbe 100644 --- a/mods/ITEMS/screwdriver/init.lua +++ b/mods/ITEMS/screwdriver/init.lua @@ -12,6 +12,30 @@ screwdriver.rotate_simple = function(pos, node, user, mode, new_param2) return false end end +screwdriver.rotate_3way = function(pos, node, user, mode, new_param2) + if mode == screwdriver.ROTATE_AXIS then + if node.param2 == 0 then + node.param2 = 6 + elseif node.param2 == 6 then + node.param2 = 12 + else + node.param2 = 0 + end + minetest.swap_node(pos, node) + return true + elseif mode == screwdriver.ROTATE_FACE then + if node.param2 == 6 then + node.param2 = 12 + minetest.swap_node(pos, node) + return true + else + node.param2 = 6 + minetest.swap_node(pos, node) + return true + end + end + return false +end -- For attached wallmounted nodes: returns true if rotation is valid -- simplified version of minetest:builtin/game/falling.lua#L148.