This RedVar an api for sharing variables via rednet.
Variables are persistant as well everytime a variable is set it is saved,
Variables are then loaded when RedVar.server() is called.
Note: It supports string, number, boolean, table
Note: It does not support function, thread/coroutine …
How To Use:
Spoiler
On the computer you want to use as the variable server all you need to do is call the functionRedVar.server( modemSide )And then on any computer you want to use as a client do something like thisTo set a variable:
rednet.open("top") --Or whatever side your modem is on
RedVar.setServerID( 0 ) --This needs to be the computer id of the server
write("Enter name for var: ")
local varName = read()
print()
write("Enter value for var: ")
local varValue = read()
print()
RedVar.setVariable(varName, varValue)
To get a variable:
rednet.open("top") --Or whatever side your modem is on
RedVar.setServerID( 0 ) --This needs to be the computer id of the server
write("Enter name of var: ")
local varName = read()
local varValue = RedVar.getVariable(varName)
print()
print("Value of var: " .. tostring(varValue))
Functions:
Spoiler
server( modemSide )
setServerID( n )
getVariable( varname )
setVariable( varname, varvalue )
How To Install:
Spoiler
1. Download the file2a. Put the file in rom/apis
+ 3. Done you can use it now
—
2b. Put the file wherever you like
+ 3. Run os.loadAPI(pathToRedVar)
+ 4. Done you can use it now
Downloads:
Changelog: