Edit: Gah, I've been ninja'd.
Thanks for the quick reply, I failed to say that I was trying to call these peripherals over a wired modem… Ooops!
I tried to adapt your code to this:
t = {}
t[1] = "glowstone_illuminator_0"
t[2] = "glowstone_illuminator_1" -- Both can be accessed by the peripheral.call
for i = 1,#t do
t[i].setColor(0x00FFFF)
end
I had no luck in executing the command, anything else you can recommend?
You've just inserted the names of the peripherals into the table. What you want to insert instead is the actual wrapped object. Below is an example of what you want to do
local t = {} --# A table can contain any Lua type, including numbers, functions, strings, and other tables.
--# This particular table will contain all of the wrapped objects returned by peripheral.wrap
t[1] = peripheral.wrap("glowstone_illuminator_0") --# By typing 't[1]', we specify that we are inserting the result
--# of peripheral.wrap into the first slot of the table
t[2] = peripheral.wrap("glowstone_illuminator_1") --# Now we insert the next result into the second slot
for i=1,#t do --# This loop will go from the first element of the table to the last element of the table. In this case, just 2 elements
t[i].setColor(0x00FFFF)
end
If you have a lot of the glowstone illuminators, you'll probably want an easier way to wrap all of them without typing it out manually. In this case, we can take advantage of the pattern each wrapped illuminator follows (illuminator_0, illuminator_1, illuminator_2).
A for loop is perfect for this:
local t = {} --# Our wrapped objects table
for count=0, 5 do --# Assuming that we have 6 glowstone illuminators, because we start counting at 0 rather than 1
t[count] = peripheral.wrap("glowstone_illuminator_"..count) --# The .. operator will concatenate (join) the "glowstone_illuminator_" string with the count
end
And then you could use another for loop like in the first example to do the setColor function on each illuminator.