mt-mods / technic

Technic mod for Minetest
18 stars 25 forks source link

Mesecon and digiline functionality of switching station #346

Open OgelGames opened 9 months ago

OgelGames commented 9 months ago

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.

https://github.com/mt-mods/technic/blob/04b0663d844ac70c44dd918e38942290afc6d5ef/technic/machines/switching_station.lua#L104-L116

BuckarooBanzay commented 9 months ago

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

S-S-X commented 9 months ago

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.

S-S-X commented 9 months ago

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.

FeXoR-o-Illuria commented 9 months ago

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

S-S-X commented 9 months ago

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.

S-S-X commented 9 months ago

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.