outlet fix - when switching station disconnects or looses power
This commit is contained in:
parent
c71e303842
commit
50bde1cfe0
10
mover.lua
10
mover.lua
@ -27,9 +27,11 @@ end
|
||||
local max_range = 10; -- machines range of operation
|
||||
local machines_timer = 5 -- timestep
|
||||
local machines_TTL = 4; -- time to live for signals
|
||||
|
||||
|
||||
MOVER_FUEL_STORAGE_CAPACITY = 5; -- how many operations from one coal lump - base unit
|
||||
basic_machines.fuels = {["default:coal_lump"]=1,["default:cactus"]=0.75,["default:tree"]=1,["default:jungletree"]=1,["default:pinetree"]=1,["default:coalblock"]=10,["default:lava_source"]=40};
|
||||
|
||||
|
||||
|
||||
|
||||
minetest.register_node("basic_machines:mover", {
|
||||
description = "Mover",
|
||||
@ -187,9 +189,9 @@ minetest.register_node("basic_machines:mover", {
|
||||
local cmeta = minetest.get_meta(fpos);
|
||||
local inv = cmeta:get_inventory();
|
||||
--fuels and their caloric value: 1 = 5 uses, TODO; add unknown fuels from minetest fuels
|
||||
local fuels = {["default:coal_lump"]=1,["default:cactus"]=0.75,["default:tree"]=1,["default:coalblock"]=10,["default:lava_source"]=40};
|
||||
|
||||
local stack;
|
||||
for i,v in pairs(fuels) do
|
||||
for i,v in pairs(basic_machines.fuels) do
|
||||
stack = ItemStack({name=i})
|
||||
if inv:contains_item("main", stack) then found_fuel = v;inv:remove_item("main", stack) break end
|
||||
end
|
||||
|
@ -55,11 +55,11 @@ function basic_machines.check_power(pos) -- mover checks power source
|
||||
|
||||
local meta = minetest.get_meta({x=pos.x,y=pos.y-1,z=pos.z});
|
||||
local p = minetest.string_to_pos(meta:get_string("station")); if not p then return end
|
||||
local smeta = minetest.get_meta(p);
|
||||
local smeta = minetest.get_meta(p); if not smeta then return end
|
||||
local infot = smeta:get_string("infotext");
|
||||
--local infot = "Switching Station. Supply: 516 Demand: 0";
|
||||
local i = string.find(infot,"Supply");
|
||||
local j = string.find(infot,"Demand");
|
||||
local i = string.find(infot,"Supply") or 1;
|
||||
local j = string.find(infot,"Demand") or 1;
|
||||
local supply = tonumber(string.sub(infot,i+8,j-1)) or 0;
|
||||
local demand = tonumber(string.sub(infot, j+8)) or 0;
|
||||
supply= supply-demand-(smeta:get_int("bdemand") or 999999);
|
||||
|
Loading…
x
Reference in New Issue
Block a user