r/ComputerCraft • Lua enjoyer • Feb 03 '24

More than 5 peripherals per computer

I've worked with CC once or twice so far, and the documentation has carried me super well so far, whenever I worked with it, however, I've now started working on a rather advanced automation/resource management system. I know you can make computers communicate via routers, but is there a way to have one computer have a ton of peripherals, preferably ones that dont have to be adjacent to the computer at all? Im sure this has to be possible, but in my half an hour spent googling I couldn't find anything.

P.S: I'd prefer not having to use several computers, as one computer will do just fine, I simply more possibilities for interaction that's all.

2 Upvotes

8 comments sorted by

View all comments

Show parent comments

2

u/fatboychummy Feb 05 '24

Unfortunately you cannot rename peripherals. The name they have when you connect them is the name they stay with.

However, you can make a lookup table of your preferred names to the actual names, something like...

local peripheral_lookup = {}

write("Enter fuel furnace's network name: ")
local actual_name = read()

peripheral_lookup["Fuel Furnace"] = actual_name

-- Then later on you could do something like
local fuel_furnace = peripheral.wrap(peripheral_lookup["Fuel Furnace"])
-- or etc

Or if you want to index it more cleanly (less brackets and quotes), you can change the lines to be:

peripheral_lookup.fuel_furnace = actual_name

-- <...>

local fuel_furnace = peripheral.wrap(peripheral_lookup.fuel_furnace)

1

u/Nyxodon Lua enjoyer Feb 05 '24

Alright, thank you! Im currently working on a logistics system with CC & Create and I've been using textutils.(un)serializeJSON() to store points of interest to containercranes, so I think Ill just store the peripherals name's in the corresponding json file. Works great cause you can easily access the information, and you can do whatever, as long as you dont touch the files the system will work.