From 12435fc2f361d11e396efcaa59732c1ab0b9e2c7 Mon Sep 17 00:00:00 2001 From: FaceDeer Date: Thu, 19 Jan 2017 23:26:45 -0700 Subject: [PATCH] add settings to settings menu --- init.lua | 97 ++++++++++++++++++++++++++++++++++++++++-------- settingtypes.txt | 27 ++++++++++++++ 2 files changed, 109 insertions(+), 15 deletions(-) create mode 100644 settingtypes.txt diff --git a/init.lua b/init.lua index c0aba62..cab47d4 100644 --- a/init.lua +++ b/init.lua @@ -15,13 +15,54 @@ dofile( minetest.get_modpath( "digtron" ) .. "/node_axle.lua" ) -- Rotation cont dofile( minetest.get_modpath( "digtron" ) .. "/node_crate.lua" ) -- Digtron portability support dofile( minetest.get_modpath( "digtron" ) .. "/recipes.lua" ) -digtron.creative_mode = false -- this causes digtrons to operate without consuming fuel or building materials. -digtron.particle_effects = true -- Enables the spray of particles out the back of a digger head and puffs of smoke from the controller -digtron.lava_impassible = true -- when true, lava counts as protected nodes. -digtron.diggers_damage_creatures = true -- when true, diggers deal damage to creatures when they trigger. +-- Enables the spray of particles out the back of a digger head and puffs of smoke from the controller +local particle_effects = minetest.setting_getbool("enable_particles") -digtron.cycle_time = 1 -- How many seconds a digtron waits between cycles. Auto-controllers can make this wait longer, but cannot make it shorter. -digtron.traction_factor = 3.0 -- How many digtron nodes can be moved for each adjacent solid node that the digtron has traction against +-- this causes digtrons to operate without consuming fuel or building materials. +local digtron_creative = minetest.setting_getbool("digtron_creative_mode") +-- when true, lava counts as protected nodes. +local lava_impassible = minetest.setting_getbool("digtron_lava_impassible") + +-- when true, diggers deal damage to creatures when they trigger. +local damage_creatures = minetest.setting_getbool("digtron_damage_creatures") + +digtron.creative_mode = digtron_creative -- 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 + +-- Enables the spray of particles out the back of a digger head and puffs of smoke from the controller +local particle_effects = minetest.setting_getbool("enable_particles") + +-- this causes digtrons to operate without consuming fuel or building materials. +local digtron_creative = minetest.setting_getbool("digtron_creative_mode") + +-- when true, lava counts as protected nodes. +local lava_impassible = minetest.setting_getbool("digtron_lava_impassible") + +-- when true, diggers deal damage to creatures when they trigger. +local damage_creatures = minetest.setting_getbool("digtron_damage_creatures") + +digtron.creative_mode = digtron_creative -- 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 + +-- 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.setting_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.setting_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: -- one default tree block is 30 units @@ -29,15 +70,41 @@ digtron.traction_factor = 3.0 -- How many digtron nodes can be moved for each ad -- one coal block is 370 units (apparently it's slightly more productive making your coal lumps into blocks before burning) -- one book is 3 units -local dig_cost_adjustment_factor = 0.5 -- across-the-board multiplier to make overall fuel costs easier to modify - -digtron.dig_cost_default = 1.0 * dig_cost_adjustment_factor -- how much fuel is required to dig a node if not in one of the following groups. --- If a node is in more than one of the following groups, the group with the maximum cost for that node is used. -digtron.dig_cost_cracky = 2.0 * dig_cost_adjustment_factor -- eg, stone -digtron.dig_cost_crumbly = 1.0 * dig_cost_adjustment_factor -- eg, dirt, sand -digtron.dig_cost_choppy = 1.5 * dig_cost_adjustment_factor -- eg, wood - -digtron.build_cost = 1.0 -- how much fuel is required to build a node +-- how much fuel is required to dig a node if not in one of the following groups. +local digtron_dig_cost_default = tonumber(minetest.setting_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 +-- eg, stone +local digtron_dig_cost_cracky = tonumber(minetest.setting_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 +-- eg, dirt, sand +local digtron_dig_cost_crumbly = tonumber(minetest.setting_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 +-- eg, wood +local digtron_dig_cost_choppy = tonumber(minetest.setting_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 +-- how much fuel is required to build a node +local digtron_build_cost = tonumber(minetest.setting_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 -- digtron group numbers: -- 1 - generic digtron node, nothing special is done with these. They're just dragged along. diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..f19bb67 --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1,27 @@ +#This causes digtrons to operate without consuming fuel or building materials. +#It's a separate setting from regular creative mode. +digtron_creative_mode (Digtron requires fuel) bool false +#When true, lava counts as protected blocks. +digtron_lava_impassible (Lava is impassible to Digtrons) bool true +#When true, diggers deal damage to creatures when they trigger. +digtron_damage_creatures (Digtrons cause damage) bool true +#How many seconds a digtron waits between cycles. +#Auto-controllers can make this wait longer, but cannot make it shorter. +digtron_cycle_time (Minimum Digtron cycle time in seconds) float 1.0 0.0 60.0 +#How many Digtron blocks can be moved for each adjacent +#solid block that the Digtron has traction against +digtron_traction_factor (Digtron traction factor) float 3.0 0.0 1000.0 +#eg, stone. +#In a default Minetest game one lump of coal provides 40.0 units of fuel. +digtron_dig_cost_cracky (Digtron dig fuel cost for cracky blocks) float 1.0 0.0 100.0 +# eg, dirt, sand. +#In a default Minetest game one lump of coal provides 40.0 units of fuel. +digtron_dig_cost_crumbly (Digtron dig fuel cost for crumbly blocks) float 0.5 0.0 100.0 +#eg, wood. +#In a default Minetest game one lump of coal provides 40.0 units of fuel. +digtron_dig_cost_choppy (Digtron dig fuel cost for choppy blocks) float 0.75 0.0 100.0 +#Fuel cost to dig a block that doesn't fall into one of the other categories. +#In a default Minetest game one lump of coal provides 40.0 units of fuel. +digtron_dig_cost_default (Digtron fuel dig cost for other block types) float 0.5 0.0 100.0 +#How much fuel is required to build a block +digtron_build_cost (Digtron fuel cost to build one block) float 1.0 0.0 100.0