mirror of
https://github.com/theFox6/microexpansion.git
synced 2024-12-28 00:17:36 +01:00
fix serialization and logging
inventories are no longer overridden with their last contents during serialization all log messages are now prepended with "[MicroExpansion] "
This commit is contained in:
parent
abe36940a7
commit
383abf919d
@ -47,7 +47,7 @@ me.register_node("ctrl", {
|
||||
me_update = function(pos,_,ev)
|
||||
local cnet = me.get_network(pos)
|
||||
if cnet == nil then
|
||||
minetest.log("error","no network for ctrl at pos "..minetest.pos_to_string(pos))
|
||||
microexpansion.log("no network for ctrl at pos "..minetest.pos_to_string(pos),"error")
|
||||
return
|
||||
end
|
||||
cnet:update()
|
||||
|
@ -44,7 +44,7 @@ function me.insert_item(stack, inv, listname)
|
||||
-- bigger item count is not possible, we only have unsigned 16 bit
|
||||
if total_count <= math.pow(2,16) then
|
||||
if not inside:set_count(total_count) then
|
||||
minetest.log("error"," adding items to stack in microexpansion network failed")
|
||||
microexpansion.log("adding items to stack in microexpansion network failed","error")
|
||||
print("stack is now " .. inside:to_string())
|
||||
end
|
||||
inv:set_stack(listname, i, inside)
|
||||
@ -119,7 +119,7 @@ function me.get_connected_network(start_pos)
|
||||
end
|
||||
|
||||
function me.update_connected_machines(start_pos,event,include_start)
|
||||
minetest.log("action","updating connected machines")
|
||||
microexpansion.log("updating connected machines","action")
|
||||
local ev = event or {type = "n/a"}
|
||||
local sn = microexpansion.get_node(start_pos)
|
||||
local sd = minetest.registered_nodes[sn.name]
|
||||
|
@ -104,7 +104,7 @@ end
|
||||
function network:remove_power_capacity(power)
|
||||
self.power_storage = self.power_storage - power
|
||||
if self.power_storage < 0 then
|
||||
minetest.log("warning","[Microexpansion] power storage of network "..self.." dropped below zero")
|
||||
microexpansion.log("power storage of network "..self.." dropped below zero","warning")
|
||||
end
|
||||
end
|
||||
|
||||
@ -286,6 +286,10 @@ function network:serialize()
|
||||
for i,v in pairs(self) do
|
||||
if i == "inv" then
|
||||
sert.strinv = self:save_inventory()
|
||||
elseif i == "strinv" then
|
||||
if not sert.strinv then
|
||||
sert[i] = v
|
||||
end
|
||||
else
|
||||
sert[i] = v
|
||||
end
|
||||
|
@ -72,7 +72,7 @@ function microexpansion.move_inv(inv1, inv2, max)
|
||||
local leftover = tinv:add_item(tname, v)
|
||||
finv:remove_item(fname, v)
|
||||
if leftover and not(leftover:is_empty()) then
|
||||
minetest.log("warning","leftover items when transfering inventory")
|
||||
microexpansion.log("leftover items when transferring inventory","warning")
|
||||
finv:add_item(fname, leftover)
|
||||
end
|
||||
end
|
||||
|
@ -118,7 +118,7 @@ local function write_drive_cells(pos,network)
|
||||
item_string = item_string:split(" ")
|
||||
local item_count = stack_inside:get_count()
|
||||
if item_count > 1 and item_string[2] ~= tostring(item_count) then
|
||||
minetest.log("warning","[microexpansion] stack count differs from second field of the item string")
|
||||
microexpansion.log("stack count differs from second field of the item string","warning")
|
||||
end
|
||||
while item_count ~= 0 and cell_idx ~= nil do
|
||||
--print(("stack to store: %q"):format(table.concat(item_string," ")))
|
||||
@ -132,7 +132,7 @@ local function write_drive_cells(pos,network)
|
||||
cell_idx = next(cells, cell_idx)
|
||||
if cell_idx == nil then
|
||||
--there may be other drives within the network
|
||||
minetest.log("info","too many items to store in drive")
|
||||
microexpansion.log("too many items to store in drive","info")
|
||||
break
|
||||
end
|
||||
size = microexpansion.get_cell_size(cells[cell_idx]:get_name())
|
||||
@ -213,7 +213,7 @@ local function add_all(pos,net)
|
||||
end
|
||||
|
||||
function me.disconnect_drive(pos,ncpos)
|
||||
minetest.log("action","disconnecting drive at "..minetest.pos_to_string(pos))
|
||||
microexpansion.log("disconnecting drive at "..minetest.pos_to_string(pos),"action")
|
||||
local fc,i = get_drive_controller(pos)
|
||||
if not fc.cpos then
|
||||
return
|
||||
@ -228,7 +228,7 @@ function me.disconnect_drive(pos,ncpos)
|
||||
if fnet then
|
||||
take_all(pos,fnet)
|
||||
else
|
||||
minetest.log("warning","drive couldn't take items from its former network")
|
||||
microexpansion.log("drive couldn't take items from its former network","warning")
|
||||
end
|
||||
end
|
||||
|
||||
@ -240,15 +240,15 @@ local function update_drive(pos,_,ev)
|
||||
local cnet = ev.net or me.get_connected_network(pos)
|
||||
if cnet then
|
||||
if not fc then
|
||||
minetest.log("action","connecting drive at "..minetest.pos_to_string(pos))
|
||||
microexpansion.log("connecting drive at "..minetest.pos_to_string(pos),"action")
|
||||
set_drive_controller(pos,true,cnet.controller_pos,i)
|
||||
add_all(pos,cnet)
|
||||
elseif not fc.cpos then
|
||||
minetest.log("action","connecting drive at "..minetest.pos_to_string(pos))
|
||||
microexpansion.log("connecting drive at "..minetest.pos_to_string(pos),"action")
|
||||
set_drive_controller(pos,false,cnet.controller_pos,i)
|
||||
add_all(pos,cnet)
|
||||
elseif not vector.equals(fc.cpos,cnet.controller_pos) then
|
||||
minetest.log("action","reconnecting drive at "..minetest.pos_to_string(pos))
|
||||
microexpansion.log("reconnecting drive at "..minetest.pos_to_string(pos),"action")
|
||||
write_drive_cells(pos,me.get_network(fc.cpos))
|
||||
set_drive_controller(pos,false,cnet.controller_pos,i)
|
||||
add_all(pos,cnet)
|
||||
|
@ -171,15 +171,15 @@ microexpansion.register_node("term", {
|
||||
local net,cp = me.get_connected_network(pos)
|
||||
if net then
|
||||
if cp then
|
||||
minetest.log("info","network and ctrl_pos")
|
||||
microexpansion.log("network and ctrl_pos","info")
|
||||
else
|
||||
minetest.log("warning","network but no ctrl_pos")
|
||||
microexpansion.log("network but no ctrl_pos","warning")
|
||||
end
|
||||
else
|
||||
if cp then
|
||||
minetest.log("warning","no network but ctrl_pos")
|
||||
microexpansion.log("no network but ctrl_pos","warning")
|
||||
else
|
||||
minetest.log("info","no network and no ctrl_pos")
|
||||
microexpansion.log("no network and no ctrl_pos","info")
|
||||
end
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
@ -190,7 +190,7 @@ microexpansion.register_node("term", {
|
||||
if cp then
|
||||
ctrl_inv = net:get_inventory()
|
||||
else
|
||||
minetest.log("warning","no network connected")
|
||||
microexpansion.log("no network connected","warning")
|
||||
return
|
||||
end
|
||||
local inv
|
||||
|
Loading…
Reference in New Issue
Block a user