This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
MCProtect's profile picture

Advanced Computers with OpenPeripheralAddons

Started by MCProtect, 24 September 2015 - 10:31 PM
MCProtect #1
Posted 25 September 2015 - 12:31 AM
I can't seem to get my Advanced Computer to interact with my Terminal Glasses Bridge from OpenPeripheralAddons.

The regular Computer works fine, and lists the functions in the autocomplete and everything while editing a program, and Lua interaction on the Advanced Computer works as well, but it doesn't work while editing the program.

Is there something extra that I need to do with my Advanced Computer to make it work and recognize the Bridge as a peripheral while editing a program, or is this a legitimate bug preventing me from doing so entirely when I otherwise should be able to? This is the code that I tried to test it with:


glass = peripheral.wrap("right")
glass.addBox(5,5,20,80,0xFFFFFF,0.3)
glass.addText(6,6,"Test Text",0x000000)
glass.sync()
Lyqyd #2
Posted 25 September 2015 - 03:35 PM
Is the bridge to the right of the advanced computer?
Bomb Bloke #3
Posted 25 September 2015 - 04:31 PM
Off the top of my head, autocomplete can only detect functions available to a peripheral if an actual pointer to that table is loaded into memory under the name which you want autocomplete to function with.

Since you're loading "glass" into the global scope, it'll stay loaded in memory when your script finishes execution (as everything in the global scope stays there until the computer reboots).

That is to say, save and run the script once, and then the editor will probably start working the way you want it to. But until the first line actually executes and creates the "glass" table, autocomplete has no reference with which to figure out what functions might be in it.
MCProtect #4
Posted 26 September 2015 - 08:52 PM
Off the top of my head, autocomplete can only detect functions available to a peripheral if an actual pointer to that table is loaded into memory under the name which you want autocomplete to function with.

Since you're loading "glass" into the global scope, it'll stay loaded in memory when your script finishes execution (as everything in the global scope stays there until the computer reboots).

That is to say, save and run the script once, and then the editor will probably start working the way you want it to. But until the first line actually executes and creates the "glass" table, autocomplete has no reference with which to figure out what functions might be in it.

The regular computer has no issue with it, however. I have saved and ran the script multiple times on the Advanced Computer (which wasn't necessary in the first place for the regular Computer) but it still fails to autocomplete, and the program will not work at all, but will work with the regular Computer.
Edited on 26 September 2015 - 08:22 PM
Bomb Bloke #5
Posted 27 September 2015 - 03:50 AM
Testing things out, I find they're as I said: you must run the command which sets "glass" to point to your wrapped peripheral before autocomplete can provide the function names attached to it. This goes for every reboot of your system, whether it's an Advanced Computer or otherwise. If it IS an Advanced Computer, then you must run the script in the same tab you want to edit it with.

Note that running the script using the "run" option offered within the edit script won't work for this purpose - this is because a unique environment table is used to only temporarily store the script's globals if you execute it that way, and they'll be cleaned up when it ends. You must exit the editor and run the script via the command line if you want the globals to stay resident in memory, where auto-complete can get at them.

Truth be told, you would ideally be localising "glass" to your script so that it isn't persisting in memory once execution finishes no matter how you run it. Sure, keeping it in RAM after execution allows auto-complete to work with it (because auto-complete works with ANY tables that happen to be floating about in memory), but that's not exactly an intended usage of auto-complete…

and the program will not work at all

So what DOES it do? If it throws an error message, what's it say? If it executes without throwing an error, that indicates it's finding the bridge without issue, in which case I'd guess it has something to do with the pairing between the bridge and the glasses you're wearing.