diff --git a/class_layout.lua b/class_layout.lua index 0aa139e..63ce529 100644 --- a/class_layout.lua +++ b/class_layout.lua @@ -6,9 +6,13 @@ DigtronLayout.__index = DigtronLayout local get_node_image = function(pos, node) 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) 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 if minetest.get_item_group(node.name, "digtron") == 4 then @@ -86,7 +90,7 @@ function DigtronLayout.create(pos, player) self.water_touching = true elseif minetest.get_item_group(node.name, "lava") ~= 0 then 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) end end diff --git a/config.lua b/config.lua index d2d8860..a4b905e 100644 --- a/config.lua +++ b/config.lua @@ -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 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. -local lava_impassible = minetest.settings:get_bool("digtron_lava_impassible") - --- 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 +setting("int", "maximum_extrusion", 25, "Maximum builder extrusion distance") +setting("float", "cycle_time", 1.0, "Minimum Digtron cycle time") +setting("float", "traction_factor", 3.0, "Traction factor") -- fuel costs. For comparison, in the default game: -- one default tree block is 30 units @@ -47,37 +43,12 @@ end -- one book is 3 units -- 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")) -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 +setting("float", "dig_cost_default", 3.0, "Default dig cost") -- eg, stone -local digtron_dig_cost_cracky = tonumber(minetest.settings:get("digtron_dig_cost_cracky")) -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 +setting("float", "dig_cost_cracky", 1.0, "Cracky dig cost") -- eg, dirt, sand -local digtron_dig_cost_crumbly = tonumber(minetest.settings:get("digtron_dig_cost_crumbly")) -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 +setting("float", "dig_cost_crumbly", 0.5, "Crumbly dig cost") -- eg, wood -local digtron_dig_cost_choppy = tonumber(minetest.settings:get("digtron_dig_cost_choppy")) -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 +setting("float", "dig_cost_choppy", 0.75, "Choppy dig cost") -- how much fuel is required to build a node -local digtron_build_cost = tonumber(minetest.settings:get("digtron_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 \ No newline at end of file +setting("float", "build_cost", 1.0, "Build cost") diff --git a/init.lua b/init.lua index c01692e..7beb8ee 100644 --- a/init.lua +++ b/init.lua @@ -4,21 +4,41 @@ digtron.auto_controller_colorize = "#88000030" digtron.pusher_controller_colorize = "#00880030" digtron.soft_digger_colorize = "#88880030" -dofile( minetest.get_modpath( "digtron" ) .. "/config.lua" ) -dofile( minetest.get_modpath( "digtron" ) .. "/util.lua" ) -dofile( minetest.get_modpath( "digtron" ) .. "/doc.lua" ) -dofile( minetest.get_modpath( "digtron" ) .. "/awards.lua" ) -dofile( minetest.get_modpath( "digtron" ) .. "/class_pointset.lua" ) -dofile( minetest.get_modpath( "digtron" ) .. "/class_layout.lua" ) -dofile( minetest.get_modpath( "digtron" ) .. "/entities.lua" ) -dofile( minetest.get_modpath( "digtron" ) .. "/node_misc.lua" ) -- contains structure and light nodes -dofile( minetest.get_modpath( "digtron" ) .. "/node_storage.lua" ) -- contains inventory and fuel storage nodes -dofile( minetest.get_modpath( "digtron" ) .. "/node_diggers.lua" ) -- contains all diggers -dofile( minetest.get_modpath( "digtron" ) .. "/node_builders.lua" ) -- contains all builders (there's just one currently) -dofile( minetest.get_modpath( "digtron" ) .. "/node_controllers.lua" ) -- controllers -dofile( minetest.get_modpath( "digtron" ) .. "/node_axle.lua" ) -- Rotation controller -dofile( minetest.get_modpath( "digtron" ) .. "/node_crate.lua" ) -- Digtron portability support -dofile( minetest.get_modpath( "digtron" ) .. "/recipes.lua" ) +-- A global dictionary is used here so that other substitutions can be added easily by other mods, if necessary +digtron.builder_read_item_substitutions = { + ["default:torch_ceiling"] = "default:torch", + ["default:torch_wall"] = "default:torch", + ["default:dirt_with_grass"] = "default:dirt", + ["default:dirt_with_grass_footsteps"] = "default:dirt", + ["default:dirt_with_dry_grass"] = "default:dirt", + ["default:dirt_with_rainforest_litter"] = "default:dirt", + ["default:dirt_with_snow"] = "default:dirt", + ["default:furnace_active"] = "default:furnace", + ["farming:soil"] = "default:dirt", + ["farming:soil_wet"] = "default:dirt", + ["farming:desert_sand_soil"] = "default:desert_sand", + ["farming:desert_sand_soil_wet"] = "default:desert_sand", +} + +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: -- 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. -- 6 - holds both fuel and main inventories -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) - 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 -}) - +-- 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 +-- it to "eat" Digtrons sometimes. if minetest.get_modpath("catacomb") and catacomb ~= nil and catacomb.chamber_protected_nodes ~= nil and catacomb.passage_protected_nodes ~= nil then local digtron_nodes = { minetest.get_content_id("digtron:inventory"), diff --git a/locale/template.pot b/locale/template.pot index 7489c3a..614fa41 100644 --- a/locale/template.pot +++ b/locale/template.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\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" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -890,380 +890,30 @@ msgid "" "pass through the structure as it's being built." 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 msgid "Digtron is adjacent to unloaded nodes." 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 msgid "Digtron needs more fuel." msgstr "" @@ -1274,18 +924,354 @@ msgid "" msgstr "" #: util_execute_cycle.lua:234 -#, lua-format -msgid "Digtron has insufficient building materials. Needed: %s" +msgid "Digtron has insufficient building materials. Needed: @1" msgstr "" -#: util_execute_cycle.lua:304 +#: util_execute_cycle.lua:303 msgid "" "Digtron unexpectedly failed to execute one or more build operations, likely " "due to an inventory error." msgstr "" -#: util_execute_cycle.lua:329 -#: util_execute_cycle.lua:517 -#, lua-format -msgid "%s uses Digtron to dig %s at (%d, %d, %d)" +#: nodes\node_axle.lua:6 +msgid "Digtron Rotation Axle" +msgstr "" + +#: 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 "" diff --git a/node_axle.lua b/nodes/node_axle.lua similarity index 97% rename from node_axle.lua rename to nodes/node_axle.lua index 8726ab8..99dda4b 100644 --- a/node_axle.lua +++ b/nodes/node_axle.lua @@ -51,7 +51,7 @@ minetest.register_node("digtron:axle", { meta = minetest.get_meta(pos) meta:set_string("waiting", "true") 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 minetest.sound_play("buzzer", {gain=1.0, pos=pos}) meta:set_string("infotext", S("Digtron is obstructed.")) diff --git a/node_builders.lua b/nodes/node_builders.lua similarity index 71% rename from node_builders.lua rename to nodes/node_builders.lua index 424eb67..ecb76cd 100644 --- a/node_builders.lua +++ b/nodes/node_builders.lua @@ -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. -local builder_formspec = nil - +local displace_due_to_help_button = 1.0 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_img .. default.gui_slots .. - "list[current_name;main;0,0;1,1;]" .. - "label[0,0.8;" .. S("Block to build") .. "]" .. - "field[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) .. "]" .. - "field[2.3,0.8;1,0.1;period;" .. S("Periodicity") .. ";${period}]" .. + "list[current_name;main;".. tostring(displace_due_to_help_button/2) ..",0;1,1;]" .. + "label[" .. tostring(displace_due_to_help_button/2).. ",0.8;" .. S("Block to build") .. "]" .. + "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.config.maximum_extrusion) .. "]" .. + "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.") .. "]" .. - "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.") .. "]" .. - "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") .. "]" .. - "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.") .. "]" .. - "button_exit[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") .. "]" .. + "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]" + +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 -- 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"), _doc_items_longdesc = digtron.doc.builder_longdesc, _doc_items_usagehelp = digtron.doc.builder_usagehelp, + _digtron_formspec = builder_formspec, groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 4}, drop = "digtron:builder", sounds = digtron.metal_sounds, @@ -133,46 +116,26 @@ minetest.register_node("digtron:builder", { -- Should prevent that somehow. But not tonight. meta:set_int("build_facing", math.floor(build_facing)) 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))) else extrusion = meta:get_int("extrusion") end if fields.set then - 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 + digtron.show_offset_markers(pos, offset, period) elseif fields.read then - local meta = minetest.get_meta(pos) local facing = minetest.get_node(pos).param2 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 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) - 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) 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) built_count = built_count + 1 else @@ -314,7 +277,7 @@ minetest.register_node("digtron:builder", { end local returned_stack, success = digtron.item_place_node(item_stack, player, buildpos, build_facing) 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. nodes_dug:set(buildpos.x, buildpos.y, buildpos.z, false) digtron.award_item_built(item_stack:get_name(), player:get_player_name()) diff --git a/node_controllers.lua b/nodes/node_controllers.lua similarity index 94% rename from node_controllers.lua rename to nodes/node_controllers.lua index a09cfbe..4382734 100644 --- a/node_controllers.lua +++ b/nodes/node_controllers.lua @@ -45,7 +45,7 @@ minetest.register_node("digtron:controller", { on_construct = function(pos) local meta = minetest.get_meta(pos) 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, 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. 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, 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) 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) 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) @@ -144,7 +144,7 @@ digtron.auto_cycle = function(pos) local newpos, status, return_code = digtron.execute_dig_cycle(pos, player) 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) 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) @@ -157,7 +157,7 @@ digtron.auto_cycle = function(pos) meta = minetest.get_meta(newpos) cycle = meta:get_int("cycles") - 1 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("lateral_done", nil) @@ -172,6 +172,7 @@ minetest.register_node("digtron:auto_controller", { description = S("Digtron Automatic Control Module"), _doc_items_longdesc = digtron.doc.auto_controller_longdesc, _doc_items_usagehelp = digtron.doc.auto_controller_usagehelp, + _digtron_formspec = auto_formspec, groups = {cracky = 3, oddly_breakable_by_hand = 3, digtron = 1}, drop = "digtron:auto_controller", sounds = digtron.metal_sounds, @@ -197,10 +198,10 @@ minetest.register_node("digtron:auto_controller", { on_construct = function(pos) local meta = minetest.get_meta(pos) 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) -- 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("cycles", 0) meta:set_int("slope", 0) @@ -232,7 +233,7 @@ minetest.register_node("digtron:auto_controller", { local cycles = tonumber(fields.cycles) 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 if offset then @@ -289,7 +290,6 @@ minetest.register_node("digtron:auto_controller", { on_timer = function(pos, elapsed) minetest.get_meta(pos):set_string("waiting", nil) end, - }) --------------------------------------------------------------------------------------------------------------- @@ -335,7 +335,7 @@ minetest.register_node("digtron:pusher", { -- Start the delay before digtron can run again. 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, on_timer = function(pos, elapsed) diff --git a/node_crate.lua b/nodes/node_crate.lua similarity index 99% rename from node_crate.lua rename to nodes/node_crate.lua index 017023d..7e30207 100644 --- a/node_crate.lua +++ b/nodes/node_crate.lua @@ -80,6 +80,7 @@ minetest.register_node("digtron:loaded_crate", { description = S("Digtron Crate (Loaded)"), _doc_items_longdesc = digtron.doc.loaded_crate_longdesc, _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}, stack_max = 1, sounds = default.node_sound_wood_defaults(), diff --git a/node_diggers.lua b/nodes/node_diggers.lua similarity index 96% rename from node_diggers.lua rename to nodes/node_diggers.lua index c12b46c..bf48f71 100644 --- a/node_diggers.lua +++ b/nodes/node_diggers.lua @@ -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.") .. "]" .. "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.") .. "]" .. - "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") .. "]" -local intermittent_on_construct = function(pos) - local formspec = intermittent_formspec - if minetest.get_modpath("doc") then - formspec = "size[4.5,1]" .. formspec .. +if minetest.get_modpath("doc") then + intermittent_formspec = "size[4.5,1]" .. intermittent_formspec .. "button_exit[3.2,0.5;1,0.1;help;" .. S("Help") .. "]" .. "tooltip[help;" .. S("Show documentation about this block") .. "]" else - formspec = "size[3.5,1]" .. formspec + intermittent_formspec = "size[3.5,1]" .. intermittent_formspec end + +local intermittent_on_construct = function(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("offset", 0) end @@ -65,6 +65,9 @@ local intermittent_on_receive_fields = function(pos, formname, fields, sender) local node_name = minetest.get_node(pos).name minetest.after(0.5, doc.show_entry, sender:get_player_name(), "nodes", node_name, true) end + if fields.set then + digtron.show_offset_markers(pos, offset, period) + end end, -- 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"), _doc_items_longdesc = digtron.doc.digger_longdesc, _doc_items_usagehelp = digtron.doc.digger_usagehelp, + _digtron_formspec = intermittent_formspec, groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 3}, drop = "digtron:digger", sounds = digtron.metal_sounds, @@ -125,6 +129,7 @@ minetest.register_node("digtron:intermittent_digger", { description = S("Digtron Intermittent Digger Head"), _doc_items_longdesc = digtron.doc.intermittent_digger_longdesc, _doc_items_usagehelp = digtron.doc.intermittent_digger_usagehelp, + _digtron_formspec = intermittent_formspec, groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 3}, drop = "digtron:intermittent_digger", sounds = digtron.metal_sounds, @@ -250,6 +255,7 @@ minetest.register_node("digtron:intermittent_soft_digger", { description = S("Digtron Intermittent Soft Material Digger Head"), _doc_items_longdesc = digtron.doc.intermittent_soft_digger_longdesc, _doc_items_usagehelp = digtron.doc.intermittent_soft_digger_usagehelp, + _digtron_formspec = intermittent_formspec, groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 3}, drop = "digtron:intermittent_soft_digger", sounds = digtron.metal_sounds, @@ -283,7 +289,7 @@ minetest.register_node("digtron:intermittent_soft_digger", { on_construct = intermittent_on_construct, on_receive_fields = intermittent_on_receive_fields, - + execute_dig = function(pos, protected_nodes, nodes_dug, controlling_coordinate, lateral_dig) if lateral_dig == true then return 0, {} diff --git a/node_misc.lua b/nodes/node_misc.lua similarity index 100% rename from node_misc.lua rename to nodes/node_misc.lua diff --git a/node_storage.lua b/nodes/node_storage.lua similarity index 84% rename from node_storage.lua rename to nodes/node_storage.lua index 5284490..56d19aa 100644 --- a/node_storage.lua +++ b/nodes/node_storage.lua @@ -2,13 +2,28 @@ local MP = minetest.get_modpath(minetest.get_current_modname()) 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. -- Note that inventories are digtron group 2. minetest.register_node("digtron:inventory", { description = S("Digtron Inventory Storage"), _doc_items_longdesc = digtron.doc.inventory_longdesc, _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", sounds = digtron.metal_sounds, paramtype2= "facedir", @@ -26,19 +41,7 @@ minetest.register_node("digtron:inventory", { on_construct = function(pos) local meta = minetest.get_meta(pos) - meta:set_string("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) - ) + meta:set_string("formspec", inventory_formspec) local inv = meta:get_inventory() inv:set_size("main", 8*4) end, @@ -48,7 +51,7 @@ minetest.register_node("digtron:inventory", { local inv = meta:get_inventory() return inv:is_empty("main") end, - + -- Pipeworks compatibility ---------------------------------------------------------------- @@ -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)() }) +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. -- Note that fuel stores are digtron group 5. minetest.register_node("digtron:fuelstore", { description = S("Digtron Fuel Storage"), _doc_items_longdesc = digtron.doc.fuelstore_longdesc, _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}, drop = "digtron:fuelstore", sounds = digtron.metal_sounds, @@ -95,19 +112,7 @@ minetest.register_node("digtron:fuelstore", { on_construct = function(pos) local meta = minetest.get_meta(pos) - meta:set_string("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) - ) + meta:set_string("formspec", fuelstore_formspec) local inv = meta:get_inventory() inv:set_size("fuel", 8*4) end, @@ -129,7 +134,7 @@ minetest.register_node("digtron:fuelstore", { local inv = meta:get_inventory() return inv:is_empty("fuel") end, - + -- Pipeworks compatibility ---------------------------------------------------------------- @@ -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)() }) +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 minetest.register_node("digtron:combined_storage", { description = S("Digtron Combined Storage"), _doc_items_longdesc = digtron.doc.combined_storage_longdesc, _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}, drop = "digtron:combined_storage", sounds = digtron.metal_sounds, @@ -179,21 +201,7 @@ minetest.register_node("digtron:combined_storage", { }, on_construct = function(pos) local meta = minetest.get_meta(pos) - meta:set_string("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) - ) + meta:set_string("formspec", combined_storage_formspec) local inv = meta:get_inventory() inv:set_size("main", 8*3) inv:set_size("fuel", 8*1) @@ -230,7 +238,7 @@ minetest.register_node("digtron:combined_storage", { local inv = meta:get_inventory() return inv:is_empty("fuel") and inv:is_empty("main") end, - + -- Pipeworks compatibility ---------------------------------------------------------------- tube = (function() if minetest.get_modpath("pipeworks") then return { diff --git a/recipes.lua b/nodes/recipes.lua similarity index 100% rename from recipes.lua rename to nodes/recipes.lua diff --git a/upgrades.lua b/upgrades.lua new file mode 100644 index 0000000..8f0c6fb --- /dev/null +++ b/upgrades.lua @@ -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 +}) \ No newline at end of file diff --git a/util.lua b/util.lua index e32c16b..63903b1 100644 --- a/util.lua +++ b/util.lua @@ -52,21 +52,21 @@ digtron.mark_diggable = function(pos, nodes_dug) local in_known_group = false 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 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 if minetest.get_item_group(target.name, "crumbly") ~= 0 then 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 if minetest.get_item_group(target.name, "choppy") ~= 0 then 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 if not in_known_group then - material_cost = digtron.dig_cost_default + material_cost = digtron.config.dig_cost_default end end @@ -240,4 +240,34 @@ digtron.is_soft_material = function(target) return true end return false +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 \ No newline at end of file diff --git a/util_execute_cycle.lua b/util_execute_cycle.lua index 0e0e092..38f4381 100644 --- a/util_execute_cycle.lua +++ b/util_execute_cycle.lua @@ -59,10 +59,10 @@ local function neighbour_test(layout, status_text, dir) minetest.sound_play("woopwoopwoop", {gain=1.0, pos=layout.controller}) 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 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 end @@ -107,7 +107,7 @@ digtron.execute_dig_cycle = function(pos, clicker) local facing = minetest.get_node(pos).param2 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 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) @@ -137,7 +137,7 @@ digtron.execute_dig_cycle = function(pos, clicker) for _, itemname in pairs(dropped) do table.insert(items_dropped, itemname) 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)) end end @@ -164,9 +164,9 @@ digtron.execute_dig_cycle = function(pos, clicker) end 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_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("buzzer", {gain=0.5, pos=pos}) 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) for k, return_item in pairs(test_build_return_items) do 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 if test_build_return_code > 1 then can_build = false @@ -222,7 +222,7 @@ digtron.execute_dig_cycle = function(pos, clicker) if not can_build then 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_code = 5 if test_build_return_code == 3 then @@ -231,8 +231,7 @@ digtron.execute_dig_cycle = function(pos, clicker) return_code = 6 elseif test_build_return_code == 2 then minetest.sound_play("dingding", {gain=1.0, pos=pos}) -- Insufficient inventory - return_string = string.format(S("Digtron has insufficient building materials. Needed: %s") .. "\n", - failed_to_find:get_name()) + return_string = S("Digtron has insufficient building materials. Needed: @1", failed_to_find:get_name()) .. "\n" return_code = 7 end 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) -- damage the weak flesh - if digtron.diggers_damage_creatures then + if digtron.config.damage_creatures then for k, location in pairs(layout.diggers) do local target = minetest.get_node(location.pos) 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. strange_failure = true build_return = (build_return * -1) - 1 - elseif not digtron.creative_mode == true then - building_fuel_cost = building_fuel_cost + (digtron.build_cost * build_return) + elseif digtron.config.uses_resources then + building_fuel_cost = building_fuel_cost + (digtron.config.build_cost * build_return) end 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)) @@ -307,14 +306,14 @@ digtron.execute_dig_cycle = function(pos, clicker) -- acutally burn the fuel needed local fuel_cost = digging_fuel_cost + building_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)) end if fuel_burning < 0 then fuel_burning = fuel_burning + digtron.burn(layout.fuelstores, -fuel_burning, false) end 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 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() while node_to_dig ~= nil do 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) end -- 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 layout:move_layout_image(dir) 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_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("buzzer", {gain=0.5, pos=pos}) 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 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 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) @@ -421,7 +420,7 @@ digtron.execute_downward_dig_cycle = function(pos, clicker) for _, itemname in pairs(dropped) do table.insert(items_dropped, itemname) 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)) end end @@ -448,9 +447,9 @@ digtron.execute_downward_dig_cycle = function(pos, clicker) end 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_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("buzzer", {gain=0.5, pos=pos}) 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) -- damage the weak flesh - if digtron.diggers_damage_creatures then + if digtron.config.damage_creatures then for k, location in pairs(layout.diggers) do local target = minetest.get_node(location.pos) local targetdef = minetest.registered_nodes[target.name] @@ -495,14 +494,14 @@ digtron.execute_downward_dig_cycle = function(pos, clicker) -- acutally burn the fuel needed 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)) end if fuel_burning < 0 then fuel_burning = fuel_burning + digtron.burn(layout.fuelstores, -fuel_burning, false) end 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 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() while node_to_dig ~= nil do 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) end -- all of the digtron's nodes wind up in nodes_dug, so this is an ideal place to stick