Merge pull request #8 from minetest-mods/cleanup

Cleanup
This commit is contained in:
FaceDeer 2017-09-30 10:56:15 -06:00 committed by GitHub
commit 444411936c
15 changed files with 675 additions and 735 deletions

@ -6,9 +6,13 @@ DigtronLayout.__index = DigtronLayout
local get_node_image = function(pos, node) local get_node_image = function(pos, node)
local node_image = {node=node, pos={x=pos.x, y=pos.y, z=pos.z}} local node_image = {node=node, pos={x=pos.x, y=pos.y, z=pos.z}}
node_image.paramtype2 = minetest.registered_nodes[node.name].paramtype2 local node_def = minetest.registered_nodes[node.name]
node_image.paramtype2 = node_def.paramtype2
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
node_image.meta = meta:to_table() node_image.meta = meta:to_table()
if node_image.meta ~= nil then
node_image.meta.fields.formspec = node_def._digtron_formspec -- causes formspec to be automatically upgraded whenever Digtron moves
end
-- Record what kind of thing we've got in a builder node so its facing can be rotated properly -- Record what kind of thing we've got in a builder node so its facing can be rotated properly
if minetest.get_item_group(node.name, "digtron") == 4 then if minetest.get_item_group(node.name, "digtron") == 4 then
@ -86,7 +90,7 @@ function DigtronLayout.create(pos, player)
self.water_touching = true self.water_touching = true
elseif minetest.get_item_group(node.name, "lava") ~= 0 then elseif minetest.get_item_group(node.name, "lava") ~= 0 then
self.lava_touching = true self.lava_touching = true
if digtron.lava_impassible == true then if digtron.config.lava_impassible then
self.protected:set(testpos.x, testpos.y, testpos.z, true) self.protected:set(testpos.x, testpos.y, testpos.z, true)
end end
end end

@ -1,44 +1,40 @@
local CONFIG_FILE_PREFIX = "digtron_"
digtron.config = {}
local print_settingtypes = false
local function setting(stype, name, default, description)
local value
if stype == "bool" then
value = minetest.setting_getbool(CONFIG_FILE_PREFIX..name)
elseif stype == "string" then
value = minetest.setting_get(CONFIG_FILE_PREFIX..name)
elseif stype == "int" or stype == "float" then
value = tonumber(minetest.setting_get(CONFIG_FILE_PREFIX..name))
end
if value == nil then
value = default
end
digtron.config[name] = value
if print_settingtypes then
minetest.debug(CONFIG_FILE_PREFIX..name.." ("..description..") "..stype.." "..tostring(default))
end
end
setting("bool", "uses_resources", true, "Digtron uses resources when active")
setting("bool", "lava_impassible", true, "Lava counts as a protected node")
setting("bool", "damage_creatures", true, "Diggers damage creatures")
-- Enables the spray of particles out the back of a digger head and puffs of smoke from the controller -- Enables the spray of particles out the back of a digger head and puffs of smoke from the controller
local particle_effects = minetest.settings:get_bool("enable_particles") local particle_effects = minetest.settings:get_bool("enable_particles")
digtron.config.particle_effects = particle_effects or particle_effects == nil -- default true
-- this causes digtrons to operate without consuming fuel or building materials.
local digtron_uses_resources = minetest.settings:get_bool("digtron_uses_resources")
if digtron_uses_resources == nil then digtron_uses_resources = true end
-- when true, lava counts as protected nodes. setting("int", "maximum_extrusion", 25, "Maximum builder extrusion distance")
local lava_impassible = minetest.settings:get_bool("digtron_lava_impassible") setting("float", "cycle_time", 1.0, "Minimum Digtron cycle time")
setting("float", "traction_factor", 3.0, "Traction factor")
-- when true, diggers deal damage to creatures when they trigger.
local damage_creatures = minetest.settings:get_bool("digtron_damage_creatures")
digtron.creative_mode = not digtron_uses_resources -- default false
digtron.particle_effects = particle_effects or particle_effects == nil -- default true
digtron.lava_impassible = lava_impassible or lava_impassible == nil -- default true
digtron.diggers_damage_creatures = damage_creatures or damage_creatures == nil -- default true
-- maximum distance a builder head can extrude blocks
local maximum_extrusion = tonumber(minetest.settings:get("digtron_maximum_extrusion"))
if maximum_extrusion == nil or maximum_extrusion < 1 or maximum_extrusion > 100 then
digtron.maximum_extrusion = 25
else
digtron.maximum_extrusion = maximum_extrusion
end
-- How many seconds a digtron waits between cycles. Auto-controllers can make this wait longer, but cannot make it shorter.
local digtron_cycle_time = tonumber(minetest.settings:get("digtron_cycle_time"))
if digtron_cycle_time == nil or digtron_cycle_time < 0 then
digtron.cycle_time = 1.0
else
digtron.cycle_time = digtron_cycle_time
end
-- How many digtron nodes can be moved for each adjacent solid node that the digtron has traction against
local digtron_traction_factor = tonumber(minetest.settings:get("digtron_traction_factor"))
if digtron_traction_factor == nil or digtron_traction_factor < 0 then
digtron.traction_factor = 3.0
else
digtron.traction_factor = digtron_traction_factor
end
-- fuel costs. For comparison, in the default game: -- fuel costs. For comparison, in the default game:
-- one default tree block is 30 units -- one default tree block is 30 units
@ -47,37 +43,12 @@ end
-- one book is 3 units -- one book is 3 units
-- how much fuel is required to dig a node if not in one of the following groups. -- how much fuel is required to dig a node if not in one of the following groups.
local digtron_dig_cost_default = tonumber(minetest.settings:get("digtron_dig_cost_default")) setting("float", "dig_cost_default", 3.0, "Default dig cost")
if digtron_dig_cost_default == nil or digtron_dig_cost_default < 0 then
digtron.dig_cost_default = 0.5
else
digtron.dig_cost_default = digtron_dig_cost_default
end
-- eg, stone -- eg, stone
local digtron_dig_cost_cracky = tonumber(minetest.settings:get("digtron_dig_cost_cracky")) setting("float", "dig_cost_cracky", 1.0, "Cracky dig cost")
if digtron_dig_cost_cracky == nil or digtron_dig_cost_cracky < 0 then
digtron.dig_cost_cracky = 1.0
else
digtron.dig_cost_cracky = digtron_dig_cost_cracky
end
-- eg, dirt, sand -- eg, dirt, sand
local digtron_dig_cost_crumbly = tonumber(minetest.settings:get("digtron_dig_cost_crumbly")) setting("float", "dig_cost_crumbly", 0.5, "Crumbly dig cost")
if digtron_dig_cost_crumbly == nil or digtron_dig_cost_crumbly < 0 then
digtron.dig_cost_crumbly = 0.5
else
digtron.dig_cost_crumbly = digtron_dig_cost_crumbly
end
-- eg, wood -- eg, wood
local digtron_dig_cost_choppy = tonumber(minetest.settings:get("digtron_dig_cost_choppy")) setting("float", "dig_cost_choppy", 0.75, "Choppy dig cost")
if digtron_dig_cost_choppy == nil or digtron_dig_cost_choppy < 0 then
digtron.dig_cost_choppy = 0.75
else
digtron.dig_cost_choppy = digtron_dig_cost_choppy
end
-- how much fuel is required to build a node -- how much fuel is required to build a node
local digtron_build_cost = tonumber(minetest.settings:get("digtron_build_cost")) setting("float", "build_cost", 1.0, "Build cost")
if digtron_build_cost == nil or digtron_build_cost < 0 then
digtron.build_cost = 1.0
else
digtron.build_cost = digtron_build_cost
end

159
init.lua

