mirror of
https://github.com/theFox6/microexpansion.git
synced 2024-11-22 15:13:51 +01:00
fix old networks with lbm
This commit is contained in:
parent
6c79e7ce60
commit
2be2eea4d8
@ -97,7 +97,7 @@ me.register_node("ctrl", {
|
|||||||
end
|
end
|
||||||
if not net then
|
if not net then
|
||||||
me.log("ME Network Controller without Network","error")
|
me.log("ME Network Controller without Network","error")
|
||||||
return false
|
return true
|
||||||
end
|
end
|
||||||
return net:get_access_level(name) >= access_level.full
|
return net:get_access_level(name) >= access_level.full
|
||||||
end,
|
end,
|
||||||
@ -131,6 +131,39 @@ me.register_node("ctrl", {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_lbm({
|
||||||
|
name = "microexpansion:update_network",
|
||||||
|
label = "integrate new ME Network data",
|
||||||
|
nodenames = {"microexpansion:ctrl"},
|
||||||
|
run_at_every_load = true,
|
||||||
|
action = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local net,idx = me.get_network(pos)
|
||||||
|
if not meta then
|
||||||
|
me.log("activated controller before metadata was available", "warning")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local source = meta:get_string("source")
|
||||||
|
if not net then
|
||||||
|
if source == "" then
|
||||||
|
me.log("activated controller without network", "warning")
|
||||||
|
return
|
||||||
|
else
|
||||||
|
net = me.get_network(vector.from_string(source))
|
||||||
|
if not net then
|
||||||
|
me.log("activated controller that is linked to an unloaded controller", "info")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not net.access then
|
||||||
|
me.log("added access table to old network", "action")
|
||||||
|
net.access = {}
|
||||||
|
end
|
||||||
|
net:fallback_access()
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
-- [register node] Cable
|
-- [register node] Cable
|
||||||
me.register_machine("cable", {
|
me.register_machine("cable", {
|
||||||
description = "ME Cable",
|
description = "ME Cable",
|
||||||
@ -173,6 +206,7 @@ me.register_machine("cable", {
|
|||||||
return net:get_access_level(name) >= access_level.modify
|
return net:get_access_level(name) >= access_level.modify
|
||||||
end,
|
end,
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
|
--perhaps this needs to be done after the check if it can be placed
|
||||||
me.send_event(pos,"connect")
|
me.send_event(pos,"connect")
|
||||||
end,
|
end,
|
||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
@ -186,6 +220,7 @@ me.register_machine("cable", {
|
|||||||
--minetest.remove_node(pos)
|
--minetest.remove_node(pos)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
--TODO: prevent connecting multiple networks
|
||||||
local net,cp = me.get_connected_network(pos)
|
local net,cp = me.get_connected_network(pos)
|
||||||
if not net then
|
if not net then
|
||||||
return false
|
return false
|
||||||
|
@ -353,11 +353,6 @@ function network:load()
|
|||||||
if self.strinv then
|
if self.strinv then
|
||||||
self:load_inventory(self.strinv)
|
self:load_inventory(self.strinv)
|
||||||
end
|
end
|
||||||
--make sure someone has access to the network
|
|
||||||
if not self.access then
|
|
||||||
self.access = {}
|
|
||||||
end
|
|
||||||
self:fallback_access()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function network:serialize()
|
function network:serialize()
|
||||||
|
Loading…
Reference in New Issue
Block a user