From 3600a745be423d60cea19bd8ac887a5f069a15bf Mon Sep 17 00:00:00 2001 From: FaceDeer Date: Tue, 3 Jan 2017 19:43:32 -0700 Subject: [PATCH] Add intermittent and non-intermittent versions of the diggers. --- README.txt | 4 +- node_builders.lua | 4 +- node_controllers.lua | 10 +- node_diggers.lua | 159 +++++++++++++++++++----- node_misc.lua | 12 +- recipes.lua | 26 ++++ textures/digtron_intermittent_motor.png | Bin 0 -> 811 bytes 7 files changed, 170 insertions(+), 45 deletions(-) create mode 100644 textures/digtron_intermittent_motor.png diff --git a/README.txt b/README.txt index 0c67e69..fe02ac4 100644 --- a/README.txt +++ b/README.txt @@ -52,12 +52,12 @@ Digger Head Facing of a digger head is significant; it will excavate material from the node on the spinning grinder wheel face of the digger head. Generally speaking, you'll want these to face forward - though having them aimed to the sides can also be useful. -Digger heads can have a period and offset defined if you want them to punch regularly-spaced holes. Note that diggers aimed forward should generally always have a period of 1, otherwise the digging machine may be unable to move. +Digger heads come in both regular and "intermittent" versions, each of which is craftable from the other. The intermittent version can have a period and offset defined if you want them to punch regularly-spaced holes. Note that diggers aimed forward should generally always be the regular kind (or have a period of 1), otherwise the digging machine may be unable to move. Soft Material Digger Head ---------------- -This specialized digger head is designed to excavate only softer material such as sand or gravel. It has no period/offset settings; it will always attempt to dig sand when it's present in its target node. It leaves all other types of nodes alone. (in technical terms, this digger digs nodes belonging to the "crumbly", "choppy", "snappy", "oddly_diggable_by_hand" and "fleshy" groups) +This specialized digger head is designed to excavate only softer material such as sand or gravel. It has no period/offset settings; it will always attempt to dig sand when it's present in its target node. It leaves all other types of nodes alone. In technical terms, this digger digs nodes belonging to the "crumbly", "choppy", "snappy", "oddly_diggable_by_hand" and "fleshy" groups. It also comes in regular and "intermittent" versions. The intended purpose of this digger is to be aimed at the ceiling or walls of a tunnel being dug, making spaces to allow shoring nodes to be inserted into unstable roofs but leaving the wall alone if it's composed of a more stable material. diff --git a/node_builders.lua b/node_builders.lua index cabb8f7..41bc85a 100644 --- a/node_builders.lua +++ b/node_builders.lua @@ -6,7 +6,7 @@ minetest.register_node("digtron:builder", { groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 4}, drop = "digtron:builder", sounds = default.node_sound_metal_defaults(), - paramtype2= 'facedir', + paramtype2= "facedir", tiles = { "digtron_plate.png^[transformR90", "digtron_plate.png^[transformR270", @@ -39,7 +39,7 @@ minetest.register_node("digtron:builder", { }, on_construct = function(pos) - local meta = minetest.env:get_meta(pos) + local meta = minetest.get_meta(pos) meta:set_string("formspec", "size[8,5.2]" .. default.gui_bg .. diff --git a/node_controllers.lua b/node_controllers.lua index 0ac65ac..8c06607 100644 --- a/node_controllers.lua +++ b/node_controllers.lua @@ -246,9 +246,9 @@ local controller_nodebox ={ minetest.register_node("digtron:controller", { description = "Digtron Control Unit", groups = {cracky = 3, oddly_breakable_by_hand = 3, digtron = 1}, - drop = 'digtron:controller', + drop = "digtron:controller", sounds = default.node_sound_metal_defaults(), - paramtype2= 'facedir', + paramtype2= "facedir", -- Aims in the +Z direction by default tiles = { "digtron_plate.png^[transformR90", @@ -267,7 +267,7 @@ minetest.register_node("digtron:controller", { }, on_construct = function(pos) - local meta = minetest.env:get_meta(pos) + local meta = minetest.get_meta(pos) meta:set_float("fuel_burning", 0.0) meta:set_string("infotext", "Heat remaining in controller furnace: 0") end, @@ -286,9 +286,9 @@ minetest.register_node("digtron:controller", { minetest.register_node("digtron:pusher", { description = "Digtron Pusher Unit", groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 1}, - drop = 'digtron:pusher', + drop = "digtron:pusher", sounds = default.node_sound_metal_defaults(), - paramtype2= 'facedir', + paramtype2= "facedir", -- Aims in the +Z direction by default tiles = { "digtron_plate.png^[transformR90^[colorize:#00880030", diff --git a/node_diggers.lua b/node_diggers.lua index f5162d8..b82e765 100644 --- a/node_diggers.lua +++ b/node_diggers.lua @@ -9,14 +9,32 @@ local digger_nodebox = { {-0.25, -0.25, -0.5, 0.25, 0.25, 0}, -- Drive } +local intermittent_on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", + "size[3.5,1]" .. + default.gui_bg .. + default.gui_bg_img .. + default.gui_slots .. + "field[0.5,0.8;1,0.1;period;Periodicity;${period}]" .. + "tooltip[period;Digger will dig once every n steps. These steps are globally aligned, all diggers with the same period and offset will dig on the same location.]" .. + "field[1.5,0.8;1,0.1;offset;Offset;${offset}]" .. + "tooltip[offset;Offsets the start of periodicity counting by this amount. For example, a digger with period 2 and offset 0 digs every even-numbered node and one with period 2 and offset 1 digs every odd-numbered node.]" .. + "button_exit[2.2,0.5;1,0.1;set;Save]" .. + "tooltip[set;Saves settings]" + ) + meta:set_int("period", 1) + meta:set_int("offset", 0) +end + -- Digs out nodes that are "in front" of the digger head. minetest.register_node("digtron:digger", { description = "Digger Head", groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 3}, - drop = 'digtron:digger', + drop = "digtron:digger", sounds = default.node_sound_metal_defaults(), paramtype = "light", - paramtype2= 'facedir', + paramtype2= "facedir", drawtype="nodebox", node_box = { @@ -41,27 +59,54 @@ minetest.register_node("digtron:digger", { }, "digtron_motor.png", }, + + -- returns fuel_cost, item_produced + execute_dig = function(pos, protected_nodes, nodes_dug, controlling_coordinate) + local facing = minetest.get_node(pos).param2 + local digpos = digtron.find_new_pos(pos, facing) + + if protected_nodes:get(digpos.x, digpos.y, digpos.z) then + return 0, nil + end + + return digtron.mark_diggable(digpos, nodes_dug) + end, +}) + +-- Digs out nodes that are "in front" of the digger head. +minetest.register_node("digtron:intermittent_digger", { + description = "Intermittent Digger Head", + groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 3}, + drop = "digtron:intermittent_digger", + sounds = default.node_sound_metal_defaults(), + paramtype = "light", + paramtype2= "facedir", - on_construct = function(pos) - local meta = minetest.env:get_meta(pos) - meta:set_string("formspec", - "size[3.5,1]" .. - default.gui_bg .. - default.gui_bg_img .. - default.gui_slots .. - "field[0.5,0.8;1,0.1;period;Periodicity;${period}]" .. - "tooltip[period;Digger will dig once every n steps. These steps are globally aligned, all diggers with the same period and offset will dig on the same location.]" .. - "field[1.5,0.8;1,0.1;offset;Offset;${offset}]" .. - "tooltip[offset;Offsets the start of periodicity counting by this amount. For example, a digger with period 2 and offset 0 digs every even-numbered node and one with period 2 and offset 1 digs every odd-numbered node.]" .. - "button_exit[2.2,0.5;1,0.1;set;Save]" .. - "tooltip[set;Saves settings]" - ) - meta:set_int("period", 1) - meta:set_int("offset", 0) - - local inv = meta:get_inventory() - inv:set_size("main", 1) - end, + drawtype="nodebox", + node_box = { + type = "fixed", + fixed = digger_nodebox, + }, + + -- Aims in the +Z direction by default + tiles = { + "digtron_plate.png^[transformR90", + "digtron_plate.png^[transformR270", + "digtron_plate.png", + "digtron_plate.png^[transformR180", + { + name = "digtron_digger.png", + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 1.0, + }, + }, + "digtron_intermittent_motor.png", + }, + + on_construct = intermittent_on_construct, on_receive_fields = function(pos, formname, fields, sender) local meta = minetest.get_meta(pos) @@ -97,10 +142,10 @@ minetest.register_node("digtron:digger", { minetest.register_node("digtron:soft_digger", { description = "Soft Material Digger Head", groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 3}, - drop = 'digtron:soft_digger', + drop = "digtron:soft_digger", sounds = default.node_sound_metal_defaults(), paramtype = "light", - paramtype2= 'facedir', + paramtype2= "facedir", drawtype="nodebox", node_box = { @@ -126,12 +171,6 @@ minetest.register_node("digtron:soft_digger", { "digtron_motor.png^[colorize:#88880030", }, - can_dig = function(pos,player) - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - return inv:is_empty("main") and inv:is_empty("inv") - end, - execute_dig = function(pos, protected_nodes, nodes_dug, controlling_coordinate) local facing = minetest.get_node(pos).param2 local digpos = digtron.find_new_pos(pos, facing) @@ -149,6 +188,66 @@ minetest.register_node("digtron:soft_digger", { return digtron.mark_diggable(digpos, nodes_dug) end + return 0, nil + end, +}) + +minetest.register_node("digtron:intermittent_soft_digger", { + description = "Intermittent Soft Material Digger Head", + groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 3}, + drop = "digtron:intermittent_soft_digger", + sounds = default.node_sound_metal_defaults(), + paramtype = "light", + paramtype2= "facedir", + + drawtype="nodebox", + node_box = { + type = "fixed", + fixed = digger_nodebox, + }, + + -- Aims in the +Z direction by default + tiles = { + "digtron_plate.png^[transformR90^[colorize:#88880030", + "digtron_plate.png^[transformR270^[colorize:#88880030", + "digtron_plate.png^[colorize:#88880030", + "digtron_plate.png^[transformR180^[colorize:#88880030", + { + name = "digtron_digger.png^[colorize:#88880030", + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 1.0, + }, + }, + "digtron_intermittent_motor.png^[colorize:#88880030", + }, + + on_construct = intermittent_on_construct, + + execute_dig = function(pos, protected_nodes, nodes_dug, controlling_coordinate) + local facing = minetest.get_node(pos).param2 + local digpos = digtron.find_new_pos(pos, facing) + + if protected_nodes:get(digpos.x, digpos.y, digpos.z) then + return 0, nil + end + + local meta = minetest.get_meta(pos) + if (digpos[controlling_coordinate] + meta:get_int("offset")) % meta:get_int("period") ~= 0 then + return 0, nil + end + + local target_node = minetest.get_node(digpos) + if minetest.get_item_group(target_node.name, "crumbly") ~= 0 or + minetest.get_item_group(target_node.name, "choppy") ~= 0 or + minetest.get_item_group(target_node.name, "snappy") ~= 0 or + minetest.get_item_group(target_node.name, "oddly_breakable_by_hand") ~= 0 or + minetest.get_item_group(target_node.name, "fleshy") ~= 0 then + return digtron.mark_diggable(digpos, nodes_dug) + end + return 0, nil end, }) \ No newline at end of file diff --git a/node_misc.lua b/node_misc.lua index c2c1bfb..c6bc8d4 100644 --- a/node_misc.lua +++ b/node_misc.lua @@ -2,7 +2,7 @@ minetest.register_node("digtron:structure", { description = "Digger Structure", groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 1}, - drop = 'digtron:structure', + drop = "digtron:structure", tiles = {"digtron_plate.png"}, drawtype = "nodebox", sounds = default.node_sound_metal_defaults(), @@ -32,7 +32,7 @@ minetest.register_node("digtron:structure", { minetest.register_node("digtron:light", { description = "Digger Light", groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 1}, - drop = 'digtron:light', + drop = "digtron:light", tiles = {"digtron_light.png"}, drawtype = "nodebox", paramtype = "light", @@ -53,9 +53,9 @@ minetest.register_node("digtron:inventory", { description = "Digtron Inventory Hopper", groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 2}, - drop = 'digtron:inventory', + drop = "digtron:inventory", sounds = default.node_sound_metal_defaults(), - paramtype2= 'facedir', + paramtype2= "facedir", tiles = {"digtron_inventory.png"}, on_construct = function(pos) @@ -90,9 +90,9 @@ minetest.register_node("digtron:fuelstore", { description = "Digtron Fuel Hopper", groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 5}, - drop = 'digtron:fuelstore', + drop = "digtron:fuelstore", sounds = default.node_sound_metal_defaults(), - paramtype2= 'facedir', + paramtype2= "facedir", tiles = {"digtron_fuelstore.png"}, on_construct = function(pos) diff --git a/recipes.lua b/recipes.lua index ec45fd3..1d0955b 100644 --- a/recipes.lua +++ b/recipes.lua @@ -93,6 +93,32 @@ minetest.register_craft({ } }) +-- For swapping digger types +minetest.register_craft({ + output = "digtron:digger", + recipe = { + {"digtron:intermittent_digger"}, + } +}) +minetest.register_craft({ + output = "digtron:intermittent_digger", + recipe = { + {"digtron:digger"}, + } +}) +minetest.register_craft({ + output = "digtron:soft_digger", + recipe = { + {"digtron:intermittent_soft_digger"}, + } +}) +minetest.register_craft({ + output = "digtron:intermittent_soft_digger", + recipe = { + {"digtron:soft_digger"}, + } +}) + -- And some recycling reactions to get digtron cores out of the "cheap" parts: minetest.register_craft({ diff --git a/textures/digtron_intermittent_motor.png b/textures/digtron_intermittent_motor.png new file mode 100644 index 0000000000000000000000000000000000000000..31afa6cc5ca42c9a02fdf7c52eb8bd08543f312b GIT binary patch literal 811 zcmV+`1JwM9P)W}0000TX;fHrLvL+uWo~o;00000Lvm$d zbY)~9cWHEJAV*0}P-HG;2LJ#9p-DtRR4C5{!AWo2Q~&_rx7+V|8&Ag5CS)N|sSt=o zhytQLAg%}`xN(5r2oiVHN+6Y@fJz00hBRU7nPieQp2hatAKwSR`tpk+h8D}hG z%sOARXT<5td>3FEyn`TUZ32K=N|dBY+v|KdWHIMS8mEQQI!!o9@+eM)5W$BmO^YlY zjm7~46tSopmG^&qaCrEbG8SMcM-{>`^I9YVLX;1(N5B5|?D$j~mFGD^1RHDnUN%jG zDJ2+VjE%Q8Kw}gW$-3>2{ynbi8h8(!h2MVjb(*IkfVOQhCcs&_Y#0BXSgX?g+j%)q zMjK^ff&xTNOT>i$fe;#V&YiXKMg5^X&24ve@v=Mo`LBl$F+x$q0A(B1SXqbPeB<@D zZxg|d)^N4>WC-#0tv?qk9*qY)zMf8&)|b_o5OO}BQ%dmXn_-L`G}>Zd9F=KETa9 za)=DNdDhNSvm{M=LknTGwvmj&0(8r}uWUSdairSz1|?_9RoFRbh6mPK0Dw{w1ptk4 z5RrgcwlSRL+hx~$HZ-3K9nL2{AM73MJLeEWWjWMR6KBlT;<^w~*K5k?b7xK(i2gZ# zdftT5*3N6UV$QYE0D!uFfe^%Rzw=fmk|$4(etC4bx4#?l6b`Zqx7E!m-rnaCld}8% zyC0_0*{i#I!5L(afG