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

Basic Settings File - How to pass a variable from one file to another

Started by Tobbe, 11 February 2015 - 04:35 AM
Tobbe #1
Posted 11 February 2015 - 05:35 AM
Hi guys,

So i have reached a point in my CC Lua program development when it makes sense to have a settings file for important / constand variabels for
The programs runtime.

Question: how to I pass a variabel from one program to the other. Ie. Program B uses variabel ComputerID that is declared/defined in Program A.

Background:
Right now I am working on a Rednet Wireless project were im controlling turtles. As a part of the program I am having individual turtles specifically listening for wireless commands being broadcasted by a specific computer ID.

The computer ID variabel (amongst a few other ones) I'd like to declare in a settings file so that I only need to change these values in one place thereby updating an references/usage of these variables in the other programs on the turtle in question.
Bomb Bloke #2
Posted 11 February 2015 - 08:29 AM
The "simple" way is to stick your desired info in a table, use textutils.serialize() to turn that into a string, then write the result to disk. Take a look at this thread for an example.