Jump to content




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


  • You cannot reply to this topic
1 reply to this topic

#1 Tobbe

  • Members
  • 4 posts

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.

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

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.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users