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

[mc1.6.4][dw20 1.0.2] How to pass a viable to another program ?

Started by MisterBrownZA, 13 December 2013 - 11:17 PM
MisterBrownZA #1
Posted 14 December 2013 - 12:17 AM
Here I am again,

I've got 2 programs, for explanation purposes - let's call them :

1. analyze
2. terminal

program 1 is dedicated to analyzing something, and keeps everything in a table (let's call it "tableDictionary")

in terminal, I've loaded the analyze api, and would like to access the variables within it so that I can modify my terminal glasses

Would this be possible without integrating the two programs ?

Kind Regards
Ajt86 #2
Posted 14 December 2013 - 02:46 AM
You could use

os.loadAPI()
os.unloadAPI()
If you make your functions and variables global (i.e. don't write "local" infront) then you can access them through analyse.{OBJECT} like you do using the default APIs. Once you're done using the API, unload it.
amtra5 #3
Posted 14 December 2013 - 02:46 AM
If analyze is loaded as an api and the variable is not local, terminal can access that variable via
analyze.variable

Edit:Ninja'd
Edited on 14 December 2013 - 01:48 AM
MisterBrownZA #4
Posted 14 December 2013 - 09:20 AM
I've tried using analyze.variable, but it returns as nil. does having the variable first declared in a function make a difference ?

I made sure there is no "local"
Edited on 14 December 2013 - 08:20 AM
MKlegoman357 #5
Posted 14 December 2013 - 09:50 AM
does having the variable first declared in a function make a difference ?

It does make a difference. When you define your variable in a function it will be created when that function runs. But because of how os.loadAPI works you wouldn't find that variable even if you run the function. You should define that variable outside of your function.