5 posts
Posted 12 September 2016 - 03:57 PM
i am trying to use a name given by the user via io,read() as the name to be wrapped.
for example
newDevName=io.read()
newDevName=peripheral.wrap(DevName)
i have also tried using tostring(newDevName) but still get "
attempt to concatenate table and string"
Is their a work around for this.
if more info is needed please let me know.
3057 posts
Location
United States of America
Posted 12 September 2016 - 05:20 PM
That code will not give the error you specified. Please post the code that throws that error.
259 posts
Posted 12 September 2016 - 06:17 PM
Yeah more info is definitely needed. In that code DevName is not defined so that would throw an attempt to call nil, but not that error.
3057 posts
Location
United States of America
Posted 12 September 2016 - 07:57 PM
Yeah more info is definitely needed. In that code DevName is not defined so that would throw an attempt to call nil, but not that error.
It would not throw attempt to call nil. It would simply not wrap the peripheral.
5 posts
Posted 13 September 2016 - 02:59 AM
Here is an image of the error
@kingofGamesYami
The error is not saying it concatenated nil with anything.
and also the image shows the error message.
and the full code
http://pastebin.com/TZg9qyyk
259 posts
Posted 13 September 2016 - 03:08 AM
Really? I learned something.
5 posts
Posted 13 September 2016 - 03:31 AM
ok i fixed my issue, and improved functionality and shortened the code
Thanks for your help
726 posts
Location
Rem is best girl
Posted 13 September 2016 - 07:45 AM
your printing peripheral.wrap, which returns a table. If your trying to get a name of a peripheral use peripheral.getType()
67. newDevName=peripheral.wrap(DevName)
68. print(newDevName.." Assigned")
3057 posts
Location
United States of America
Posted 13 September 2016 - 12:18 PM
For anyone reading this in the future, wrapped peripherals are tables and cannot be concatenated with a string, which Linrox attempted to do on line 67.
5 posts
Posted 14 September 2016 - 04:31 AM
I didn't need to change the line at all it now works. I only had to move it into the k,v loop above it. Moved lines 65 & 66 up to line 63 before the end statement.
Here is the updated version. But still heavily a WIP.
726 posts
Location
Rem is best girl
Posted 14 September 2016 - 07:25 AM
Its coz you changed newDevname assigned to v assigned
also another thing, you can do peripheral.getSides() for a list of connected peripherals. (Its better as it can also detect stuff connected via rednet cables)
Also what is your program meant to do? xD