cc-tweaked / CC-Tweaked

Just another ComputerCraft fork
https://tweaked.cc
913 stars 208 forks source link

Add wireless modem power control #1688

Open hugeblank opened 7 months ago

hugeblank commented 7 months ago

The premise is fairly simple, add a couple of additional methods onto the wireless modem that get/set a radius, in blocks, where messages can be transmitted. This could be done in a couple of ways:

  1. Percentage, where 100% is the maximum distance the modem can transmit, and 0% is the singular block that the modem is in.
  2. Radius, where the maximum is the longest range the modem can transmit without restriction (eg. 64 blocks), and the minimum is 0, again being the single block area where the modem exists.

Why? My primary use-case is inventory-contained networking for things like pocket computers, or plethora's neural interfaces. To be able to set the transmit radius to 0 would give wired modem-like functionality to all pocket computers. However, I think this could be useful beyond that, like in a base within a heavily populated spawn area. Limiting the modem's power could reduce the amount of computers that end up processing the message considerably.

This request partially depends on #955, unfortunately. Ender modems simply should not have the ability to capture a transmission from a wireless modem that can't even transmit more than a block away. The idea of a local in-inventory network also gets broken due to this.

hugeblank commented 7 months ago

This report is a bit subversive, as my goal is in-inventory networking, and not necessarily to refactor/break modems. An entirely new peripheral could also fulfill the need I have and I would be just as happy. The way proposed above is the one that makes the most sense to me, given the confines of CC and the peripherals within.

Lupus590 commented 7 months ago

Maybe pocket computers should be able to talk to other pocket computers in the same inventory even without a wireless modem. With some creative usage, one could simulate having pocket computers with multiple peripherals.

Wojbie commented 7 months ago

I kinda question usefulness of 0 power messages? Like it would allow you to have 2 pockets talk with each other but then you have 2 pockets with wireless modems.. And that don't really increase ability of things you can do? Anything you could do with 2 wireless pockets you can do with just one wireless pocket.

And without ^ i kinda fail to see usefulness of reducing amount of computers that will see and then ignore your message. Feels like most users would just keep transmitting at full power and this would have low amount of actual use.

hugeblank commented 7 months ago

Anything you could do with 2 wireless pockets you can do with just one wireless pocket.

You're right. This should be a functionality that's inherent to pocket computers/inventory devices. That way one can do something like have 2 connected pocket computers: one with a speaker, and one with a modem. (Seemingly the same conclusion that was arrived at by #1406)

SquidDev commented 7 months ago

Maybe pocket computers should be able to talk to other pocket computers in the same inventory even without a wireless modem.

This was also mentioned in #1406, and I ... I have mixed feeling about it.

I do actually really like it as an idea. I think it introduces a fun programming challenge (distributed systems and networking is hard!) and some interesting trade-offs (adding a new "upgrade" consumes a full inventory slot, and those are valuable).

There's a bit of me which would even be inclined to take it further and take inspiration from TIS-100 - pocket computers should only be able to talk to those adjacent to them in the inventory. Though maybe that's more cutsey than actually engaging to use.

That all said, I'm not sure how ComputerCraft-y it feels as an idea. I'm aware that's a kinda nebulous term that can be used to shoot down any idea, I'm guess I'm just unsure about it and can't put my finger on why that is!

hugeblank commented 7 months ago

I've attempted an implementation in #1689, feel free to play around with it. I actually like it a lot more than I thought, given the original idea with limiting proposed in this issue.