Shortwave Fixed


Connect circuit networks via shortwave radio channels.

Content
5 months ago
1.1 - 2.0
2.46K
Circuit network

i Dynamic channel

4 months ago

This mod is great!
I was kind of bummed that we don't have channels on radar circuits in 2.0, but this mod manages to fix it nicely. Thanks for updating it!
I was wondering - would it be possible to implement a way to set the channels via circuit?

I came up with that because I wanted to scan across some channels (for example, getting info from the iron plate (1), iron plate (2) and iron plate(3) for some circuits).
Right now you can set up 3 radios, manually set their channels, connect each to a combinator and a clock, and then merge the output of all the combinators to get the info from the different channels one each clock.

However, it might get burdensome if you want to listen to 20 channels (20 combinators), or 100 (100 combinators).

If we could set channel via circuit, we would only need a clock (that goes through iron plate 1 to 200) and a shortwave radio to do the same job.
For it to work, you just take the whole wire (so all signals) and copy both their order and amount.

Hopefully it isn't impossible.
Best wishes.

4 months ago
(updated 4 months ago)

Hi, glad you enjoy this mod! That is an interesting idea--we could call it a "software defined radio". The downside is that with the current system, it will have a large impact on UPS. Every time a radio is retuned, it breaks and makes hidden circuit wire connections, which both triggers events and makes the game recompute a bunch of things that aren't typically expected to happen all the time.

With fixed channel settings we have now, that means no mod code is needed to send the signals every tick. Changing it to either route the signals using scripts instead of wires, or have potentially make and break wire connections every tick, would get laggy with more than a few radios. And it's outside the scope that I have time to support.

I would rather encourage the optimization of your current setup. There are plenty of ways you can multiplex signals onto the same channel, or have multiple radios like you currently do.

4 months ago

Hi, got a little impatient anddd...
I have a working implementation, that apparently doesn't murder UPS!

4 months ago

I'll send you a .patch file in a bit if you want to test it. It uses defines.events.on_entity_logistic_slot_changed instead of defines.events.on_tick (which did severely impact performance in my testing)

4 months ago

That's super interesting! I guess you are using a dummy requester chest entity to connect the signal-setting wire?

4 months ago
(updated 4 months ago)

Sorry for the delay. Here's what I had:

https://pastebin.com/U3qhQsWh

You can use the patch command in an unix system or GnuWin32 in Windows to apply the patch to the mod. It's plaintext, you can parse it beforehand if you want.

I got excited because defines.events.on_entity_logistic_slot_changed was working, but failed to notice I was using retune_all() instead of radio_tune(). So it works well when there are few radios, but with 48K radios it does create lag spikes. I was using just another constant combinator to change the group value, which did work, but it brings other problems - I thought on_entity_logistic_slot_changed's LuaLogisticSection would store as "owner" all entities that had the same logistic group, but it doesn't. It only stores the owner of the change, so I can't find the radio to use radio_tune(). As you say, I think I need to make the changes happen automatically within the radio.

I think trying to make a compound entity (a radio + something like the logistic group combinator https://mods.factorio.com/mod/logistic-group-combinator) might work well. While logistic-group-combinator does use on_tick, and so the compound entity wouldn't scale, you could have 99% normal radios and only the few radios that use the compound entity would be polled every tick. And only those 1% of radios would need to call radio_tune (and only if their logistic group changed)

4 months ago

If its outside the scope I understand. It does take a while to do these things :p

4 months ago

Yeah, that's basically what I was thinking. Make a special entity where you can wire to the "knob" side of it, then in on_tick read the circuit contents to see if it changed and only retune that radio when it changes.

As far as which channel to tune it to, I assume it would be the concatenation of all the signals on the wire, just like the static tuning is the concatenation of all the signals in the constant combinator logistics group. So you'd have to be careful what was on the wire you used for tuning.

4 months ago

I get the modding itch every few months and this seems doable.

4 months ago

Well, thanks! If you want any help with a task feel free to ask and I should be able to do a PR. I have only worked with non-compound entities in the data stage so I'm not that familiar with runtime, but I got here at least :P.

New response