@ -4,21 +4,41 @@ digtron.auto_controller_colorize = "#88000030"
digtron.pusher_controller_colorize = "#00880030" digtron.pusher_controller_colorize = "#00880030"
digtron.soft_digger_colorize = "#88880030" digtron.soft_digger_colorize = "#88880030"
dofile( minetest.get_modpath( "digtron" ) .. "/config.lua" ) -- A global dictionary is used here so that other substitutions can be added easily by other mods, if necessary
dofile( minetest.get_modpath( "digtron" ) .. "/util.lua" ) digtron.builder_read_item_substitutions = {
dofile( minetest.get_modpath( "digtron" ) .. "/doc.lua" ) ["default:torch_ceiling"] = "default:torch",
dofile( minetest.get_modpath( "digtron" ) .. "/awards.lua" ) ["default:torch_wall"] = "default:torch",
dofile( minetest.get_modpath( "digtron" ) .. "/class_pointset.lua" ) ["default:dirt_with_grass"] = "default:dirt",
dofile( minetest.get_modpath( "digtron" ) .. "/class_layout.lua" ) ["default:dirt_with_grass_footsteps"] = "default:dirt",
dofile( minetest.get_modpath( "digtron" ) .. "/entities.lua" ) ["default:dirt_with_dry_grass"] = "default:dirt",
dofile( minetest.get_modpath( "digtron" ) .. "/node_misc.lua" ) -- contains structure and light nodes ["default:dirt_with_rainforest_litter"] = "default:dirt",
dofile( minetest.get_modpath( "digtron" ) .. "/node_storage.lua" ) -- contains inventory and fuel storage nodes ["default:dirt_with_snow"] = "default:dirt",
dofile( minetest.get_modpath( "digtron" ) .. "/node_diggers.lua" ) -- contains all diggers ["default:furnace_active"] = "default:furnace",
dofile( minetest.get_modpath( "digtron" ) .. "/node_builders.lua" ) -- contains all builders (there's just one currently) ["farming:soil"] = "default:dirt",
dofile( minetest.get_modpath( "digtron" ) .. "/node_controllers.lua" ) -- controllers ["farming:soil_wet"] = "default:dirt",
dofile( minetest.get_modpath( "digtron" ) .. "/node_axle.lua" ) -- Rotation controller ["farming:desert_sand_soil"] = "default:desert_sand",
dofile( minetest.get_modpath( "digtron" ) .. "/node_crate.lua" ) -- Digtron portability support ["farming:desert_sand_soil_wet"] = "default:desert_sand",
dofile( minetest.get_modpath( "digtron" ) .. "/recipes.lua" ) }
local digtron_modpath = minetest.get_modpath( "digtron" )
dofile( digtron_modpath .. "/config.lua" )
dofile( digtron_modpath .. "/util.lua" )
dofile( digtron_modpath .. "/doc.lua" )
dofile( digtron_modpath .. "/awards.lua" )
dofile( digtron_modpath .. "/class_pointset.lua" )
dofile( digtron_modpath .. "/class_layout.lua" )
dofile( digtron_modpath .. "/entities.lua" )
dofile( digtron_modpath .. "/nodes/node_misc.lua" ) -- contains structure and light nodes
dofile( digtron_modpath .. "/nodes/node_storage.lua" ) -- contains inventory and fuel storage nodes
dofile( digtron_modpath .. "/nodes/node_diggers.lua" ) -- contains all diggers
dofile( digtron_modpath .. "/nodes/node_builders.lua" ) -- contains all builders (there's just one currently)
dofile( digtron_modpath .. "/nodes/node_controllers.lua" ) -- controllers
dofile( digtron_modpath .. "/nodes/node_axle.lua" ) -- Rotation controller
dofile( digtron_modpath .. "/nodes/node_crate.lua" ) -- Digtron portability support
dofile( digtron_modpath .. "/nodes/recipes.lua" )
dofile( digtron_modpath .. "/upgrades.lua" ) -- various LBMs for upgrading older versions of Digtron.
-- digtron group numbers: -- digtron group numbers:
-- 1 - generic digtron node, nothing special is done with these. They're just dragged along. -- 1 - generic digtron node, nothing special is done with these. They're just dragged along.
@ -28,113 +48,8 @@ dofile( minetest.get_modpath( "digtron" ) .. "/recipes.lua" )
-- 5 - fuel-holding digtron, has a "fuel" invetory that the control node can draw fuel items from. Separate from general inventory, nothing gets put here automatically. -- 5 - fuel-holding digtron, has a "fuel" invetory that the control node can draw fuel items from. Separate from general inventory, nothing gets put here automatically.
-- 6 - holds both fuel and main inventories -- 6 - holds both fuel and main inventories
minetest.register_lbm({ -- This code was added for use with FaceDeer's fork of the [catacomb] mod. Paramat's version doesn't support customized protected nodes, which causes
name = "digtron:sand_digger_upgrade", -- it to "eat" Digtrons sometimes.
nodenames = {"digtron:sand_digger"},
action = function(pos, node)
local meta = minetest.get_meta(pos)
local offset = meta:get_string("offset")
local period = meta:get_string("period")
minetest.set_node(pos, {name = "digtron:soft_digger",
param2 = node.param2})
meta:set_string("offset", offset)
meta:set_string("period", period)
end
})
minetest.register_lbm({
name = "digtron:fuelstore_upgrade",
nodenames = {"digtron:fuelstore"},
action = function(pos, node)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local list = inv:get_list("main")
inv:set_list("main", {})
inv:set_list("fuel", list)
meta:set_string("formspec",
"size[8,9.3]" ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"label[0,0;Fuel items]" ..
"list[current_name;fuel;0,0.6;8,4;]" ..
"list[current_player;main;0,5.15;8,1;]" ..
"list[current_player;main;0,6.38;8,3;8]" ..
"listring[current_name;fuel]" ..
"listring[current_player;main]" ..
default.get_hotbar_bg(0,5.15)
)
end
})
minetest.register_lbm({
name = "digtron:autocontroller_lateral_upgrade",
nodenames = {"digtron:auto_controller"},
action = function(pos, node)
local meta = minetest.get_meta(pos)
local cycles = meta:get_int("offset")
meta:set_int("cycles", cycles)
meta:set_int("offset", 0)
meta:set_int("slope", 0)
meta:set_string("formspec",
"size[3.5,2]" ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"field[0.5,0.8;1,0.1;cycles;Cycles;${cycles}]" ..
"tooltip[cycles;When triggered, this controller will try to run for the given number of cycles.\nThe cycle count will decrement as it runs, so if it gets halted by a problem\nyou can fix the problem and restart.]" ..
"button_exit[1.2,0.5;1,0.1;set;Set]" ..
"tooltip[set;Saves the cycle setting without starting the controller running]" ..
"button_exit[2.2,0.5;1,0.1;execute;Set &\nExecute]" ..
"tooltip[execute;Begins executing the given number of cycles]" ..
"field[0.5,2.0;1,0.1;slope;Slope;${slope}]" ..
"tooltip[slope;For diagonal digging. After every X nodes the auto controller moves forward,\nthe controller will add an additional cycle moving the digtron laterally in the\ndirection of the arrows on the side of this controller.\nSet to 0 for no lateral digging.]" ..
"field[1.5,2.0;1,0.1;offset;Offset;${offset}]" ..
"tooltip[offset;Sets the offset of the lateral motion defined in the Slope field.\nNote: this offset is relative to the controller's location.\nThe controller will move down when it reaches the indicated point.]" ..
"field[2.5,2.0;1,0.1;period;Delay;${period}]" ..
"tooltip[period;Number of seconds to wait between each cycle]"
)
end
})
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
minetest.register_lbm({
name = "digtron:builder_extrusion_upgrade",
nodenames = {"digtron:builder"},
action = function(pos, node)
local meta = minetest.get_meta(pos)
meta:set_int("extrusion", 1)
meta:set_string("formspec",
"size[8,5.2]" ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"list[current_name;main;0.5,0;1,1;]" ..
"label[0.5,0.8;" .. S("Block to build") .. "]" ..
"field[2.3,0.8;1,0.1;extrusion;" .. S("Extrusion") .. ";${extrusion}]" ..
"tooltip[extrusion;" .. S("Builder will extrude this many blocks in the direction it is facing.\nCan be set from 1 to @1.\nNote that Digtron won't build into unloaded map regions.", digtron.maximum_extrusion) .. "]" ..
"field[3.3,0.8;1,0.1;period;" .. S("Periodicity") .. ";${period}]" ..
"tooltip[period;" .. S("Builder will build once every n steps.\nThese steps are globally aligned, so all builders with the\nsame period and offset will build on the same location.") .. "]" ..
"field[4.3,0.8;1,0.1;offset;" .. S("Offset") .. ";${offset}]" ..
"tooltip[offset;" .. S("Offsets the start of periodicity counting by this amount.\nFor example, a builder with period 2 and offset 0 builds\nevery even-numbered block and one with period 2 and\noffset 1 builds every odd-numbered block.") .. "]" ..
"button_exit[5.0,0.5;1,0.1;set;" .. S("Save &\nShow") .. "]" ..
"tooltip[set;" .. S("Saves settings") .. "]" ..
"field[6.3,0.8;1,0.1;build_facing;" .. S("Facing") .. ";${build_facing}]" ..
"tooltip[build_facing;" .. S("Value from 0-23. Not all block types make use of this.\nUse the 'Read & Save' button to copy the facing of the block\ncurrently in the builder output location.") .. "]" ..
"button_exit[7.0,0.5;1,0.1;read;" .. S("Read &\nSave") .. "]" ..
"tooltip[read;" .. S("Reads the facing of the block currently in the build location,\nthen saves all settings.") .. "]" ..
"list[current_player;main;0,1.3;8,1;]" ..
default.get_hotbar_bg(0,1.3) ..
"list[current_player;main;0,2.5;8,3;8]" ..
"listring[current_player;main]" ..
"listring[current_name;main]"
)
end
})
if minetest.get_modpath("catacomb") and catacomb ~= nil and catacomb.chamber_protected_nodes ~= nil and catacomb.passage_protected_nodes ~= nil then if minetest.get_modpath("catacomb") and catacomb ~= nil and catacomb.chamber_protected_nodes ~= nil and catacomb.passage_protected_nodes ~= nil then
local digtron_nodes = { local digtron_nodes = {
minetest.get_content_id("digtron:inventory"), minetest.get_content_id("digtron:inventory"),

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-09-10 19:05-0600\n" "POT-Creation-Date: 2017-09-19 23:37-0600\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -890,380 +890,30 @@ msgid ""
"pass through the structure as it's being built." "pass through the structure as it's being built."
msgstr "" msgstr ""
#: node_axle.lua:6
msgid "Digtron Rotation Axle"
msgstr ""
#: node_axle.lua:57
#: util_execute_cycle.lua:172
#: util_execute_cycle.lua:367
#: util_execute_cycle.lua:456
msgid "Digtron is obstructed."
msgstr ""
#: node_builders.lua:13
msgid "Block to build"
msgstr ""
#: node_builders.lua:14
msgid "Extrusion"
msgstr ""
#: node_builders.lua:15
msgid ""
"Builder will extrude this many blocks in the direction it is facing.\n"
"Can be set from 1 to @1.\n"
"Note that Digtron won't build into unloaded map regions."
msgstr ""
#: node_builders.lua:16
#: node_diggers.lua:32
msgid "Periodicity"
msgstr ""
#: node_builders.lua:17
msgid ""
"Builder will build once every n steps.\n"
"These steps are globally aligned, so all builders with the\n"
"same period and offset will build on the same location."
msgstr ""
#: node_builders.lua:18
#: node_controllers.lua:91
#: node_diggers.lua:34
msgid "Offset"
msgstr ""
#: node_builders.lua:19
msgid ""
"Offsets the start of periodicity counting by this amount.\n"
"For example, a builder with period 2 and offset 0 builds\n"
"every even-numbered block and one with period 2 and\n"
"offset 1 builds every odd-numbered block."
msgstr ""
#: node_builders.lua:20
msgid ""
"Save &\n"
"Show"
msgstr ""
#: node_builders.lua:21
#: node_diggers.lua:37
msgid "Saves settings"
msgstr ""
#: node_builders.lua:22
msgid "Facing"
msgstr ""
#: node_builders.lua:23
msgid ""
"Value from 0-23. Not all block types make use of this.\n"
"Use the 'Read & Save' button to copy the facing of the block\n"
"currently in the builder output location."
msgstr ""
#: node_builders.lua:24
msgid ""
"Read &\n"
"Save"
msgstr ""
#: node_builders.lua:25
msgid ""
"Reads the facing of the block currently in the build location,\n"
"then saves all settings."
msgstr ""
#: node_builders.lua:34
#: node_controllers.lua:106
#: node_crate.lua:62
#: node_diggers.lua:43
msgid "Help"
msgstr ""
#: node_builders.lua:35
#: node_controllers.lua:107
#: node_crate.lua:63
#: node_diggers.lua:44
msgid "Show documentation about this block"
msgstr ""
#: node_builders.lua:40
msgid "Digtron Builder Module"
msgstr ""
#: node_builders.lua:279
#: node_builders.lua:294
#, lua-format
msgid "%s uses Digtron to build %s at (%d, %d, %d), displacing %s"
msgstr ""
#: node_controllers.lua:20
msgid "Digtron Control Module"
msgstr ""
#: node_controllers.lua:48
#: node_controllers.lua:200
#: util_execute_cycle.lua:110
#: util_execute_cycle.lua:317
#: util_execute_cycle.lua:394
#: util_execute_cycle.lua:505
#, lua-format
msgid "Heat remaining in controller furnace: %d"
msgstr ""
#: node_controllers.lua:83
msgid "Cycles"
msgstr ""
#: node_controllers.lua:84
msgid ""
"When triggered, this controller will try to run for the given number of "
"cycles.\n"
"The cycle count will decrement as it runs, so if it gets halted by a "
"problem\n"
"you can fix the problem and restart."
msgstr ""
#: node_controllers.lua:85
msgid "Set"
msgstr ""
#: node_controllers.lua:86
msgid "Saves the cycle setting without starting the controller running"
msgstr ""
#: node_controllers.lua:87
msgid ""
"Set &\n"
"Execute"
msgstr ""
#: node_controllers.lua:88
msgid "Begins executing the given number of cycles"
msgstr ""
#: node_controllers.lua:89
msgid "Slope"
msgstr ""
#: node_controllers.lua:90
msgid ""
"For diagonal digging. After moving forward this number of nodes the auto "
"controller\n"
"will add an additional cycle moving the digtron laterally in the\n"
"direction of the arrows on the side of this controller.\n"
"Set to 0 for no lateral digging."
msgstr ""
#: node_controllers.lua:92
msgid ""
"Sets the offset of the lateral motion defined in the Slope field.\n"
"Note: this offset is relative to the controller's location.\n"
"The controller will move laterally when it reaches the indicated point."
msgstr ""
#: node_controllers.lua:93
msgid "Delay"
msgstr ""
#: node_controllers.lua:94
msgid "Number of seconds to wait between each cycle"
msgstr ""
#: node_controllers.lua:96
msgid "Stop block"
msgstr ""
#: node_controllers.lua:128
#: node_controllers.lua:147
#: node_controllers.lua:160
#, lua-format
msgid "Cycles remaining: %d"
msgstr ""
#: node_controllers.lua:128
#: node_controllers.lua:147
msgid "Halted!"
msgstr ""
#: node_controllers.lua:172
msgid "Digtron Automatic Control Module"
msgstr ""
#: node_controllers.lua:284
msgid "Interrupted!"
msgstr ""
#: node_controllers.lua:300
msgid "Digtron Pusher Module"
msgstr ""
#: node_crate.lua:6
msgid "Digtron Crate (Empty)"
msgstr ""
#: node_crate.lua:22
msgid "Digtron can't be packaged, it contains protected blocks"
msgstr ""
#: node_crate.lua:42
#: node_crate.lua:43
msgid "Crated Digtron"
msgstr ""
#: node_crate.lua:55
#: node_crate.lua:70
msgid "Digtron Name"
msgstr ""
#: node_crate.lua:56
#: node_crate.lua:71
msgid ""
"Save\n"
"Title"
msgstr ""
#: node_crate.lua:57
#: node_crate.lua:72
msgid "Saves the title of this Digtron"
msgstr ""
#: node_crate.lua:58
#: node_crate.lua:73
msgid ""
"Show\n"
"Blocks"
msgstr ""
#: node_crate.lua:59
#: node_crate.lua:74
msgid "Shows which blocks the packed Digtron will occupy if unpacked"
msgstr ""
#: node_crate.lua:60
#: node_crate.lua:75
msgid "Unpack"
msgstr ""
#: node_crate.lua:61
#: node_crate.lua:76
msgid "Attempts to unpack the Digtron on this location"
msgstr ""
#: node_crate.lua:80
msgid "Digtron Crate (Loaded)"
msgstr ""
#: node_crate.lua:114
msgid ""
"Unable to read layout from crate metadata, regrettably this Digtron may be "
"corrupted or lost."
msgstr ""
#: node_crate.lua:145
msgid "Unable to deploy Digtron due to protected blocks in target area"
msgstr ""
#: node_crate.lua:151
msgid "Unable to deploy Digtron due to obstruction in target area"
msgstr ""
#: node_diggers.lua:33
msgid ""
"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."
msgstr ""
#: node_diggers.lua:35
msgid ""
"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."
msgstr ""
#: node_diggers.lua:36
msgid "Save"
msgstr ""
#: node_diggers.lua:72
msgid "Digtron Digger Head"
msgstr ""
#: node_diggers.lua:125
msgid "Digtron Intermittent Digger Head"
msgstr ""
#: node_diggers.lua:195
msgid "Digtron Soft Material Digger Head"
msgstr ""
#: node_diggers.lua:250
msgid "Digtron Intermittent Soft Material Digger Head"
msgstr ""
#: node_diggers.lua:323
msgid "Digtron Dual Digger Head"
msgstr ""
#: node_diggers.lua:400
msgid "Digtron Dual Soft Material Digger Head"
msgstr ""
#: node_misc.lua:7
msgid "Digtron Structure"
msgstr ""
#: node_misc.lua:40
msgid "Digtron Light"
msgstr ""
#: node_misc.lua:62
msgid "Digtron Panel"
msgstr ""
#: node_misc.lua:85
msgid "Digtron Edge Panel"
msgstr ""
#: node_misc.lua:114
msgid "Digtron Corner Panel"
msgstr ""
#: node_storage.lua:8
msgid "Digtron Inventory Storage"
msgstr ""
#: node_storage.lua:34
#: node_storage.lua:187
msgid "Inventory items"
msgstr ""
#: node_storage.lua:77
msgid "Digtron Fuel Storage"
msgstr ""
#: node_storage.lua:103
#: node_storage.lua:189
msgid "Fuel items"
msgstr ""
#: node_storage.lua:163
msgid "Digtron Combined Storage"
msgstr ""
#: recipes.lua:6
msgid "Digtron Core"
msgstr ""
#: util_execute_cycle.lua:51 #: util_execute_cycle.lua:51
msgid "Digtron is adjacent to unloaded nodes." msgid "Digtron is adjacent to unloaded nodes."
msgstr "" msgstr ""
#: util_execute_cycle.lua:65
msgid "Digtron has @1 blocks but only enough traction to move @2 blocks.\n"
msgstr ""
#: util_execute_cycle.lua:110
#: util_execute_cycle.lua:316
#: util_execute_cycle.lua:393
#: util_execute_cycle.lua:504
#: nodes\node_controllers.lua:48
#: nodes\node_controllers.lua:201
msgid "Heat remaining in controller furnace: @1"
msgstr ""
#: util_execute_cycle.lua:172
#: util_execute_cycle.lua:366
#: util_execute_cycle.lua:455
#: nodes\node_axle.lua:57
msgid "Digtron is obstructed."
msgstr ""
#: util_execute_cycle.lua:220 #: util_execute_cycle.lua:220
msgid "Digtron needs more fuel." msgid "Digtron needs more fuel."
msgstr "" msgstr ""
@ -1274,18 +924,354 @@ msgid ""
msgstr "" msgstr ""
#: util_execute_cycle.lua:234 #: util_execute_cycle.lua:234
#, lua-format msgid "Digtron has insufficient building materials. Needed: @1"
msgid "Digtron has insufficient building materials. Needed: %s"
msgstr "" msgstr ""
#: util_execute_cycle.lua:304 #: util_execute_cycle.lua:303
msgid "" msgid ""
"Digtron unexpectedly failed to execute one or more build operations, likely " "Digtron unexpectedly failed to execute one or more build operations, likely "
"due to an inventory error." "due to an inventory error."
msgstr "" msgstr ""
#: util_execute_cycle.lua:329 #: nodes\node_axle.lua:6
#: util_execute_cycle.lua:517 msgid "Digtron Rotation Axle"
#, lua-format msgstr ""
msgid "%s uses Digtron to dig %s at (%d, %d, %d)"
#: nodes\node_builders.lua:18
msgid "Block to build"
msgstr ""
#: nodes\node_builders.lua:19
msgid "Extrusion"
msgstr ""
#: nodes\node_builders.lua:20
msgid ""
"Builder will extrude this many blocks in the direction it is facing.\n"
"Can be set from 1 to @1.\n"
"Note that Digtron won't build into unloaded map regions."
msgstr ""
#: nodes\node_builders.lua:21
#: nodes\node_diggers.lua:32
msgid "Periodicity"
msgstr ""
#: nodes\node_builders.lua:22
msgid ""
"Builder will build once every n steps.\n"
"These steps are globally aligned, so all builders with the\n"
"same period and offset will build on the same location."
msgstr ""
#: nodes\node_builders.lua:23
#: nodes\node_controllers.lua:91
#: nodes\node_diggers.lua:34
msgid "Offset"
msgstr ""
#: nodes\node_builders.lua:24
msgid ""
"Offsets the start of periodicity counting by this amount.\n"
"For example, a builder with period 2 and offset 0 builds\n"
"every even-numbered block and one with period 2 and\n"
"offset 1 builds every odd-numbered block."
msgstr ""
#: nodes\node_builders.lua:25
#: nodes\node_diggers.lua:36
msgid ""
"Save &\n"
"Show"
msgstr ""
#: nodes\node_builders.lua:26
#: nodes\node_diggers.lua:37
msgid "Saves settings"
msgstr ""
#: nodes\node_builders.lua:27
msgid "Facing"
msgstr ""
#: nodes\node_builders.lua:28
msgid ""
"Value from 0-23. Not all block types make use of this.\n"
"Use the 'Read & Save' button to copy the facing of the block\n"
"currently in the builder output location."
msgstr ""
#: nodes\node_builders.lua:29
msgid ""
"Read &\n"
"Save"
msgstr ""
#: nodes\node_builders.lua:30
msgid ""
"Reads the facing of the block currently in the build location,\n"
"then saves all settings."
msgstr ""
#: nodes\node_builders.lua:39
#: nodes\node_controllers.lua:106
#: nodes\node_crate.lua:62
#: nodes\node_diggers.lua:41
msgid "Help"
msgstr ""
#: nodes\node_builders.lua:40
#: nodes\node_controllers.lua:107
#: nodes\node_crate.lua:63
#: nodes\node_diggers.lua:42
msgid "Show documentation about this block"
msgstr ""
#: nodes\node_builders.lua:45
msgid "Digtron Builder Module"
msgstr ""
#: nodes\node_controllers.lua:20
msgid "Digtron Control Module"
msgstr ""
#: nodes\node_controllers.lua:83
msgid "Cycles"
msgstr ""
#: nodes\node_controllers.lua:84
msgid ""
"When triggered, this controller will try to run for the given number of "
"cycles.\n"
"The cycle count will decrement as it runs, so if it gets halted by a "
"problem\n"
"you can fix the problem and restart."
msgstr ""
#: nodes\node_controllers.lua:85
msgid "Set"
msgstr ""
#: nodes\node_controllers.lua:86
msgid "Saves the cycle setting without starting the controller running"
msgstr ""
#: nodes\node_controllers.lua:87
msgid ""
"Set &\n"
"Execute"
msgstr ""
#: nodes\node_controllers.lua:88
msgid "Begins executing the given number of cycles"
msgstr ""
#: nodes\node_controllers.lua:89
msgid "Slope"
msgstr ""
#: nodes\node_controllers.lua:90
msgid ""
"For diagonal digging. After moving forward this number of nodes the auto "
"controller\n"
"will add an additional cycle moving the digtron laterally in the\n"
"direction of the arrows on the side of this controller.\n"
"Set to 0 for no lateral digging."
msgstr ""
#: nodes\node_controllers.lua:92
msgid ""
"Sets the offset of the lateral motion defined in the Slope field.\n"
"Note: this offset is relative to the controller's location.\n"
"The controller will move laterally when it reaches the indicated point."
msgstr ""
#: nodes\node_controllers.lua:93
msgid "Delay"
msgstr ""
#: nodes\node_controllers.lua:94
msgid "Number of seconds to wait between each cycle"
msgstr ""
#: nodes\node_controllers.lua:96
msgid "Stop block"
msgstr ""
#: nodes\node_controllers.lua:128
#: nodes\node_controllers.lua:147
#: nodes\node_controllers.lua:160
msgid "Cycles remaining: @1"
msgstr ""
#: nodes\node_controllers.lua:128
#: nodes\node_controllers.lua:147
msgid "Halted!"
msgstr ""
#: nodes\node_controllers.lua:172
msgid "Digtron Automatic Control Module"
msgstr ""
#: nodes\node_controllers.lua:285
msgid "Interrupted!"
msgstr ""
#: nodes\node_controllers.lua:300
msgid "Digtron Pusher Module"
msgstr ""
#: nodes\node_crate.lua:6
msgid "Digtron Crate (Empty)"
msgstr ""
#: nodes\node_crate.lua:22
msgid "Digtron can't be packaged, it contains protected blocks"
msgstr ""
#: nodes\node_crate.lua:42
#: nodes\node_crate.lua:43
msgid "Crated Digtron"
msgstr ""
#: nodes\node_crate.lua:55
#: nodes\node_crate.lua:70
msgid "Digtron Name"
msgstr ""
#: nodes\node_crate.lua:56
#: nodes\node_crate.lua:71
msgid ""
"Save\n"
"Title"
msgstr ""
#: nodes\node_crate.lua:57
#: nodes\node_crate.lua:72
msgid "Saves the title of this Digtron"
msgstr ""
#: nodes\node_crate.lua:58
#: nodes\node_crate.lua:73
msgid ""
"Show\n"
"Blocks"
msgstr ""
#: nodes\node_crate.lua:59
#: nodes\node_crate.lua:74
msgid "Shows which blocks the packed Digtron will occupy if unpacked"
msgstr ""
#: nodes\node_crate.lua:60
#: nodes\node_crate.lua:75
msgid "Unpack"
msgstr ""
#: nodes\node_crate.lua:61
#: nodes\node_crate.lua:76
msgid "Attempts to unpack the Digtron on this location"
msgstr ""
#: nodes\node_crate.lua:80
msgid "Digtron Crate (Loaded)"
msgstr ""
#: nodes\node_crate.lua:115
msgid ""
"Unable to read layout from crate metadata, regrettably this Digtron may be "
"corrupted or lost."
msgstr ""
#: nodes\node_crate.lua:146
msgid "Unable to deploy Digtron due to protected blocks in target area"
msgstr ""
#: nodes\node_crate.lua:152
msgid "Unable to deploy Digtron due to obstruction in target area"
msgstr ""
#: nodes\node_diggers.lua:33
msgid ""
"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."
msgstr ""
#: nodes\node_diggers.lua:35
msgid ""
"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."
msgstr ""
#: nodes\node_diggers.lua:75
msgid "Digtron Digger Head"
msgstr ""
#: nodes\node_diggers.lua:129
msgid "Digtron Intermittent Digger Head"
msgstr ""
#: nodes\node_diggers.lua:200
msgid "Digtron Soft Material Digger Head"
msgstr ""
#: nodes\node_diggers.lua:255
msgid "Digtron Intermittent Soft Material Digger Head"
msgstr ""
#: nodes\node_diggers.lua:329
msgid "Digtron Dual Digger Head"
msgstr ""
#: nodes\node_diggers.lua:406
msgid "Digtron Dual Soft Material Digger Head"
msgstr ""
#: nodes\node_misc.lua:7
msgid "Digtron Structure"
msgstr ""
#: nodes\node_misc.lua:40
msgid "Digtron Light"
msgstr ""
#: nodes\node_misc.lua:62
msgid "Digtron Panel"
msgstr ""
#: nodes\node_misc.lua:85
msgid "Digtron Edge Panel"
msgstr ""
#: nodes\node_misc.lua:114
msgid "Digtron Corner Panel"
msgstr ""
#: nodes\node_storage.lua:11
#: nodes\node_storage.lua:171
msgid "Inventory items"
msgstr ""
#: nodes\node_storage.lua:22
msgid "Digtron Inventory Storage"
msgstr ""
#: nodes\node_storage.lua:82
#: nodes\node_storage.lua:173
msgid "Fuel items"
msgstr ""
#: nodes\node_storage.lua:93
msgid "Digtron Fuel Storage"
msgstr ""
#: nodes\node_storage.lua:184
msgid "Digtron Combined Storage"
msgstr ""
#: nodes\recipes.lua:6
msgid "Digtron Core"
msgstr "" msgstr ""

@ -51,7 +51,7 @@ minetest.register_node("digtron:axle", {
meta = minetest.get_meta(pos) meta = minetest.get_meta(pos)
meta:set_string("waiting", "true") meta:set_string("waiting", "true")
meta:set_string("infotext", nil) meta:set_string("infotext", nil)
minetest.get_node_timer(pos):start(digtron.cycle_time*2) minetest.get_node_timer(pos):start(digtron.config.cycle_time*2)
else else
minetest.sound_play("buzzer", {gain=1.0, pos=pos}) minetest.sound_play("buzzer", {gain=1.0, pos=pos})
meta:set_string("infotext", S("Digtron is obstructed.")) meta:set_string("infotext", S("Digtron is obstructed."))

@ -4,58 +4,40 @@ local S, NS = dofile(MP.."/intllib.lua")
-- Note: builders go in group 4 and have both test_build and execute_build methods. -- Note: builders go in group 4 and have both test_build and execute_build methods.
local builder_formspec = nil local displace_due_to_help_button = 1.0
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
builder_formspec = "size[8,5.2]" .. displace_due_to_help_button = 0.0
end
local builder_formspec =
"size[8,5.2]" ..
default.gui_bg .. default.gui_bg ..
default.gui_bg_img .. default.gui_bg_img ..
default.gui_slots .. default.gui_slots ..
"list[current_name;main;0,0;1,1;]" .. "list[current_name;main;".. tostring(displace_due_to_help_button/2) ..",0;1,1;]" ..
"label[0,0.8;" .. S("Block to build") .. "]" .. "label[" .. tostring(displace_due_to_help_button/2).. ",0.8;" .. S("Block to build") .. "]" ..
"field[1.3,0.8;1,0.1;extrusion;" .. S("Extrusion") .. ";${extrusion}]" .. "field[" .. tostring(displace_due_to_help_button + 1.3) ..",0.8;1,0.1;extrusion;" .. S("Extrusion") .. ";${extrusion}]" ..
"tooltip[extrusion;" .. S("Builder will extrude this many blocks in the direction it is facing.\nCan be set from 1 to @1.\nNote that Digtron won't build into unloaded map regions.", digtron.maximum_extrusion) .. "]" .. "tooltip[extrusion;" .. S("Builder will extrude this many blocks in the direction it is facing.\nCan be set from 1 to @1.\nNote that Digtron won't build into unloaded map regions.", digtron.config.maximum_extrusion) .. "]" ..
"field[2.3,0.8;1,0.1;period;" .. S("Periodicity") .. ";${period}]" .. "field[" .. tostring(displace_due_to_help_button + 2.3) ..",0.8;1,0.1;period;" .. S("Periodicity") .. ";${period}]" ..
"tooltip[period;" .. S("Builder will build once every n steps.\nThese steps are globally aligned, so all builders with the\nsame period and offset will build on the same location.") .. "]" .. "tooltip[period;" .. S("Builder will build once every n steps.\nThese steps are globally aligned, so all builders with the\nsame period and offset will build on the same location.") .. "]" ..
"field[3.3,0.8;1,0.1;offset;" .. S("Offset") .. ";${offset}]" .. "field[" .. tostring(displace_due_to_help_button + 3.3) ..",0.8;1,0.1;offset;" .. S("Offset") .. ";${offset}]" ..
"tooltip[offset;" .. S("Offsets the start of periodicity counting by this amount.\nFor example, a builder with period 2 and offset 0 builds\nevery even-numbered block and one with period 2 and\noffset 1 builds every odd-numbered block.") .. "]" .. "tooltip[offset;" .. S("Offsets the start of periodicity counting by this amount.\nFor example, a builder with period 2 and offset 0 builds\nevery even-numbered block and one with period 2 and\noffset 1 builds every odd-numbered block.") .. "]" ..
"button_exit[4.0,0.5;1,0.1;set;" .. S("Save &\nShow") .. "]" .. "button_exit[" .. tostring(displace_due_to_help_button + 4.0) ..",0.5;1,0.1;set;" .. S("Save &\nShow") .. "]" ..
"tooltip[set;" .. S("Saves settings") .. "]" .. "tooltip[set;" .. S("Saves settings") .. "]" ..
"field[5.3,0.8;1,0.1;build_facing;" .. S("Facing") .. ";${build_facing}]" .. "field[" .. tostring(displace_due_to_help_button + 5.3) .. ",0.8;1,0.1;build_facing;" .. S("Facing") .. ";${build_facing}]" ..
"tooltip[build_facing;" .. S("Value from 0-23. Not all block types make use of this.\nUse the 'Read & Save' button to copy the facing of the block\ncurrently in the builder output location.") .. "]" .. "tooltip[build_facing;" .. S("Value from 0-23. Not all block types make use of this.\nUse the 'Read & Save' button to copy the facing of the block\ncurrently in the builder output location.") .. "]" ..
"button_exit[6.0,0.5;1,0.1;read;" .. S("Read &\nSave") .. "]" .. "button_exit[" .. tostring(displace_due_to_help_button + 6.0) ..",0.5;1,0.1;read;" .. S("Read &\nSave") .. "]" ..
"tooltip[read;" .. S("Reads the facing of the block currently in the build location,\nthen saves all settings.") .. "]" ..
"list[current_player;main;0,1.3;8,1;]" ..
default.get_hotbar_bg(0,1.3) ..
"list[current_player;main;0,2.5;8,3;8]" ..
"listring[current_player;main]" ..
"listring[current_name;main]" ..
"button_exit[7.0,0.5;1,0.1;help;" .. S("Help") .. "]" ..
"tooltip[help;" .. S("Show documentation about this block") .. "]"
else
builder_formspec = "size[8,5.2]" ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"list[current_name;main;0.5,0;1,1;]" ..
"label[0.5,0.8;" .. S("Block to build") .. "]" ..
"field[2.3,0.8;1,0.1;extrusion;" .. S("Extrusion") .. ";${extrusion}]" ..
"tooltip[extrusion;" .. S("Builder will extrude this many blocks in the direction it is facing.\nCan be set from 1 to @1.\nNote that Digtron won't build into unloaded map regions.", digtron.maximum_extrusion) .. "]" ..
"field[3.3,0.8;1,0.1;period;" .. S("Periodicity") .. ";${period}]" ..
"tooltip[period;" .. S("Builder will build once every n steps.\nThese steps are globally aligned, so all builders with the\nsame period and offset will build on the same location.") .. "]" ..
"field[4.3,0.8;1,0.1;offset;" .. S("Offset") .. ";${offset}]" ..
"tooltip[offset;" .. S("Offsets the start of periodicity counting by this amount.\nFor example, a builder with period 2 and offset 0 builds\nevery even-numbered block and one with period 2 and\noffset 1 builds every odd-numbered block.") .. "]" ..
"button_exit[5.0,0.5;1,0.1;set;" .. S("Save &\nShow") .. "]" ..
"tooltip[set;" .. S("Saves settings") .. "]" ..
"field[6.3,0.8;1,0.1;build_facing;" .. S("Facing") .. ";${build_facing}]" ..
"tooltip[build_facing;" .. S("Value from 0-23. Not all block types make use of this.\nUse the 'Read & Save' button to copy the facing of the block\ncurrently in the builder output location.") .. "]" ..
"button_exit[7.0,0.5;1,0.1;read;" .. S("Read &\nSave") .. "]" ..
"tooltip[read;" .. S("Reads the facing of the block currently in the build location,\nthen saves all settings.") .. "]" .. "tooltip[read;" .. S("Reads the facing of the block currently in the build location,\nthen saves all settings.") .. "]" ..
"list[current_player;main;0,1.3;8,1;]" .. "list[current_player;main;0,1.3;8,1;]" ..
default.get_hotbar_bg(0,1.3) .. default.get_hotbar_bg(0,1.3) ..
"list[current_player;main;0,2.5;8,3;8]" .. "list[current_player;main;0,2.5;8,3;8]" ..
"listring[current_player;main]" .. "listring[current_player;main]" ..
"listring[current_name;main]" "listring[current_name;main]"
if minetest.get_modpath("doc") then
builder_formspec = builder_formspec ..
"button_exit[7.0,0.5;1,0.1;help;" .. S("Help") .. "]" ..
"tooltip[help;" .. S("Show documentation about this block") .. "]"
end end
-- Builds objects in the targeted node. This is a complicated beastie. -- Builds objects in the targeted node. This is a complicated beastie.
@ -63,6 +45,7 @@ minetest.register_node("digtron:builder", {
description = S("Digtron Builder Module"), description = S("Digtron Builder Module"),
_doc_items_longdesc = digtron.doc.builder_longdesc, _doc_items_longdesc = digtron.doc.builder_longdesc,
_doc_items_usagehelp = digtron.doc.builder_usagehelp, _doc_items_usagehelp = digtron.doc.builder_usagehelp,
_digtron_formspec = builder_formspec,
groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 4}, groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 4},
drop = "digtron:builder", drop = "digtron:builder",
sounds = digtron.metal_sounds, sounds = digtron.metal_sounds,
@ -133,46 +116,26 @@ minetest.register_node("digtron:builder", {
-- Should prevent that somehow. But not tonight. -- Should prevent that somehow. But not tonight.
meta:set_int("build_facing", math.floor(build_facing)) meta:set_int("build_facing", math.floor(build_facing))
end end
if extrusion and extrusion > 0 and extrusion <= digtron.maximum_extrusion then if extrusion and extrusion > 0 and extrusion <= digtron.config.maximum_extrusion then
meta:set_int("extrusion", math.floor(tonumber(fields.extrusion))) meta:set_int("extrusion", math.floor(tonumber(fields.extrusion)))
else else
extrusion = meta:get_int("extrusion") extrusion = meta:get_int("extrusion")
end end
if fields.set then if fields.set then
local buildpos = digtron.find_new_pos(pos, minetest.get_node(pos).param2) digtron.show_offset_markers(pos, offset, period)
local x_pos = math.floor((buildpos.x+offset)/period)*period - offset
minetest.add_entity({x=x_pos, y=buildpos.y, z=buildpos.z}, "digtron:marker")
if x_pos >= buildpos.x then
minetest.add_entity({x=x_pos - period, y=buildpos.y, z=buildpos.z}, "digtron:marker")
end
if x_pos <= buildpos.x then
minetest.add_entity({x=x_pos + period, y=buildpos.y, z=buildpos.z}, "digtron:marker")
end
local y_pos = math.floor((buildpos.y+offset)/period)*period - offset
minetest.add_entity({x=buildpos.x, y=y_pos, z=buildpos.z}, "digtron:marker_vertical")
if y_pos >= buildpos.y then
minetest.add_entity({x=buildpos.x, y=y_pos - period, z=buildpos.z}, "digtron:marker_vertical")
end
if y_pos <= buildpos.y then
minetest.add_entity({x=buildpos.x, y=y_pos + period, z=buildpos.z}, "digtron:marker_vertical")
end
local z_pos = math.floor((buildpos.z+offset)/period)*period - offset
minetest.add_entity({x=buildpos.x, y=buildpos.y, z=z_pos}, "digtron:marker"):setyaw(1.5708)
if z_pos >= buildpos.z then
minetest.add_entity({x=buildpos.x, y=buildpos.y, z=z_pos - period}, "digtron:marker"):setyaw(1.5708)
end
if z_pos <= buildpos.z then
minetest.add_entity({x=buildpos.x, y=buildpos.y, z=z_pos + period}, "digtron:marker"):setyaw(1.5708)
end
elseif fields.read then elseif fields.read then
local meta = minetest.get_meta(pos)
local facing = minetest.get_node(pos).param2 local facing = minetest.get_node(pos).param2
local buildpos = digtron.find_new_pos(pos, facing) local buildpos = digtron.find_new_pos(pos, facing)
meta:set_int("build_facing", minetest.get_node(buildpos).param2) local target_node = minetest.get_node(buildpos)
if target_node.name ~= "air" and minetest.get_item_group(target_node.name, "digtron") == 0 then
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local target_name = digtron.builder_read_item_substitutions[target_node.name] or target_node.name
inv:set_stack("main", 1, target_name)
meta:set_int("build_facing", target_node.param2)
end
end end
if fields.help and minetest.get_modpath("doc") then --check for mod in case someone disabled it after this digger was built if fields.help and minetest.get_modpath("doc") then --check for mod in case someone disabled it after this digger was built
@ -296,10 +259,10 @@ minetest.register_node("digtron:builder", {
local oldnode = minetest.get_node(buildpos) local oldnode = minetest.get_node(buildpos)
if digtron.creative_mode then if not digtron.config.uses_resources then
local returned_stack, success = digtron.item_place_node(item_stack, player, buildpos, build_facing) local returned_stack, success = digtron.item_place_node(item_stack, player, buildpos, build_facing)
if success == true then if success == true then
minetest.log("action", string.format(S("%s uses Digtron to build %s at (%d, %d, %d), displacing %s"), player:get_player_name(), item_stack:get_name(), buildpos.x, buildpos.y, buildpos.z, oldnode.name)) minetest.log("action", string.format("%s uses Digtron to build %s at (%d, %d, %d), displacing %s", player:get_player_name(), item_stack:get_name(), buildpos.x, buildpos.y, buildpos.z, oldnode.name))
nodes_dug:set(buildpos.x, buildpos.y, buildpos.z, false) nodes_dug:set(buildpos.x, buildpos.y, buildpos.z, false)
built_count = built_count + 1 built_count = built_count + 1
else else
@ -314,7 +277,7 @@ minetest.register_node("digtron:builder", {
end end
local returned_stack, success = digtron.item_place_node(item_stack, player, buildpos, build_facing) local returned_stack, success = digtron.item_place_node(item_stack, player, buildpos, build_facing)
if success == true then if success == true then
minetest.log("action", string.format(S("%s uses Digtron to build %s at (%d, %d, %d), displacing %s"), player:get_player_name(), item_stack:get_name(), buildpos.x, buildpos.y, buildpos.z, oldnode.name)) minetest.log("action", string.format("%s uses Digtron to build %s at (%d, %d, %d), displacing %s", player:get_player_name(), item_stack:get_name(), buildpos.x, buildpos.y, buildpos.z, oldnode.name))
--flag this node as *not* to be dug. --flag this node as *not* to be dug.
nodes_dug:set(buildpos.x, buildpos.y, buildpos.z, false) nodes_dug:set(buildpos.x, buildpos.y, buildpos.z, false)
digtron.award_item_built(item_stack:get_name(), player:get_player_name()) digtron.award_item_built(item_stack:get_name(), player:get_player_name())

@ -45,7 +45,7 @@ minetest.register_node("digtron:controller", {
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_float("fuel_burning", 0.0) meta:set_float("fuel_burning", 0.0)
meta:set_string("infotext", string.format(S("Heat remaining in controller furnace: %d"), 0)) meta:set_string("infotext", S("Heat remaining in controller furnace: @1", 0))
end, end,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
@ -64,7 +64,7 @@ minetest.register_node("digtron:controller", {
-- Start the delay before digtron can run again. -- Start the delay before digtron can run again.
minetest.get_meta(newpos):set_string("waiting", "true") minetest.get_meta(newpos):set_string("waiting", "true")
minetest.get_node_timer(newpos):start(digtron.cycle_time) minetest.get_node_timer(newpos):start(digtron.config.cycle_time)
end, end,
on_timer = function(pos, elapsed) on_timer = function(pos, elapsed)
@ -125,7 +125,7 @@ digtron.auto_cycle = function(pos)
local newpos, status, return_code = digtron.execute_downward_dig_cycle(pos, player) local newpos, status, return_code = digtron.execute_downward_dig_cycle(pos, player)
if vector.equals(pos, newpos) then if vector.equals(pos, newpos) then
status = status .. string.format("\n" .. S("Cycles remaining: %d") .. "\n" .. S("Halted!"), cycle) status = status .. "\n" .. S("Cycles remaining: @1", cycle) .. "\n" .. S("Halted!")
meta:set_string("infotext", status) meta:set_string("infotext", status)
if return_code == 1 then --return code 1 happens when there's unloaded nodes adjacent, just keep trying. if return_code == 1 then --return code 1 happens when there's unloaded nodes adjacent, just keep trying.
minetest.after(meta:get_int("period"), digtron.auto_cycle, newpos) minetest.after(meta:get_int("period"), digtron.auto_cycle, newpos)
@ -144,7 +144,7 @@ digtron.auto_cycle = function(pos)
local newpos, status, return_code = digtron.execute_dig_cycle(pos, player) local newpos, status, return_code = digtron.execute_dig_cycle(pos, player)
if vector.equals(pos, newpos) then if vector.equals(pos, newpos) then
status = status .. string.format("\n" .. S("Cycles remaining: %d") .. "\n" .. S("Halted!"), cycle) status = status .. "\n" .. S("Cycles remaining: @1", cycle) .. "\n" .. S("Halted!")
meta:set_string("infotext", status) meta:set_string("infotext", status)
if return_code == 1 then --return code 1 happens when there's unloaded nodes adjacent, just keep trying. if return_code == 1 then --return code 1 happens when there's unloaded nodes adjacent, just keep trying.
minetest.after(meta:get_int("period"), digtron.auto_cycle, newpos) minetest.after(meta:get_int("period"), digtron.auto_cycle, newpos)
@ -157,7 +157,7 @@ digtron.auto_cycle = function(pos)
meta = minetest.get_meta(newpos) meta = minetest.get_meta(newpos)
cycle = meta:get_int("cycles") - 1 cycle = meta:get_int("cycles") - 1
meta:set_int("cycles", cycle) meta:set_int("cycles", cycle)
status = status .. string.format("\n" .. S("Cycles remaining: %d"), cycle) status = status .. "\n" .. S("Cycles remaining: @1", cycle)
meta:set_string("infotext", status) meta:set_string("infotext", status)
meta:set_string("lateral_done", nil) meta:set_string("lateral_done", nil)
@ -172,6 +172,7 @@ minetest.register_node("digtron:auto_controller", {
description = S("Digtron Automatic Control Module"), description = S("Digtron Automatic Control Module"),
_doc_items_longdesc = digtron.doc.auto_controller_longdesc, _doc_items_longdesc = digtron.doc.auto_controller_longdesc,
_doc_items_usagehelp = digtron.doc.auto_controller_usagehelp, _doc_items_usagehelp = digtron.doc.auto_controller_usagehelp,
_digtron_formspec = auto_formspec,
groups = {cracky = 3, oddly_breakable_by_hand = 3, digtron = 1}, groups = {cracky = 3, oddly_breakable_by_hand = 3, digtron = 1},
drop = "digtron:auto_controller", drop = "digtron:auto_controller",
sounds = digtron.metal_sounds, sounds = digtron.metal_sounds,
@ -197,10 +198,10 @@ minetest.register_node("digtron:auto_controller", {
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_float("fuel_burning", 0.0) meta:set_float("fuel_burning", 0.0)
meta:set_string("infotext", string.format(S("Heat remaining in controller furnace: %d"), 0)) meta:set_string("infotext", S("Heat remaining in controller furnace: @1", 0))
meta:set_string("formspec", auto_formspec) meta:set_string("formspec", auto_formspec)
-- Reusing offset and period to keep the digtron node-moving code simple, and the names still fit well -- Reusing offset and period to keep the digtron node-moving code simple, and the names still fit well
meta:set_int("period", digtron.cycle_time) meta:set_int("period", digtron.config.cycle_time)
meta:set_int("offset", 0) meta:set_int("offset", 0)
meta:set_int("cycles", 0) meta:set_int("cycles", 0)
meta:set_int("slope", 0) meta:set_int("slope", 0)
@ -232,7 +233,7 @@ minetest.register_node("digtron:auto_controller", {
local cycles = tonumber(fields.cycles) local cycles = tonumber(fields.cycles)
if period and period > 0 then if period and period > 0 then
meta:set_int("period", math.max(digtron.cycle_time, math.floor(period))) meta:set_int("period", math.max(digtron.config.cycle_time, math.floor(period)))
end end
if offset then if offset then
@ -289,7 +290,6 @@ minetest.register_node("digtron:auto_controller", {
on_timer = function(pos, elapsed) on_timer = function(pos, elapsed)
minetest.get_meta(pos):set_string("waiting", nil) minetest.get_meta(pos):set_string("waiting", nil)
end, end,
}) })
--------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------
@ -335,7 +335,7 @@ minetest.register_node("digtron:pusher", {
-- Start the delay before digtron can run again. -- Start the delay before digtron can run again.
minetest.get_meta(newpos):set_string("waiting", "true") minetest.get_meta(newpos):set_string("waiting", "true")
minetest.get_node_timer(newpos):start(digtron.cycle_time) minetest.get_node_timer(newpos):start(digtron.config.cycle_time)
end, end,
on_timer = function(pos, elapsed) on_timer = function(pos, elapsed)

@ -80,6 +80,7 @@ minetest.register_node("digtron:loaded_crate", {
description = S("Digtron Crate (Loaded)"), description = S("Digtron Crate (Loaded)"),
_doc_items_longdesc = digtron.doc.loaded_crate_longdesc, _doc_items_longdesc = digtron.doc.loaded_crate_longdesc,
_doc_items_usagehelp = digtron.doc.loaded_crate_usagehelp, _doc_items_usagehelp = digtron.doc.loaded_crate_usagehelp,
_digtron_formspec = loaded_formspec,
groups = {cracky = 3, oddly_breakable_by_hand=3, not_in_creative_inventory=1, digtron_protected=1}, groups = {cracky = 3, oddly_breakable_by_hand=3, not_in_creative_inventory=1, digtron_protected=1},
stack_max = 1, stack_max = 1,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),

@ -33,20 +33,20 @@ local intermittent_formspec =
"tooltip[period;" .. S("Digger will dig once every n steps.\nThese steps are globally aligned, all diggers with\nthe same period and offset will dig on the same location.") .. "]" .. "tooltip[period;" .. S("Digger will dig once every n steps.\nThese steps are globally aligned, all diggers with\nthe same period and offset will dig on the same location.") .. "]" ..
"field[1.5,0.8;1,0.1;offset;" .. S("Offset") .. ";${offset}]" .. "field[1.5,0.8;1,0.1;offset;" .. S("Offset") .. ";${offset}]" ..
"tooltip[offset;" .. S("Offsets the start of periodicity counting by this amount.\nFor example, a digger with period 2 and offset 0 digs\nevery even-numbered block and one with period 2 and\noffset 1 digs every odd-numbered block.") .. "]" .. "tooltip[offset;" .. S("Offsets the start of periodicity counting by this amount.\nFor example, a digger with period 2 and offset 0 digs\nevery even-numbered block and one with period 2 and\noffset 1 digs every odd-numbered block.") .. "]" ..
"button_exit[2.2,0.5;1,0.1;set;" .. S("Save") .. "]" .. "button_exit[2.2,0.5;1,0.1;set;" .. S("Save &\nShow") .. "]" ..
"tooltip[set;" .. S("Saves settings") .. "]" "tooltip[set;" .. S("Saves settings") .. "]"
local intermittent_on_construct = function(pos) if minetest.get_modpath("doc") then
local formspec = intermittent_formspec intermittent_formspec = "size[4.5,1]" .. intermittent_formspec ..
if minetest.get_modpath("doc") then
formspec = "size[4.5,1]" .. formspec ..
"button_exit[3.2,0.5;1,0.1;help;" .. S("Help") .. "]" .. "button_exit[3.2,0.5;1,0.1;help;" .. S("Help") .. "]" ..
"tooltip[help;" .. S("Show documentation about this block") .. "]" "tooltip[help;" .. S("Show documentation about this block") .. "]"
else else
formspec = "size[3.5,1]" .. formspec intermittent_formspec = "size[3.5,1]" .. intermittent_formspec
end end
local intermittent_on_construct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", formspec) meta:set_string("formspec", intermittent_formspec)
meta:set_int("period", 1) meta:set_int("period", 1)
meta:set_int("offset", 0) meta:set_int("offset", 0)
end end
@ -65,6 +65,9 @@ local intermittent_on_receive_fields = function(pos, formname, fields, sender)
local node_name = minetest.get_node(pos).name local node_name = minetest.get_node(pos).name
minetest.after(0.5, doc.show_entry, sender:get_player_name(), "nodes", node_name, true) minetest.after(0.5, doc.show_entry, sender:get_player_name(), "nodes", node_name, true)
end end
if fields.set then
digtron.show_offset_markers(pos, offset, period)
end
end, end,
-- Digs out nodes that are "in front" of the digger head. -- Digs out nodes that are "in front" of the digger head.
@ -72,6 +75,7 @@ minetest.register_node("digtron:digger", {
description = S("Digtron Digger Head"), description = S("Digtron Digger Head"),
_doc_items_longdesc = digtron.doc.digger_longdesc, _doc_items_longdesc = digtron.doc.digger_longdesc,
_doc_items_usagehelp = digtron.doc.digger_usagehelp, _doc_items_usagehelp = digtron.doc.digger_usagehelp,
_digtron_formspec = intermittent_formspec,
groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 3}, groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 3},
drop = "digtron:digger", drop = "digtron:digger",
sounds = digtron.metal_sounds, sounds = digtron.metal_sounds,
@ -125,6 +129,7 @@ minetest.register_node("digtron:intermittent_digger", {
description = S("Digtron Intermittent Digger Head"), description = S("Digtron Intermittent Digger Head"),
_doc_items_longdesc = digtron.doc.intermittent_digger_longdesc, _doc_items_longdesc = digtron.doc.intermittent_digger_longdesc,
_doc_items_usagehelp = digtron.doc.intermittent_digger_usagehelp, _doc_items_usagehelp = digtron.doc.intermittent_digger_usagehelp,
_digtron_formspec = intermittent_formspec,
groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 3}, groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 3},
drop = "digtron:intermittent_digger", drop = "digtron:intermittent_digger",
sounds = digtron.metal_sounds, sounds = digtron.metal_sounds,
@ -250,6 +255,7 @@ minetest.register_node("digtron:intermittent_soft_digger", {
description = S("Digtron Intermittent Soft Material Digger Head"), description = S("Digtron Intermittent Soft Material Digger Head"),
_doc_items_longdesc = digtron.doc.intermittent_soft_digger_longdesc, _doc_items_longdesc = digtron.doc.intermittent_soft_digger_longdesc,
_doc_items_usagehelp = digtron.doc.intermittent_soft_digger_usagehelp, _doc_items_usagehelp = digtron.doc.intermittent_soft_digger_usagehelp,
_digtron_formspec = intermittent_formspec,
groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 3}, groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 3},
drop = "digtron:intermittent_soft_digger", drop = "digtron:intermittent_soft_digger",
sounds = digtron.metal_sounds, sounds = digtron.metal_sounds,

@ -2,13 +2,28 @@
local MP = minetest.get_modpath(minetest.get_current_modname()) local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua") local S, NS = dofile(MP.."/intllib.lua")
local inventory_formspec =
"size[8,9.3]" ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"label[0,0;" .. S("Inventory items") .. "]" ..
"list[current_name;main;0,0.6;8,4;]" ..
"list[current_player;main;0,5.15;8,1;]" ..
"list[current_player;main;0,6.38;8,3;8]" ..
"listring[current_name;main]" ..
"listring[current_player;main]" ..
default.get_hotbar_bg(0,5.15)
-- Storage buffer. Builder nodes draw from this inventory and digger nodes deposit into it. -- Storage buffer. Builder nodes draw from this inventory and digger nodes deposit into it.
-- Note that inventories are digtron group 2. -- Note that inventories are digtron group 2.
minetest.register_node("digtron:inventory", { minetest.register_node("digtron:inventory", {
description = S("Digtron Inventory Storage"), description = S("Digtron Inventory Storage"),
_doc_items_longdesc = digtron.doc.inventory_longdesc, _doc_items_longdesc = digtron.doc.inventory_longdesc,
_doc_items_usagehelp = digtron.doc.inventory_usagehelp, _doc_items_usagehelp = digtron.doc.inventory_usagehelp,
groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 2, tubedevice = 1, tubedevice_receiver = 1}, _digtron_formspec = inventory_formspec,
groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 2, tubedevice = 1, tubedevice_receiver = 1},
drop = "digtron:inventory", drop = "digtron:inventory",
sounds = digtron.metal_sounds, sounds = digtron.metal_sounds,
paramtype2= "facedir", paramtype2= "facedir",
@ -26,19 +41,7 @@ minetest.register_node("digtron:inventory", {
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", meta:set_string("formspec", inventory_formspec)
"size[8,9.3]" ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"label[0,0;" .. S("Inventory items") .. "]" ..
"list[current_name;main;0,0.6;8,4;]" ..
"list[current_player;main;0,5.15;8,1;]" ..
"list[current_player;main;0,6.38;8,3;8]" ..
"listring[current_name;main]" ..
"listring[current_player;main]" ..
default.get_hotbar_bg(0,5.15)
)
local inv = meta:get_inventory() local inv = meta:get_inventory()
inv:set_size("main", 8*4) inv:set_size("main", 8*4)
end, end,
@ -71,12 +74,26 @@ minetest.register_node("digtron:inventory", {
after_dig_node = (function() if minetest.get_modpath("pipeworks") then return pipeworks.after_dig end end)() after_dig_node = (function() if minetest.get_modpath("pipeworks") then return pipeworks.after_dig end end)()
}) })
local fuelstore_formspec =
"size[8,9.3]" ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"label[0,0;" .. S("Fuel items") .. "]" ..
"list[current_name;fuel;0,0.6;8,4;]" ..
"list[current_player;main;0,5.15;8,1;]" ..
"list[current_player;main;0,6.38;8,3;8]" ..
"listring[current_name;fuel]" ..
"listring[current_player;main]" ..
default.get_hotbar_bg(0,5.15)
-- Fuel storage. Controller node draws fuel from here. -- Fuel storage. Controller node draws fuel from here.
-- Note that fuel stores are digtron group 5. -- Note that fuel stores are digtron group 5.
minetest.register_node("digtron:fuelstore", { minetest.register_node("digtron:fuelstore", {
description = S("Digtron Fuel Storage"), description = S("Digtron Fuel Storage"),
_doc_items_longdesc = digtron.doc.fuelstore_longdesc, _doc_items_longdesc = digtron.doc.fuelstore_longdesc,
_doc_items_usagehelp = digtron.doc.fuelstore_usagehelp, _doc_items_usagehelp = digtron.doc.fuelstore_usagehelp,
_digtron_formspec = fuelstore_formspec,
groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 5, tubedevice = 1, tubedevice_receiver = 1}, groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 5, tubedevice = 1, tubedevice_receiver = 1},
drop = "digtron:fuelstore", drop = "digtron:fuelstore",
sounds = digtron.metal_sounds, sounds = digtron.metal_sounds,
@ -95,19 +112,7 @@ minetest.register_node("digtron:fuelstore", {
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", meta:set_string("formspec", fuelstore_formspec)
"size[8,9.3]" ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"label[0,0;" .. S("Fuel items") .. "]" ..
"list[current_name;fuel;0,0.6;8,4;]" ..
"list[current_player;main;0,5.15;8,1;]" ..
"list[current_player;main;0,6.38;8,3;8]" ..
"listring[current_name;fuel]" ..
"listring[current_player;main]" ..
default.get_hotbar_bg(0,5.15)
)
local inv = meta:get_inventory() local inv = meta:get_inventory()
inv:set_size("fuel", 8*4) inv:set_size("fuel", 8*4)
end, end,
@ -158,11 +163,28 @@ minetest.register_node("digtron:fuelstore", {
after_dig_node = (function() if minetest.get_modpath("pipeworks")then return pipeworks.after_dig end end)() after_dig_node = (function() if minetest.get_modpath("pipeworks")then return pipeworks.after_dig end end)()
}) })
local combined_storage_formspec =
"size[8,9.9]" ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"label[0,0;" .. S("Inventory items") .. "]" ..
"list[current_name;main;0,0.6;8,3;]" ..
"label[0,3.5;" .. S("Fuel items") .. "]" ..
"list[current_name;fuel;0,4.1;8,1;]" ..
"list[current_player;main;0,5.75;8,1;]" ..
"list[current_player;main;0,6.98;8,3;8]" ..
"listring[current_name;main]" ..
"listring[current_player;main]" ..
default.get_hotbar_bg(0,5.75)
-- Combined storage. Group 6 has both an inventory and a fuel store -- Combined storage. Group 6 has both an inventory and a fuel store
minetest.register_node("digtron:combined_storage", { minetest.register_node("digtron:combined_storage", {
description = S("Digtron Combined Storage"), description = S("Digtron Combined Storage"),
_doc_items_longdesc = digtron.doc.combined_storage_longdesc, _doc_items_longdesc = digtron.doc.combined_storage_longdesc,
_doc_items_usagehelp = digtron.doc.combined_storage_usagehelp, _doc_items_usagehelp = digtron.doc.combined_storage_usagehelp,
_digtron_formspec = combined_storage_formspec,
groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 6, tubedevice = 1, tubedevice_receiver = 1}, groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 6, tubedevice = 1, tubedevice_receiver = 1},
drop = "digtron:combined_storage", drop = "digtron:combined_storage",
sounds = digtron.metal_sounds, sounds = digtron.metal_sounds,
@ -179,21 +201,7 @@ minetest.register_node("digtron:combined_storage", {
}, },
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", meta:set_string("formspec", combined_storage_formspec)
"size[8,9.9]" ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"label[0,0;" .. S("Inventory items") .. "]" ..
"list[current_name;main;0,0.6;8,3;]" ..
"label[0,3.5;" .. S("Fuel items") .. "]" ..
"list[current_name;fuel;0,4.1;8,1;]" ..
"list[current_player;main;0,5.75;8,1;]" ..
"list[current_player;main;0,6.98;8,3;8]" ..
"listring[current_name;main]" ..
"listring[current_player;main]" ..
default.get_hotbar_bg(0,5.75)
)
local inv = meta:get_inventory() local inv = meta:get_inventory()
inv:set_size("main", 8*3) inv:set_size("main", 8*3)
inv:set_size("fuel", 8*1) inv:set_size("fuel", 8*1)

57
upgrades.lua Normal file

@ -0,0 +1,57 @@
-- re-applies the "_digtron_formspec" property from all digtron node defs to the digtron node's metadata.
minetest.register_lbm({
name = "digtron:generic_formspec_sanitizer",
nodenames = {"group:digtron"},
action = function(pos, node)
local node_def = minetest.registered_nodes[node.name]
local meta = minetest.get_meta(pos)
meta:set_string("formspec", node_def._digtron_formspec)
end
})
minetest.register_lbm({
name = "digtron:sand_digger_upgrade",
nodenames = {"digtron:sand_digger"},
action = function(pos, node)
local meta = minetest.get_meta(pos)
local offset = meta:get_string("offset")
local period = meta:get_string("period")
minetest.set_node(pos, {name = "digtron:soft_digger",
param2 = node.param2})
meta:set_string("offset", offset)
meta:set_string("period", period)
end
})
minetest.register_lbm({
name = "digtron:fuelstore_upgrade",
nodenames = {"digtron:fuelstore"},
action = function(pos, node)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local list = inv:get_list("main")
inv:set_list("main", {})
inv:set_list("fuel", list)
end
})
minetest.register_lbm({
name = "digtron:autocontroller_lateral_upgrade",
nodenames = {"digtron:auto_controller"},
action = function(pos, node)
local meta = minetest.get_meta(pos)
local cycles = meta:get_int("offset")
meta:set_int("cycles", cycles)
meta:set_int("offset", 0)
meta:set_int("slope", 0)
end
})
minetest.register_lbm({
name = "digtron:builder_extrusion_upgrade",
nodenames = {"digtron:builder"},
action = function(pos, node)
local meta = minetest.get_meta(pos)
meta:set_int("extrusion", 1)
end
})

@ -52,21 +52,21 @@ digtron.mark_diggable = function(pos, nodes_dug)
local in_known_group = false local in_known_group = false
local material_cost = 0 local material_cost = 0
if digtron.creative_mode ~= true then if digtron.config.uses_resources then
if minetest.get_item_group(target.name, "cracky") ~= 0 then if minetest.get_item_group(target.name, "cracky") ~= 0 then
in_known_group = true in_known_group = true
material_cost = math.max(material_cost, digtron.dig_cost_cracky) material_cost = math.max(material_cost, digtron.config.dig_cost_cracky)
end end
if minetest.get_item_group(target.name, "crumbly") ~= 0 then if minetest.get_item_group(target.name, "crumbly") ~= 0 then
in_known_group = true in_known_group = true
material_cost = math.max(material_cost, digtron.dig_cost_crumbly) material_cost = math.max(material_cost, digtron.config.dig_cost_crumbly)
end end
if minetest.get_item_group(target.name, "choppy") ~= 0 then if minetest.get_item_group(target.name, "choppy") ~= 0 then
in_known_group = true in_known_group = true
material_cost = math.max(material_cost, digtron.dig_cost_choppy) material_cost = math.max(material_cost, digtron.config.dig_cost_choppy)
end end
if not in_known_group then if not in_known_group then
material_cost = digtron.dig_cost_default material_cost = digtron.config.dig_cost_default
end end
end end
@ -241,3 +241,33 @@ digtron.is_soft_material = function(target)
end end
return false return false
end end
digtron.show_offset_markers = function(pos, offset, period)
local buildpos = digtron.find_new_pos(pos, minetest.get_node(pos).param2)
local x_pos = math.floor((buildpos.x+offset)/period)*period - offset
minetest.add_entity({x=x_pos, y=buildpos.y, z=buildpos.z}, "digtron:marker")
if x_pos >= buildpos.x then
minetest.add_entity({x=x_pos - period, y=buildpos.y, z=buildpos.z}, "digtron:marker")
end
if x_pos <= buildpos.x then
minetest.add_entity({x=x_pos + period, y=buildpos.y, z=buildpos.z}, "digtron:marker")
end
local y_pos = math.floor((buildpos.y+offset)/period)*period - offset
minetest.add_entity({x=buildpos.x, y=y_pos, z=buildpos.z}, "digtron:marker_vertical")
if y_pos >= buildpos.y then
minetest.add_entity({x=buildpos.x, y=y_pos - period, z=buildpos.z}, "digtron:marker_vertical")
end
if y_pos <= buildpos.y then
minetest.add_entity({x=buildpos.x, y=y_pos + period, z=buildpos.z}, "digtron:marker_vertical")
end
local z_pos = math.floor((buildpos.z+offset)/period)*period - offset
minetest.add_entity({x=buildpos.x, y=buildpos.y, z=z_pos}, "digtron:marker"):setyaw(1.5708)
if z_pos >= buildpos.z then
minetest.add_entity({x=buildpos.x, y=buildpos.y, z=z_pos - period}, "digtron:marker"):setyaw(1.5708)
end
if z_pos <= buildpos.z then
minetest.add_entity({x=buildpos.x, y=buildpos.y, z=z_pos + period}, "digtron:marker"):setyaw(1.5708)
end
end

@ -59,10 +59,10 @@ local function neighbour_test(layout, status_text, dir)
minetest.sound_play("woopwoopwoop", {gain=1.0, pos=layout.controller}) minetest.sound_play("woopwoopwoop", {gain=1.0, pos=layout.controller})
end end
if dir and dir.y ~= -1 and layout.traction * digtron.traction_factor < table.getn(layout.all) then if dir and dir.y ~= -1 and layout.traction * digtron.config.traction_factor < table.getn(layout.all) then
-- digtrons can't fly, though they can fall -- digtrons can't fly, though they can fall
minetest.sound_play("squeal", {gain=1.0, pos=layout.controller}) minetest.sound_play("squeal", {gain=1.0, pos=layout.controller})
return string.format("Digtron has %d blocks but only enough traction to move %d blocks.\n", table.getn(layout.all), layout.traction * digtron.traction_factor) return S("Digtron has @1 blocks but only enough traction to move @2 blocks.\n", table.getn(layout.all), layout.traction * digtron.config.traction_factor)
.. status_text, 2 .. status_text, 2
end end
@ -107,7 +107,7 @@ digtron.execute_dig_cycle = function(pos, clicker)
local facing = minetest.get_node(pos).param2 local facing = minetest.get_node(pos).param2
local dir = minetest.facedir_to_dir(facing) local dir = minetest.facedir_to_dir(facing)
local fuel_burning = meta:get_float("fuel_burning") -- get amount of burned fuel left over from last cycle local fuel_burning = meta:get_float("fuel_burning") -- get amount of burned fuel left over from last cycle
local status_text = string.format(S("Heat remaining in controller furnace: %d"), math.max(0, fuel_burning)) local status_text = S("Heat remaining in controller furnace: @1", math.max(0, fuel_burning))
local layout = DigtronLayout.create(pos, clicker) local layout = DigtronLayout.create(pos, clicker)
@ -137,7 +137,7 @@ digtron.execute_dig_cycle = function(pos, clicker)
for _, itemname in pairs(dropped) do for _, itemname in pairs(dropped) do
table.insert(items_dropped, itemname) table.insert(items_dropped, itemname)
end end
if digtron.particle_effects then if digtron.config.particle_effects then
table.insert(particle_systems, dig_dust(vector.add(location.pos, dir), target.param2)) table.insert(particle_systems, dig_dust(vector.add(location.pos, dir), target.param2))
end end
end end
@ -164,9 +164,9 @@ digtron.execute_dig_cycle = function(pos, clicker)
end end
if not can_move then if not can_move then
-- mark this node as waiting, will clear this flag in digtron.cycle_time seconds -- mark this node as waiting, will clear this flag in digtron.config.cycle_time seconds
minetest.get_meta(pos):set_string("waiting", "true") minetest.get_meta(pos):set_string("waiting", "true")
minetest.get_node_timer(pos):start(digtron.cycle_time) minetest.get_node_timer(pos):start(digtron.config.cycle_time)
minetest.sound_play("squeal", {gain=1.0, pos=pos}) minetest.sound_play("squeal", {gain=1.0, pos=pos})
minetest.sound_play("buzzer", {gain=0.5, pos=pos}) minetest.sound_play("buzzer", {gain=0.5, pos=pos})
return pos, S("Digtron is obstructed.") .. "\n" .. status_text, 3 --Abort, don't dig and don't build. return pos, S("Digtron is obstructed.") .. "\n" .. status_text, 3 --Abort, don't dig and don't build.
@ -193,7 +193,7 @@ digtron.execute_dig_cycle = function(pos, clicker)
test_build_return_code, test_build_return_items, failed_to_find = targetdef.test_build(location.pos, test_location, layout.inventories, layout.protected, layout.nodes_dug, controlling_coordinate, layout.controller) test_build_return_code, test_build_return_items, failed_to_find = targetdef.test_build(location.pos, test_location, layout.inventories, layout.protected, layout.nodes_dug, controlling_coordinate, layout.controller)
for k, return_item in pairs(test_build_return_items) do for k, return_item in pairs(test_build_return_items) do
table.insert(test_items, return_item) table.insert(test_items, return_item)
test_build_fuel_cost = test_build_fuel_cost + digtron.build_cost test_build_fuel_cost = test_build_fuel_cost + digtron.config.build_cost
end end
if test_build_return_code > 1 then if test_build_return_code > 1 then
can_build = false can_build = false
@ -222,7 +222,7 @@ digtron.execute_dig_cycle = function(pos, clicker)
if not can_build then if not can_build then
minetest.get_meta(pos):set_string("waiting", "true") minetest.get_meta(pos):set_string("waiting", "true")
minetest.get_node_timer(pos):start(digtron.cycle_time) minetest.get_node_timer(pos):start(digtron.config.cycle_time)
local return_string = nil local return_string = nil
local return_code = 5 local return_code = 5
if test_build_return_code == 3 then if test_build_return_code == 3 then
@ -231,8 +231,7 @@ digtron.execute_dig_cycle = function(pos, clicker)
return_code = 6 return_code = 6
elseif test_build_return_code == 2 then elseif test_build_return_code == 2 then
minetest.sound_play("dingding", {gain=1.0, pos=pos}) -- Insufficient inventory minetest.sound_play("dingding", {gain=1.0, pos=pos}) -- Insufficient inventory
return_string = string.format(S("Digtron has insufficient building materials. Needed: %s") .. "\n", return_string = S("Digtron has insufficient building materials. Needed: @1", failed_to_find:get_name()) .. "\n"
failed_to_find:get_name())
return_code = 7 return_code = 7
end end
return pos, return_string .. status_text, return_code --Abort, don't dig and don't build. return pos, return_string .. status_text, return_code --Abort, don't dig and don't build.
@ -247,7 +246,7 @@ digtron.execute_dig_cycle = function(pos, clicker)
local move_player = move_player_test(layout, clicker) local move_player = move_player_test(layout, clicker)
-- damage the weak flesh -- damage the weak flesh
if digtron.diggers_damage_creatures then if digtron.config.damage_creatures then
for k, location in pairs(layout.diggers) do for k, location in pairs(layout.diggers) do
local target = minetest.get_node(location.pos) local target = minetest.get_node(location.pos)
local targetdef = minetest.registered_nodes[target.name] local targetdef = minetest.registered_nodes[target.name]
@ -288,8 +287,8 @@ digtron.execute_dig_cycle = function(pos, clicker)
-- don't interrupt the build cycle as a whole, we've already moved so might as well try to complete as much as possible. -- don't interrupt the build cycle as a whole, we've already moved so might as well try to complete as much as possible.
strange_failure = true strange_failure = true
build_return = (build_return * -1) - 1 build_return = (build_return * -1) - 1
elseif not digtron.creative_mode == true then elseif digtron.config.uses_resources then
building_fuel_cost = building_fuel_cost + (digtron.build_cost * build_return) building_fuel_cost = building_fuel_cost + (digtron.config.build_cost * build_return)
end end
else else
minetest.log(string.format("%s has builder group but is missing execute_build method! This is an error in mod programming, file a bug.", targetdef.name)) minetest.log(string.format("%s has builder group but is missing execute_build method! This is an error in mod programming, file a bug.", targetdef.name))
@ -307,14 +306,14 @@ digtron.execute_dig_cycle = function(pos, clicker)
-- acutally burn the fuel needed -- acutally burn the fuel needed
local fuel_cost = digging_fuel_cost + building_fuel_cost local fuel_cost = digging_fuel_cost + building_fuel_cost
fuel_burning = fuel_burning - fuel_cost fuel_burning = fuel_burning - fuel_cost
if digtron.particle_effects then if digtron.config.particle_effects then
table.insert(particle_systems, burn_smoke(pos, fuel_cost)) table.insert(particle_systems, burn_smoke(pos, fuel_cost))
end end
if fuel_burning < 0 then if fuel_burning < 0 then
fuel_burning = fuel_burning + digtron.burn(layout.fuelstores, -fuel_burning, false) fuel_burning = fuel_burning + digtron.burn(layout.fuelstores, -fuel_burning, false)
end end
meta:set_float("fuel_burning", fuel_burning) meta:set_float("fuel_burning", fuel_burning)
status_text = status_text .. string.format(S("Heat remaining in controller furnace: %d"), math.max(0, fuel_burning)) status_text = status_text .. S("Heat remaining in controller furnace: @1", math.max(0, fuel_burning))
-- Eyecandy -- Eyecandy
for _, particles in pairs(particle_systems) do for _, particles in pairs(particle_systems) do
@ -326,7 +325,7 @@ digtron.execute_dig_cycle = function(pos, clicker)
local node_to_dig, whether_to_dig = layout.nodes_dug:pop() local node_to_dig, whether_to_dig = layout.nodes_dug:pop()
while node_to_dig ~= nil do while node_to_dig ~= nil do
if whether_to_dig == true then if whether_to_dig == true then
minetest.log("action", string.format(S("%s uses Digtron to dig %s at (%d, %d, %d)"), clicker:get_player_name(), minetest.get_node(node_to_dig).name, node_to_dig.x, node_to_dig.y, node_to_dig.z)) minetest.log("action", string.format("%s uses Digtron to dig %s at (%d, %d, %d)", clicker:get_player_name(), minetest.get_node(node_to_dig).name, node_to_dig.x, node_to_dig.y, node_to_dig.z))
minetest.remove_node(node_to_dig) minetest.remove_node(node_to_dig)
end end
-- all of the digtron's nodes wind up in nodes_dug, so this is an ideal place to stick -- all of the digtron's nodes wind up in nodes_dug, so this is an ideal place to stick
@ -359,9 +358,9 @@ digtron.execute_move_cycle = function(pos, clicker)
-- test if any digtrons are obstructed by non-digtron nodes -- test if any digtrons are obstructed by non-digtron nodes
layout:move_layout_image(dir) layout:move_layout_image(dir)
if not layout:can_write_layout_image() then if not layout:can_write_layout_image() then
-- mark this node as waiting, will clear this flag in digtron.cycle_time seconds -- mark this node as waiting, will clear this flag in digtron.config.cycle_time seconds
minetest.get_meta(pos):set_string("waiting", "true") minetest.get_meta(pos):set_string("waiting", "true")
minetest.get_node_timer(pos):start(digtron.cycle_time) minetest.get_node_timer(pos):start(digtron.config.cycle_time)
minetest.sound_play("squeal", {gain=1.0, pos=pos}) minetest.sound_play("squeal", {gain=1.0, pos=pos})
minetest.sound_play("buzzer", {gain=0.5, pos=pos}) minetest.sound_play("buzzer", {gain=0.5, pos=pos})
return pos, S("Digtron is obstructed.") .. "\n" .. status_text, 3 --Abort, don't dig and don't build. return pos, S("Digtron is obstructed.") .. "\n" .. status_text, 3 --Abort, don't dig and don't build.
@ -391,7 +390,7 @@ digtron.execute_downward_dig_cycle = function(pos, clicker)
local facing = minetest.get_node(pos).param2 local facing = minetest.get_node(pos).param2
local dir = digtron.facedir_to_down_dir(facing) local dir = digtron.facedir_to_down_dir(facing)
local fuel_burning = meta:get_float("fuel_burning") -- get amount of burned fuel left over from last cycle local fuel_burning = meta:get_float("fuel_burning") -- get amount of burned fuel left over from last cycle
local status_text = string.format(S("Heat remaining in controller furnace: %d"), math.max(0, fuel_burning)) local status_text = S("Heat remaining in controller furnace: @1", math.max(0, fuel_burning))
local layout = DigtronLayout.create(pos, clicker) local layout = DigtronLayout.create(pos, clicker)
@ -421,7 +420,7 @@ digtron.execute_downward_dig_cycle = function(pos, clicker)
for _, itemname in pairs(dropped) do for _, itemname in pairs(dropped) do
table.insert(items_dropped, itemname) table.insert(items_dropped, itemname)
end end
if digtron.particle_effects then if digtron.config.particle_effects then
table.insert(particle_systems, dig_dust(vector.add(location.pos, dir), target.param2)) table.insert(particle_systems, dig_dust(vector.add(location.pos, dir), target.param2))
end end
end end
@ -448,9 +447,9 @@ digtron.execute_downward_dig_cycle = function(pos, clicker)
end end
if not can_move then if not can_move then
-- mark this node as waiting, will clear this flag in digtron.cycle_time seconds -- mark this node as waiting, will clear this flag in digtron.config.cycle_time seconds
minetest.get_meta(pos):set_string("waiting", "true") minetest.get_meta(pos):set_string("waiting", "true")
minetest.get_node_timer(pos):start(digtron.cycle_time) minetest.get_node_timer(pos):start(digtron.config.cycle_time)
minetest.sound_play("squeal", {gain=1.0, pos=pos}) minetest.sound_play("squeal", {gain=1.0, pos=pos})
minetest.sound_play("buzzer", {gain=0.5, pos=pos}) minetest.sound_play("buzzer", {gain=0.5, pos=pos})
return pos, S("Digtron is obstructed.") .. "\n" .. status_text, 3 --Abort, don't dig and don't build. return pos, S("Digtron is obstructed.") .. "\n" .. status_text, 3 --Abort, don't dig and don't build.
@ -465,7 +464,7 @@ digtron.execute_downward_dig_cycle = function(pos, clicker)
local move_player = move_player_test(layout, clicker) local move_player = move_player_test(layout, clicker)
-- damage the weak flesh -- damage the weak flesh
if digtron.diggers_damage_creatures then if digtron.config.damage_creatures then
for k, location in pairs(layout.diggers) do for k, location in pairs(layout.diggers) do
local target = minetest.get_node(location.pos) local target = minetest.get_node(location.pos)
local targetdef = minetest.registered_nodes[target.name] local targetdef = minetest.registered_nodes[target.name]
@ -495,14 +494,14 @@ digtron.execute_downward_dig_cycle = function(pos, clicker)
-- acutally burn the fuel needed -- acutally burn the fuel needed
fuel_burning = fuel_burning - digging_fuel_cost fuel_burning = fuel_burning - digging_fuel_cost
if digtron.particle_effects then if digtron.config.particle_effects then
table.insert(particle_systems, burn_smoke(pos, digging_fuel_cost)) table.insert(particle_systems, burn_smoke(pos, digging_fuel_cost))
end end
if fuel_burning < 0 then if fuel_burning < 0 then
fuel_burning = fuel_burning + digtron.burn(layout.fuelstores, -fuel_burning, false) fuel_burning = fuel_burning + digtron.burn(layout.fuelstores, -fuel_burning, false)
end end
meta:set_float("fuel_burning", fuel_burning) meta:set_float("fuel_burning", fuel_burning)
status_text = status_text .. string.format(S("Heat remaining in controller furnace: %d"), math.max(0, fuel_burning)) status_text = status_text .. S("Heat remaining in controller furnace: @1", math.max(0, fuel_burning))
-- Eyecandy -- Eyecandy
for _, particles in pairs(particle_systems) do for _, particles in pairs(particle_systems) do
@ -514,7 +513,7 @@ digtron.execute_downward_dig_cycle = function(pos, clicker)
local node_to_dig, whether_to_dig = layout.nodes_dug:pop() local node_to_dig, whether_to_dig = layout.nodes_dug:pop()
while node_to_dig ~= nil do while node_to_dig ~= nil do
if whether_to_dig == true then if whether_to_dig == true then
minetest.log("action", string.format(S("%s uses Digtron to dig %s at (%d, %d, %d)"), clicker:get_player_name(), minetest.get_node(node_to_dig).name, node_to_dig.x, node_to_dig.y, node_to_dig.z)) minetest.log("action", string.format("%s uses Digtron to dig %s at (%d, %d, %d)", clicker:get_player_name(), minetest.get_node(node_to_dig).name, node_to_dig.x, node_to_dig.y, node_to_dig.z))
minetest.remove_node(node_to_dig) minetest.remove_node(node_to_dig)
end end
-- all of the digtron's nodes wind up in nodes_dug, so this is an ideal place to stick -- all of the digtron's nodes wind up in nodes_dug, so this is an ideal place to stick