mirror of
https://github.com/minetest-mods/digtron.git
synced 2024-12-23 04:42:23 +01:00
standardize config settings
This commit is contained in:
parent
15b327c842
commit
46bffd82d3
@ -86,7 +86,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
|
||||||
|
105
config.lua
105
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
|
-- 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
|
|
||||||
|
2
init.lua
2
init.lua
@ -115,7 +115,7 @@ minetest.register_lbm({
|
|||||||
"list[current_name;main;0.5,0;1,1;]" ..
|
"list[current_name;main;0.5,0;1,1;]" ..
|
||||||
"label[0.5,0.8;" .. S("Block to build") .. "]" ..
|
"label[0.5,0.8;" .. S("Block to build") .. "]" ..
|
||||||
"field[2.3,0.8;1,0.1;extrusion;" .. S("Extrusion") .. ";${extrusion}]" ..
|
"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) .. "]" ..
|
"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[3.3,0.8;1,0.1;period;" .. S("Periodicity") .. ";${period}]" ..
|
"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.") .. "]" ..
|
"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}]" ..
|
"field[4.3,0.8;1,0.1;offset;" .. S("Offset") .. ";${offset}]" ..
|
||||||
|
@ -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."))
|
||||||
|
@ -14,7 +14,7 @@ if minetest.get_modpath("doc") then
|
|||||||
"list[current_name;main;0,0;1,1;]" ..
|
"list[current_name;main;0,0;1,1;]" ..
|
||||||
"label[0,0.8;" .. S("Block to build") .. "]" ..
|
"label[0,0.8;" .. S("Block to build") .. "]" ..
|
||||||
"field[1.3,0.8;1,0.1;extrusion;" .. S("Extrusion") .. ";${extrusion}]" ..
|
"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) .. "]" ..
|
"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[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[3.3,0.8;1,0.1;offset;" .. S("Offset") .. ";${offset}]" ..
|
||||||
@ -40,7 +40,7 @@ else
|
|||||||
"list[current_name;main;0.5,0;1,1;]" ..
|
"list[current_name;main;0.5,0;1,1;]" ..
|
||||||
"label[0.5,0.8;" .. S("Block to build") .. "]" ..
|
"label[0.5,0.8;" .. S("Block to build") .. "]" ..
|
||||||
"field[2.3,0.8;1,0.1;extrusion;" .. S("Extrusion") .. ";${extrusion}]" ..
|
"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) .. "]" ..
|
"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[3.3,0.8;1,0.1;period;" .. S("Periodicity") .. ";${period}]" ..
|
"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.") .. "]" ..
|
"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}]" ..
|
"field[4.3,0.8;1,0.1;offset;" .. S("Offset") .. ";${offset}]" ..
|
||||||
@ -133,7 +133,7 @@ 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")
|
||||||
@ -296,7 +296,7 @@ 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("%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))
|
||||||
|
@ -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)
|
||||||
@ -200,7 +200,7 @@ minetest.register_node("digtron:auto_controller", {
|
|||||||
meta:set_string("infotext", string.format(S("Heat remaining in controller furnace: %d"), 0))
|
meta:set_string("infotext", string.format(S("Heat remaining in controller furnace: %d"), 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 +232,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
|
||||||
@ -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)
|
||||||
|
10
util.lua
10
util.lua
@ -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
|
||||||
|
|
||||||
|
@ -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 string.format("Digtron has %d blocks but only enough traction to move %d blocks.\n", table.getn(layout.all), layout.traction * digtron.config.traction_factor)
|
||||||
.. status_text, 2
|
.. status_text, 2
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -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
|
||||||
@ -247,7 +247,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 +288,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,7 +307,7 @@ 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
|
||||||
@ -359,9 +359,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.
|
||||||
@ -421,7 +421,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 +448,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 +465,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,7 +495,7 @@ 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
|
||||||
|
Loading…
Reference in New Issue
Block a user