diff options
author | FaceDeer <FaceDeer@users.noreply.github.com> | 2017-09-30 10:56:15 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-30 10:56:15 -0600 |
commit | 444411936cc85ba0ef9bfaad11f74544c24cb0b6 (patch) | |
tree | a58d3e8667a8e97e91c2b35e550d58fe3c211611 /config.lua | |
parent | 3441a0d1da37087287fdaade7c8930480abe65e9 (diff) | |
parent | 860890b10061d76c5ea011fe0befca435be5f243 (diff) |
Merge pull request #8 from minetest-mods/cleanup
Cleanup
Diffstat (limited to 'config.lua')
-rw-r--r-- | config.lua | 105 |
1 files changed, 38 insertions, 67 deletions
@@ -1,44 +1,40 @@ --- 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") - --- 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") +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 -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 +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") --- 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 +-- 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 --- 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") |