CC: Tweaked

CC: Tweaked

59M Downloads

Custom names for modems/peripherals?

chuman72486 opened this issue ยท 2 comments

commented

Useful information to include:

  • Explanation of how the feature/change should work.
  • Some rationale/use case for a feature. My general approach to designing new features is to ask yourself "what issue are we trying to solve" and then "is this the best way to solve this issue?".

If it's not already an option, I'd like to suggest a method of naming or renaming peripherals on a wired network.
Right now I'm building a rather large wired network with lots of peripherals. This has resulted in a complicated mess of peripheral names and unless I wrote everything down and made additional note if I had to break and move a modem (which changes the peripheral name), it's easy to lose track of which peripheral is which. If it were possible to manually name a peripheral, or give it a label that remains after breaking and reconnecting modems, and allow wrap() to find it by this new label, that would simplify a lot of the process and make code more reusable.

Similar to how computers and turtles can have labels, there should be a way to label the modem connection and peripherals with a more intuitive name.

Example: I have three monitors and some redstone relays to control doors. It took a lot of rewiring to get everything organized, so now I have code that looks like:

local frontDoor = peripheral.wrap('redstoneRelay_2')
local sideDoor = peripheral.wrap('redstoneRelay_5')
local backDoor = peripheral.wrap('redstoneRelay_3')
local frontScreen = peripheral.wrap('monitor_0')
local backScreen = peripheral.wrap('monitor_3')
local insideScreen = peripheral.wrap('monitor_1')

but it could be changed to look like:

local frontDoor = peripheral.wrap('frontDoor')
local sideDoor = peripheral.wrap('sideDoor')
local backDoor = peripheral.wrap('backDoor')
local frontScreen = peripheral.wrap('frontScreen')
local backScreen = peripheral.wrap('backScreen')
local insideScreen = peripheral.wrap('insideScreen')

and no matter how many times I rewire the network, those peripherals will always connect with their labels, instead of generic peripheral name and number (which keeps increasing, even when the earlier connection is gone. Easy to end up with monitor_219 in your network because you've been building lots of different computers over months of gameplay.

The process of naming a peripheral could be as simple as a configuration tool that you sneak-click the modem or peripheral with to add a label (probably stored in NBT on the block, so it's preserved if you break the block and place it somewhere else or connect a different modem/computer to it), or using the value from a nametag/anvil rename to generate the peripheral name. This would need to be able to add labels to non CC:T blocks, like a chest or machine that shows up as an inventory peripheral.
Naming a peripheral can also be useful for directly connected peripherals, such as if a Turtle walks up to a chest, the label can help the turtle know which chest it connected to. For mods like Sophisticated Backpacks, the backpacks can be placed on the ground like a block and interacted with as if they were a chest, so it would be useful for the computer to be able to read the label to know which backpack you put down, so it can interact with it appropriately (load the backpack with supplies, or take out stuff from a recent mining trip and put it away in storage, etc)

commented

In the event that two peripherals have the same label, the system can append a number, the same as if two directly connected peripherals had the same type (like inventory_0, inventory_1, but instead frontDoor_1, frontDoor_2)

commented

Related: #78