mt-mods / technic

Technic mod for Minetest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mesecon and digiline functionality of switching station

OgelGames opened this issue · comments

Currently the switching station uses mesecons to enable "notification" messages being sent via digilines. Maybe that toggle could be moved to a checkbox in the formspec, so mesecons can be used to turn the network on and off.

-- If mesecon signal enabled and power supply or demand changed then send them via digilines.
if mesecons_path and digilines_path and mesecon.is_powered(pos) then
local network = technic.networks[network_id]
if meta:get_int("supply") ~= network.supply or meta:get_int("demand") ~= network.demand then
meta:set_int("supply", network.supply)
meta:set_int("demand", network.demand)
local channel = meta:get_string("channel")
digilines.receptor_send(pos, technic.digilines.rules, channel, {
supply = network.supply,
demand = network.demand
})
end
end

IMO: the mesecons-toggle is pretty weird, 👍 for a formspec solution (maybe even put demand/supply-fields and an enabled-button into it 😏)

commented

This would have to be network wide synced configuration for all connected switching stations. Metadata could be used for this but doesn't really sound like a good way to do it.
Currently networks are stateless between restarts, probably would need to have some kind of network wide storage.
There's many ways to mess it up so best to plan it well, just simple global storage might sound like a good solution but there's some issues also with that.

commented

Well, simple option could of course be to make it just switching station specific thing, ignore multi switch stuff and just let (possible) other switching stations to override it.
Then multi switch networks at first might seem to work bit weird but probably wouldn't be too bad or too hard to learn.
Important thing would be that switching station would be turned off so it wouldn't attempt to actively shut down the network while possible other switch would keep fighting it. So just shut it down once when player hits button/checkbox and disable nodetimer until player enables it again.

That should be possible by simply setting network ttl to zero and turning off nodetimer.

I agree with @OgelGames that the behavior is at least untypical.

I don't use this feature but could at least imagine some use cases.

I also agree a checkbox in the formspec would be a more obvious way.

If this is to replace the current mesecons toggle that possibility would be gone - though if the node isn't stateless between restarts any longer I guess a digiline toggle could be added, too

commented

though if the node isn't stateless between restarts any longer I guess a digiline toggle could be added, too

Networks being stateless is mostly issue with multi switch networks, keeping a node state will work just fine with single switch networks no issue with that. Would only affect multi switch networks. So single switch is straightforward but multi switch might be a bit confusing at first but still fairly easy to learn through trial and error.

commented

Could be interestin if digicables / digiline connection would be used to sync switch configuration. So without actual connection they would not sync but if connected it would sync automatically, actual digiline message could be used to achieve this.