summaryrefslogtreecommitdiff
path: root/util_execute_cycle.lua
diff options
context:
space:
mode:
Diffstat (limited to 'util_execute_cycle.lua')
-rw-r--r--util_execute_cycle.lua69
1 files changed, 58 insertions, 11 deletions
diff --git a/util_execute_cycle.lua b/util_execute_cycle.lua
index 38f4381..4a0e50a 100644
--- a/util_execute_cycle.lua
+++ b/util_execute_cycle.lua
@@ -108,6 +108,7 @@ digtron.execute_dig_cycle = function(pos, clicker)
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 = S("Heat remaining in controller furnace: @1", math.max(0, fuel_burning))
+ local exhaust = meta:get_int("on_coal")
local layout = DigtronLayout.create(pos, clicker)
@@ -206,8 +207,20 @@ digtron.execute_dig_cycle = function(pos, clicker)
local test_fuel_needed = test_build_fuel_cost + digging_fuel_cost - fuel_burning
local test_fuel_burned = 0
+-- if test_fuel_needed > 0 then
+-- test_fuel_burned = digtron.burn(layout.fuelstores, test_fuel_needed, true)
+-- end
+
if test_fuel_needed > 0 then
- test_fuel_burned = digtron.burn(layout.fuelstores, test_fuel_needed, true)
+ -- check for the available electrical power
+ test_fuel_burned = digtron.tap_batteries(layout.battery_holders, test_fuel_needed, true)
+ end
+ if (test_fuel_needed < test_fuel_burned) then
+ exhaust = 0 -- all power needs met by electricity, don't blow smoke
+ else
+ -- burn combustible fuel if not enough power
+ test_fuel_burned = test_fuel_burned + digtron.burn(layout.fuelstores, test_fuel_needed - test_fuel_burned, true)
+ exhaust = 1 -- burning fuel produces smoke
end
--Put everything back where it came from
@@ -303,16 +316,32 @@ digtron.execute_dig_cycle = function(pos, clicker)
status_text = S("Digtron unexpectedly failed to execute one or more build operations, likely due to an inventory error.") .. "\n"
end
- -- acutally burn the fuel needed
- local fuel_cost = digging_fuel_cost + building_fuel_cost
- fuel_burning = fuel_burning - fuel_cost
- if digtron.config.particle_effects then
- table.insert(particle_systems, burn_smoke(pos, fuel_cost))
+-- -- acutally burn the fuel needed
+-- local fuel_cost = digging_fuel_cost + building_fuel_cost
+-- fuel_burning = fuel_burning - fuel_cost
+-- 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
+
+ -- actually burn the fuel needed
+ fuel_burning = fuel_burning - digging_fuel_cost
+ if digtron.particle_effects and exhaust == 1 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)
+ -- we tap into the batteries either way
+ fuel_burning = fuel_burning + digtron.tap_batteries(layout.battery_holders, -fuel_burning, false)
+ if exhaust == 1 then
+ -- but we burn coal only if we must (exhaust = flag)
+ fuel_burning = fuel_burning + digtron.burn(layout.fuelstores, -fuel_burning, false)
+ end
end
+
meta:set_float("fuel_burning", fuel_burning)
+ meta:set_int("on_coal", exhaust)
status_text = status_text .. S("Heat remaining in controller furnace: @1", math.max(0, fuel_burning))
-- Eyecandy
@@ -391,7 +420,8 @@ digtron.execute_downward_dig_cycle = function(pos, clicker)
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 = S("Heat remaining in controller furnace: @1", math.max(0, fuel_burning))
-
+ local exhaust = meta:get_int("on_coal")
+
local layout = DigtronLayout.create(pos, clicker)
local status_text, return_code = neighbour_test(layout, status_text, dir)
@@ -492,15 +522,32 @@ digtron.execute_downward_dig_cycle = function(pos, clicker)
local status_text = ""
- -- acutally burn the fuel needed
+-- -- acutally burn the fuel needed
+-- fuel_burning = fuel_burning - digging_fuel_cost
+-- 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
+
+ -- actually burn the fuel needed
fuel_burning = fuel_burning - digging_fuel_cost
- if digtron.config.particle_effects then
+ if digtron.particle_effects and exhaust == 1 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)
+ -- we tap into the batteries either way
+ fuel_burning = fuel_burning + digtron.tap_batteries(layout.battery_holders, -fuel_burning, false)
+ if exhaust == 1 then
+ -- but we burn coal only if we must (exhaust = flag)
+ fuel_burning = fuel_burning + digtron.burn(layout.fuelstores, -fuel_burning, false)
+ end
end
+
+
meta:set_float("fuel_burning", fuel_burning)
+ meta:set_int("on_coal", exhaust)
status_text = status_text .. S("Heat remaining in controller furnace: @1", math.max(0, fuel_burning))
-- Eyecandy