2017-02-05 07:08:38 +01:00
-- internationalization boilerplate
local MP = minetest.get_modpath ( minetest.get_current_modname ( ) )
2023-06-05 13:05:54 +02:00
local S = dofile ( MP .. " /intllib.lua " )
2017-02-05 07:08:38 +01:00
2016-12-31 07:38:18 +01:00
-- Note: diggers go in group 3 and have an execute_dig method.
2019-01-05 06:06:12 +01:00
local damage_hp = digtron.config . damage_hp
local damage_hp_half = damage_hp / 2
2016-12-31 07:38:18 +01:00
local digger_nodebox = {
{ - 0.5 , - 0.5 , 0 , 0.5 , 0.5 , 0.4375 } , -- Block
{ - 0.4375 , - 0.3125 , 0.4375 , 0.4375 , 0.3125 , 0.5 } , -- Cutter1
{ - 0.3125 , - 0.4375 , 0.4375 , 0.3125 , 0.4375 , 0.5 } , -- Cutter2
{ - 0.5 , - 0.125 , - 0.125 , 0.5 , 0.125 , 0 } , -- BackFrame1
{ - 0.125 , - 0.5 , - 0.125 , 0.125 , 0.5 , 0 } , -- BackFrame2
{ - 0.25 , - 0.25 , - 0.5 , 0.25 , 0.25 , 0 } , -- Drive
}
2017-01-14 07:20:59 +01:00
local dual_digger_nodebox = {
{ - 0.5 , - 0.4375 , 0 , 0.5 , 0.5 , 0.4375 } , -- Block
{ - 0.4375 , - 0.3125 , 0.4375 , 0.4375 , 0.3125 , 0.5 } , -- Cutter1
{ - 0.3125 , - 0.4375 , 0.4375 , 0.3125 , 0.4375 , 0.5 } , -- Cutter2
{ - 0.5 , 0 , - 0.125 , 0.5 , 0.125 , 0 } , -- BackFrame1
{ - 0.25 , 0 , - 0.5 , 0.25 , 0.25 , 0 } , -- Drive
{ - 0.25 , 0.25 , - 0.25 , 0.25 , 0.5 , 0 } , -- Upper_Drive
{ - 0.5 , - 0.4375 , - 0.5 , 0.5 , 0 , 0.4375 } , -- Lower_Block
{ - 0.3125 , - 0.5 , - 0.4375 , 0.3125 , - 0.4375 , 0.4375 } , -- Lower_Cutter_1
{ - 0.4375 , - 0.5 , - 0.3125 , 0.4375 , - 0.4375 , 0.3125 } , -- Lower_Cutter_2
}
2017-10-22 06:29:18 +02:00
local modpath_doc = minetest.get_modpath ( " doc " )
local intermittent_formspec_string = default.gui_bg ..
2017-02-02 04:32:58 +01:00
default.gui_bg_img ..
default.gui_slots ..
2017-02-05 07:08:38 +01:00
" field[0.5,0.8;1,0.1;period; " .. S ( " Periodicity " ) .. " ;${period}] " ..
" tooltip[period; " .. S ( " Digger will dig once every n steps. \n These steps are globally aligned, all diggers with \n the same period and offset will dig on the same location. " ) .. " ] " ..
" field[1.5,0.8;1,0.1;offset; " .. S ( " Offset " ) .. " ;${offset}] " ..
2023-06-05 13:05:54 +02:00
" tooltip[offset; " .. S ( " Offsets the start of periodicity counting by this amount. \n For example, a digger with period 2 and offset 0 digs \n every even-numbered block and one with period 2 and \n " ..
" offset 1 digs every odd-numbered block. " ) .. " ] " ..
2017-09-20 07:25:11 +02:00
" button_exit[2.2,0.5;1,0.1;set; " .. S ( " Save & \n Show " ) .. " ] " ..
2017-02-05 07:08:38 +01:00
" tooltip[set; " .. S ( " Saves settings " ) .. " ] "
2017-02-02 04:32:58 +01:00
2017-10-22 06:29:18 +02:00
if modpath_doc then
intermittent_formspec_string = " size[4.5,1] " .. intermittent_formspec_string ..
2017-02-05 07:08:38 +01:00
" button_exit[3.2,0.5;1,0.1;help; " .. S ( " Help " ) .. " ] " ..
" tooltip[help; " .. S ( " Show documentation about this block " ) .. " ] "
2017-02-02 04:32:58 +01:00
else
2017-10-22 06:29:18 +02:00
intermittent_formspec_string = " size[3.5,1] " .. intermittent_formspec_string
2017-02-02 04:32:58 +01:00
end
2017-09-20 06:57:40 +02:00
2023-06-05 13:05:54 +02:00
local intermittent_formspec = function ( _ , meta )
2017-10-22 06:29:18 +02:00
return intermittent_formspec_string
2019-01-02 07:31:51 +01:00
: gsub ( " ${period} " , meta : get_int ( " period " ) , 1 )
: gsub ( " ${offset} " , meta : get_int ( " offset " ) , 1 )
end
2017-10-22 06:29:18 +02:00
2017-09-20 06:57:40 +02:00
local intermittent_on_construct = function ( pos )
2017-01-04 03:43:32 +01:00
local meta = minetest.get_meta ( pos )
2023-06-05 12:39:36 +02:00
meta : set_int ( " period " , 1 )
meta : set_int ( " offset " , 0 )
2017-01-04 03:43:32 +01:00
end
2023-06-05 13:05:54 +02:00
local intermittent_on_rightclick = function ( pos , _ , clicker , itemstack , pointed_thing )
2019-01-09 08:20:02 +01:00
local item_def = itemstack : get_definition ( )
if item_def.type == " node " and minetest.get_item_group ( itemstack : get_name ( ) , " digtron " ) > 0 then
local returnstack , success = minetest.item_place_node ( itemstack , clicker , pointed_thing )
if success and item_def.sounds and item_def.sounds . place and item_def.sounds . place.name then
minetest.sound_play ( item_def.sounds . place , { pos = pos } )
end
return returnstack , success
2017-01-04 07:03:41 +01:00
end
2023-06-05 13:05:54 +02:00
local meta = minetest.get_meta ( pos )
2019-01-02 07:31:51 +01:00
minetest.show_formspec ( clicker : get_player_name ( ) ,
" digtron:intermittent_digger " .. minetest.pos_to_string ( pos ) ,
intermittent_formspec ( pos , meta ) )
end
2021-08-21 09:42:00 +02:00
local use_texture_alpha = minetest.features . use_texture_alpha_string_modes and " opaque " or nil
2019-01-02 07:31:51 +01:00
minetest.register_on_player_receive_fields ( function ( player , formname , fields )
if formname : sub ( 1 , 27 ) == " digtron:intermittent_digger " then
local pos = minetest.string_to_pos ( formname : sub ( 28 , - 1 ) )
local meta = minetest.get_meta ( pos )
local period = tonumber ( fields.period )
local offset = tonumber ( fields.offset )
if period and period > 0 then
meta : set_int ( " period " , math.floor ( period ) )
end
if offset then
meta : set_int ( " offset " , math.floor ( offset ) )
end
if fields.help and minetest.get_modpath ( " doc " ) then --check for mod in case someone disabled it after this digger was built
local node_name = minetest.get_node ( pos ) . name
minetest.after ( 0.5 , doc.show_entry , player : get_player_name ( ) , " nodes " , node_name , true )
end
if fields.set then
digtron.show_offset_markers ( pos , offset , period )
end
return true
2017-09-20 07:25:11 +02:00
end
2019-01-02 07:31:51 +01:00
end )
2017-01-04 07:03:41 +01:00
2016-12-31 07:38:18 +01:00
-- Digs out nodes that are "in front" of the digger head.
minetest.register_node ( " digtron:digger " , {
2017-02-05 07:08:38 +01:00
description = S ( " Digtron Digger Head " ) ,
2017-01-18 03:57:20 +01:00
_doc_items_longdesc = digtron.doc . digger_longdesc ,
_doc_items_usagehelp = digtron.doc . digger_usagehelp ,
2017-01-03 04:07:15 +01:00
groups = { cracky = 3 , oddly_breakable_by_hand = 3 , digtron = 3 } ,
2017-01-04 03:43:32 +01:00
drop = " digtron:digger " ,
2017-01-04 07:56:34 +01:00
sounds = digtron.metal_sounds ,
2016-12-31 07:38:18 +01:00
paramtype = " light " ,
2017-01-04 03:43:32 +01:00
paramtype2 = " facedir " ,
2023-06-05 13:05:54 +02:00
is_ground_content = false ,
2016-12-31 07:38:18 +01:00
drawtype = " nodebox " ,
node_box = {
type = " fixed " ,
fixed = digger_nodebox ,
} ,
2023-06-05 12:34:40 +02:00
2016-12-31 07:38:18 +01:00
-- Aims in the +Z direction by default
tiles = {
" digtron_plate.png^[transformR90 " ,
" digtron_plate.png^[transformR270 " ,
" digtron_plate.png " ,
" digtron_plate.png^[transformR180 " ,
{
2017-01-06 05:13:16 +01:00
name = " digtron_digger_yb.png " ,
2016-12-31 07:38:18 +01:00
animation = {
type = " vertical_frames " ,
aspect_w = 16 ,
aspect_h = 16 ,
length = 1.0 ,
} ,
} ,
2017-01-11 06:59:11 +01:00
" digtron_plate.png^digtron_motor.png " ,
2016-12-31 07:38:18 +01:00
} ,
2017-01-04 03:43:32 +01:00
-- returns fuel_cost, item_produced
2023-06-05 13:05:54 +02:00
execute_dig = function ( pos , protected_nodes , nodes_dug , _ , _ , player )
2017-01-04 03:43:32 +01:00
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
2019-01-05 06:06:12 +01:00
return 0
2017-01-04 03:43:32 +01:00
end
2023-06-05 12:34:40 +02:00
2017-10-15 20:54:48 +02:00
return digtron.mark_diggable ( digpos , nodes_dug , player )
2017-01-04 03:43:32 +01:00
end ,
2023-06-05 12:34:40 +02:00
2023-06-05 13:05:54 +02:00
damage_creatures = function ( player , pos , _ , items_dropped )
2017-01-14 07:20:59 +01:00
local facing = minetest.get_node ( pos ) . param2
2019-01-05 06:06:12 +01:00
digtron.damage_creatures ( player , pos , digtron.find_new_pos ( pos , facing ) , damage_hp , items_dropped )
2017-01-07 07:48:48 +01:00
end ,
2017-01-04 03:43:32 +01:00
} )
-- Digs out nodes that are "in front" of the digger head.
minetest.register_node ( " digtron:intermittent_digger " , {
2017-02-05 07:08:38 +01:00
description = S ( " Digtron Intermittent Digger Head " ) ,
2017-01-18 03:57:20 +01:00
_doc_items_longdesc = digtron.doc . intermittent_digger_longdesc ,
_doc_items_usagehelp = digtron.doc . intermittent_digger_usagehelp ,
2017-09-20 06:57:40 +02:00
_digtron_formspec = intermittent_formspec ,
2017-01-04 03:43:32 +01:00
groups = { cracky = 3 , oddly_breakable_by_hand = 3 , digtron = 3 } ,
drop = " digtron:intermittent_digger " ,
2017-01-04 07:56:34 +01:00
sounds = digtron.metal_sounds ,
2017-01-04 03:43:32 +01:00
paramtype = " light " ,
paramtype2 = " facedir " ,
2023-06-05 13:05:54 +02:00
is_ground_content = false ,
2017-01-04 03:43:32 +01:00
drawtype = " nodebox " ,
node_box = {
type = " fixed " ,
fixed = digger_nodebox ,
} ,
2023-06-05 12:34:40 +02:00
2017-01-04 03:43:32 +01:00
-- Aims in the +Z direction by default
tiles = {
" digtron_plate.png^[transformR90 " ,
" digtron_plate.png^[transformR270 " ,
" digtron_plate.png " ,
" digtron_plate.png^[transformR180 " ,
{
2017-01-06 05:13:16 +01:00
name = " digtron_digger_yb.png " ,
2017-01-04 03:43:32 +01:00
animation = {
type = " vertical_frames " ,
aspect_w = 16 ,
aspect_h = 16 ,
length = 1.0 ,
} ,
} ,
2017-01-22 04:38:19 +01:00
" digtron_plate.png^digtron_intermittent.png^digtron_motor.png " ,
2017-01-04 03:43:32 +01:00
} ,
2023-06-05 12:34:40 +02:00
2017-01-04 03:43:32 +01:00
on_construct = intermittent_on_construct ,
2023-06-05 12:34:40 +02:00
2019-01-02 07:31:51 +01:00
on_rightclick = intermittent_on_rightclick ,
2016-12-31 07:38:18 +01:00
2019-01-05 06:06:12 +01:00
-- returns fuel_cost, item_produced (a table or nil)
2017-10-15 20:54:48 +02:00
execute_dig = function ( pos , protected_nodes , nodes_dug , controlling_coordinate , lateral_dig , player )
2017-01-15 00:58:37 +01:00
if lateral_dig == true then
2019-01-05 06:06:12 +01:00
return 0
2017-01-15 00:58:37 +01:00
end
2016-12-31 07:38:18 +01:00
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
2019-01-05 06:06:12 +01:00
return 0
2016-12-31 07:38:18 +01:00
end
2023-06-05 12:34:40 +02:00
2016-12-31 07:38:18 +01:00
local meta = minetest.get_meta ( pos )
2017-01-02 01:12:32 +01:00
if ( digpos [ controlling_coordinate ] + meta : get_int ( " offset " ) ) % meta : get_int ( " period " ) ~= 0 then
2019-01-05 06:06:12 +01:00
return 0
2016-12-31 07:38:18 +01:00
end
2023-06-05 12:34:40 +02:00
2017-10-15 20:54:48 +02:00
return digtron.mark_diggable ( digpos , nodes_dug , player )
2016-12-31 07:38:18 +01:00
end ,
2023-06-05 12:34:40 +02:00
2019-01-05 06:06:12 +01:00
damage_creatures = function ( player , pos , controlling_coordinate , items_dropped )
2017-01-14 07:20:59 +01:00
local facing = minetest.get_node ( pos ) . param2
local targetpos = digtron.find_new_pos ( pos , facing )
2017-01-07 07:48:48 +01:00
local meta = minetest.get_meta ( pos )
if ( targetpos [ controlling_coordinate ] + meta : get_int ( " offset " ) ) % meta : get_int ( " period " ) == 0 then
2019-01-05 06:06:12 +01:00
digtron.damage_creatures ( player , pos , targetpos , damage_hp , items_dropped )
2017-01-07 07:48:48 +01:00
end
end
2016-12-31 07:38:18 +01:00
} )
-- A special-purpose digger to deal with stuff like sand and gravel in the ceiling. It always digs (no periodicity or offset), but it only digs falling_block nodes
2017-01-01 05:19:52 +01:00
minetest.register_node ( " digtron:soft_digger " , {
2017-02-05 07:08:38 +01:00
description = S ( " Digtron Soft Material Digger Head " ) ,
2017-01-18 03:57:20 +01:00
_doc_items_longdesc = digtron.doc . soft_digger_longdesc ,
_doc_items_usagehelp = digtron.doc . soft_digger_usagehelp ,
2017-01-03 04:07:15 +01:00
groups = { cracky = 3 , oddly_breakable_by_hand = 3 , digtron = 3 } ,
2017-01-04 03:43:32 +01:00
drop = " digtron:soft_digger " ,
2017-01-04 07:56:34 +01:00
sounds = digtron.metal_sounds ,
2021-08-21 09:42:00 +02:00
use_texture_alpha = use_texture_alpha ,
2016-12-31 07:38:18 +01:00
paramtype = " light " ,
2017-01-04 03:43:32 +01:00
paramtype2 = " facedir " ,
2017-10-10 21:02:35 +02:00
is_ground_content = false ,
2016-12-31 07:38:18 +01:00
drawtype = " nodebox " ,
node_box = {
type = " fixed " ,
fixed = digger_nodebox ,
} ,
2023-06-05 12:34:40 +02:00
2016-12-31 07:38:18 +01:00
-- Aims in the +Z direction by default
tiles = {
2017-01-22 04:38:19 +01:00
" digtron_plate.png^[transformR90^[colorize: " .. digtron.soft_digger_colorize ,
" digtron_plate.png^[transformR270^[colorize: " .. digtron.soft_digger_colorize ,
" digtron_plate.png^[colorize: " .. digtron.soft_digger_colorize ,
" digtron_plate.png^[transformR180^[colorize: " .. digtron.soft_digger_colorize ,
2016-12-31 07:38:18 +01:00
{
2017-01-22 04:38:19 +01:00
name = " digtron_digger_yb.png^[colorize: " .. digtron.soft_digger_colorize ,
2016-12-31 07:38:18 +01:00
animation = {
type = " vertical_frames " ,
aspect_w = 16 ,
aspect_h = 16 ,
length = 1.0 ,
} ,
} ,
2017-01-22 04:38:19 +01:00
" digtron_plate.png^digtron_motor.png^[colorize: " .. digtron.soft_digger_colorize ,
2016-12-31 07:38:18 +01:00
} ,
2023-06-05 12:34:40 +02:00
2023-06-05 13:05:54 +02:00
execute_dig = function ( pos , protected_nodes , nodes_dug , _ , _ , player )
2017-01-04 03:43:32 +01:00
local facing = minetest.get_node ( pos ) . param2
local digpos = digtron.find_new_pos ( pos , facing )
2023-06-05 12:34:40 +02:00
2017-01-04 03:43:32 +01:00
if protected_nodes : get ( digpos.x , digpos.y , digpos.z ) then
2019-01-05 06:06:12 +01:00
return 0
2017-01-04 03:43:32 +01:00
end
2023-06-05 12:34:40 +02:00
2017-01-14 07:20:59 +01:00
if digtron.is_soft_material ( digpos ) then
2017-10-15 20:54:48 +02:00
return digtron.mark_diggable ( digpos , nodes_dug , player )
2017-01-04 03:43:32 +01:00
end
2023-06-05 12:34:40 +02:00
2019-01-05 06:06:12 +01:00
return 0
2016-12-31 07:38:18 +01:00
end ,
2017-01-07 07:48:48 +01:00
2023-06-05 13:05:54 +02:00
damage_creatures = function ( player , pos , _ , items_dropped )
2017-01-14 07:20:59 +01:00
local facing = minetest.get_node ( pos ) . param2
2019-01-05 06:06:12 +01:00
digtron.damage_creatures ( player , pos , digtron.find_new_pos ( pos , facing ) , damage_hp_half , items_dropped )
2017-01-07 07:48:48 +01:00
end ,
2017-01-04 03:43:32 +01:00
} )
minetest.register_node ( " digtron:intermittent_soft_digger " , {
2017-02-05 07:08:38 +01:00
description = S ( " Digtron Intermittent Soft Material Digger Head " ) ,
2017-01-18 03:57:20 +01:00
_doc_items_longdesc = digtron.doc . intermittent_soft_digger_longdesc ,
_doc_items_usagehelp = digtron.doc . intermittent_soft_digger_usagehelp ,
2017-09-20 06:57:40 +02:00
_digtron_formspec = intermittent_formspec ,
2017-01-04 03:43:32 +01:00
groups = { cracky = 3 , oddly_breakable_by_hand = 3 , digtron = 3 } ,
drop = " digtron:intermittent_soft_digger " ,
2017-01-04 07:56:34 +01:00
sounds = digtron.metal_sounds ,
2021-08-21 09:42:00 +02:00
use_texture_alpha = use_texture_alpha ,
2017-01-04 03:43:32 +01:00
paramtype = " light " ,
paramtype2 = " facedir " ,
2017-01-06 07:52:09 +01:00
is_ground_content = false ,
2017-01-04 03:43:32 +01:00
drawtype = " nodebox " ,
node_box = {
type = " fixed " ,
fixed = digger_nodebox ,
} ,
2023-06-05 12:34:40 +02:00
2017-01-04 03:43:32 +01:00
-- Aims in the +Z direction by default
tiles = {
2017-01-22 04:38:19 +01:00
" digtron_plate.png^[transformR90^[colorize: " .. digtron.soft_digger_colorize ,
" digtron_plate.png^[transformR270^[colorize: " .. digtron.soft_digger_colorize ,
" digtron_plate.png^[colorize: " .. digtron.soft_digger_colorize ,
" digtron_plate.png^[transformR180^[colorize: " .. digtron.soft_digger_colorize ,
2017-01-04 03:43:32 +01:00
{
2017-01-22 04:38:19 +01:00
name = " digtron_digger_yb.png^[colorize: " .. digtron.soft_digger_colorize ,
2017-01-04 03:43:32 +01:00
animation = {
type = " vertical_frames " ,
aspect_w = 16 ,
aspect_h = 16 ,
length = 1.0 ,
} ,
} ,
2017-01-22 04:38:19 +01:00
" digtron_plate.png^digtron_intermittent.png^digtron_motor.png^[colorize: " .. digtron.soft_digger_colorize ,
2017-01-04 03:43:32 +01:00
} ,
2023-06-05 12:34:40 +02:00
2017-01-04 03:43:32 +01:00
on_construct = intermittent_on_construct ,
2023-06-05 12:34:40 +02:00
2019-01-02 07:31:51 +01:00
on_rightclick = intermittent_on_rightclick ,
2023-06-05 12:34:40 +02:00
2017-10-15 20:54:48 +02:00
execute_dig = function ( pos , protected_nodes , nodes_dug , controlling_coordinate , lateral_dig , player )
2017-01-15 00:58:37 +01:00
if lateral_dig == true then
2019-01-05 06:06:12 +01:00
return 0
2017-01-15 00:58:37 +01:00
end
2016-12-31 07:38:18 +01:00
local facing = minetest.get_node ( pos ) . param2
local digpos = digtron.find_new_pos ( pos , facing )
2023-06-05 12:34:40 +02:00
2016-12-31 07:38:18 +01:00
if protected_nodes : get ( digpos.x , digpos.y , digpos.z ) then
2019-01-05 06:06:12 +01:00
return 0
2016-12-31 07:38:18 +01:00
end
2023-06-05 12:34:40 +02:00
2017-01-04 03:43:32 +01:00
local meta = minetest.get_meta ( pos )
if ( digpos [ controlling_coordinate ] + meta : get_int ( " offset " ) ) % meta : get_int ( " period " ) ~= 0 then
2019-01-05 06:06:12 +01:00
return 0
2017-01-04 03:43:32 +01:00
end
2023-06-05 12:34:40 +02:00
2017-01-14 07:20:59 +01:00
if digtron.is_soft_material ( digpos ) then
2017-10-15 20:54:48 +02:00
return digtron.mark_diggable ( digpos , nodes_dug , player )
2016-12-31 07:38:18 +01:00
end
2023-06-05 12:34:40 +02:00
2019-01-05 06:06:12 +01:00
return 0
2016-12-31 07:38:18 +01:00
end ,
2017-01-07 07:48:48 +01:00
2019-01-05 06:06:12 +01:00
damage_creatures = function ( player , pos , controlling_coordinate , items_dropped )
2017-01-07 07:48:48 +01:00
local meta = minetest.get_meta ( pos )
2017-01-14 07:20:59 +01:00
local facing = minetest.get_node ( pos ) . param2
2023-06-05 13:05:54 +02:00
local targetpos = digtron.find_new_pos ( pos , facing )
2017-01-07 07:48:48 +01:00
if ( targetpos [ controlling_coordinate ] + meta : get_int ( " offset " ) ) % meta : get_int ( " period " ) == 0 then
2019-01-05 06:06:12 +01:00
digtron.damage_creatures ( player , pos , targetpos , damage_hp_half , items_dropped )
2017-01-07 07:48:48 +01:00
end
end ,
2017-01-14 07:20:59 +01:00
} )
-- Digs out nodes that are "in front" of the digger head and "below" the digger head (can be rotated).
minetest.register_node ( " digtron:dual_digger " , {
2017-02-05 07:08:38 +01:00
description = S ( " Digtron Dual Digger Head " ) ,
2017-01-18 03:57:20 +01:00
_doc_items_longdesc = digtron.doc . dual_digger_longdesc ,
_doc_items_usagehelp = digtron.doc . dual_digger_usagehelp ,
2017-01-14 07:20:59 +01:00
groups = { cracky = 3 , oddly_breakable_by_hand = 3 , digtron = 3 } ,
drop = " digtron:dual_digger " ,
sounds = digtron.metal_sounds ,
paramtype = " light " ,
paramtype2 = " facedir " ,
2023-06-05 13:05:54 +02:00
is_ground_content = false ,
2017-01-14 07:20:59 +01:00
drawtype = " nodebox " ,
node_box = {
type = " fixed " ,
fixed = dual_digger_nodebox ,
} ,
2023-06-05 12:34:40 +02:00
2017-01-14 07:20:59 +01:00
-- Aims in the +Z and -Y direction by default
tiles = {
" digtron_plate.png^digtron_motor.png " ,
{
name = " digtron_digger_yb.png " ,
animation = {
type = " vertical_frames " ,
aspect_w = 16 ,
aspect_h = 16 ,
length = 1.0 ,
} ,
} ,
" digtron_plate.png " ,
" digtron_plate.png^[transformR180 " ,
{
name = " digtron_digger_yb.png " ,
animation = {
type = " vertical_frames " ,
aspect_w = 16 ,
aspect_h = 16 ,
length = 1.0 ,
} ,
} ,
" digtron_plate.png^digtron_motor.png " ,
} ,
-- returns fuel_cost, items_produced
2023-06-05 13:05:54 +02:00
execute_dig = function ( pos , protected_nodes , nodes_dug , _ , _ , player )
2017-01-14 07:20:59 +01:00
local facing = minetest.get_node ( pos ) . param2
local digpos = digtron.find_new_pos ( pos , facing )
local digdown = digtron.find_new_pos_downward ( pos , facing )
local items = { }
local cost = 0
2023-06-05 12:34:40 +02:00
2017-01-14 07:20:59 +01:00
if protected_nodes : get ( digpos.x , digpos.y , digpos.z ) ~= true then
2017-10-15 20:54:48 +02:00
local forward_cost , forward_items = digtron.mark_diggable ( digpos , nodes_dug , player )
2019-01-05 06:06:12 +01:00
if forward_items ~= nil then
for _ , item in pairs ( forward_items ) do
table.insert ( items , item )
end
2017-01-14 07:20:59 +01:00
end
cost = cost + forward_cost
end
if protected_nodes : get ( digdown.x , digdown.y , digdown.z ) ~= true then
2017-10-15 20:54:48 +02:00
local down_cost , down_items = digtron.mark_diggable ( digdown , nodes_dug , player )
2019-01-05 06:06:12 +01:00
if down_items ~= nil then
for _ , item in pairs ( down_items ) do
table.insert ( items , item )
end
2017-01-14 07:20:59 +01:00
end
cost = cost + down_cost
end
2023-06-05 12:34:40 +02:00
2017-01-14 07:20:59 +01:00
return cost , items
end ,
2023-06-05 12:34:40 +02:00
2023-06-05 13:05:54 +02:00
damage_creatures = function ( player , pos , _ , items_dropped )
2017-01-14 07:20:59 +01:00
local facing = minetest.get_node ( pos ) . param2
2019-01-05 06:06:12 +01:00
digtron.damage_creatures ( player , pos , digtron.find_new_pos ( pos , facing ) , damage_hp , items_dropped )
digtron.damage_creatures ( player , pos , digtron.find_new_pos_downward ( pos , facing ) , damage_hp , items_dropped )
2017-01-14 07:20:59 +01:00
end ,
} )
-- Digs out soft nodes that are "in front" of the digger head and "below" the digger head (can be rotated).
minetest.register_node ( " digtron:dual_soft_digger " , {
2017-02-05 07:08:38 +01:00
description = S ( " Digtron Dual Soft Material Digger Head " ) ,
2017-01-18 03:57:20 +01:00
_doc_items_longdesc = digtron.doc . dual_soft_digger_longdesc ,
_doc_items_usagehelp = digtron.doc . dual_soft_digger_usagehelp ,
2017-01-14 07:20:59 +01:00
groups = { cracky = 3 , oddly_breakable_by_hand = 3 , digtron = 3 } ,
drop = " digtron:dual_soft_digger " ,
sounds = digtron.metal_sounds ,
2021-08-21 09:42:00 +02:00
use_texture_alpha = use_texture_alpha ,
2017-01-14 07:20:59 +01:00
paramtype = " light " ,
paramtype2 = " facedir " ,
2023-06-05 13:05:54 +02:00
is_ground_content = false ,
2017-01-14 07:20:59 +01:00
drawtype = " nodebox " ,
node_box = {
type = " fixed " ,
fixed = dual_digger_nodebox ,
} ,
2023-06-05 12:34:40 +02:00
2017-01-14 07:20:59 +01:00
-- Aims in the +Z and -Y direction by default
tiles = {
2017-01-22 04:38:19 +01:00
" digtron_plate.png^digtron_motor.png^[colorize: " .. digtron.soft_digger_colorize ,
2017-01-14 07:20:59 +01:00
{
2017-01-22 04:38:19 +01:00
name = " digtron_digger_yb.png^[colorize: " .. digtron.soft_digger_colorize ,
2017-01-14 07:20:59 +01:00
animation = {
type = " vertical_frames " ,
aspect_w = 16 ,
aspect_h = 16 ,
length = 1.0 ,
} ,
} ,
2017-01-22 04:38:19 +01:00
" digtron_plate.png^[colorize: " .. digtron.soft_digger_colorize ,
" digtron_plate.png^[transformR180^[colorize: " .. digtron.soft_digger_colorize ,
2017-01-14 07:20:59 +01:00
{
2017-01-22 04:38:19 +01:00
name = " digtron_digger_yb.png^[colorize: " .. digtron.soft_digger_colorize ,
2017-01-14 07:20:59 +01:00
animation = {
type = " vertical_frames " ,
aspect_w = 16 ,
aspect_h = 16 ,
length = 1.0 ,
} ,
} ,
2017-01-22 04:38:19 +01:00
" digtron_plate.png^digtron_motor.png^[colorize: " .. digtron.soft_digger_colorize ,
2017-01-14 07:20:59 +01:00
} ,
-- returns fuel_cost, items_produced
2023-06-05 13:05:54 +02:00
execute_dig = function ( pos , protected_nodes , nodes_dug , _ , _ , player )
2017-01-14 07:20:59 +01:00
local facing = minetest.get_node ( pos ) . param2
local digpos = digtron.find_new_pos ( pos , facing )
local digdown = digtron.find_new_pos_downward ( pos , facing )
local items = { }
local cost = 0
2023-06-05 12:34:40 +02:00
2017-01-14 07:20:59 +01:00
if protected_nodes : get ( digpos.x , digpos.y , digpos.z ) ~= true and digtron.is_soft_material ( digpos ) then
2017-10-15 20:54:48 +02:00
local forward_cost , forward_items = digtron.mark_diggable ( digpos , nodes_dug , player )
2019-01-05 06:06:12 +01:00
if forward_items ~= nil then
for _ , item in pairs ( forward_items ) do
table.insert ( items , item )
end
2017-01-14 07:20:59 +01:00
end
cost = cost + forward_cost
end
if protected_nodes : get ( digdown.x , digdown.y , digdown.z ) ~= true and digtron.is_soft_material ( digdown ) then
2017-10-15 20:54:48 +02:00
local down_cost , down_items = digtron.mark_diggable ( digdown , nodes_dug , player )
2019-01-05 06:06:12 +01:00
if down_items ~= nil then
for _ , item in pairs ( down_items ) do
table.insert ( items , item )
end
2017-01-14 07:20:59 +01:00
end
cost = cost + down_cost
end
2023-06-05 12:34:40 +02:00
2017-01-14 07:20:59 +01:00
return cost , items
end ,
2023-06-05 12:34:40 +02:00
2023-06-05 13:05:54 +02:00
damage_creatures = function ( player , pos , _ , items_dropped )
2017-01-14 07:20:59 +01:00
local facing = minetest.get_node ( pos ) . param2
2019-01-05 06:06:12 +01:00
digtron.damage_creatures ( player , pos , digtron.find_new_pos ( pos , facing ) , damage_hp_half , items_dropped )
digtron.damage_creatures ( player , pos , digtron.find_new_pos_downward ( pos , facing ) , damage_hp_half , items_dropped )
2017-01-14 07:20:59 +01:00
end ,
2021-08-21 09:42:00 +02:00
} )