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

RedVar

Started by Xtansia, 11 May 2012 - 07:20 AM
Xtansia #1
Posted 11 May 2012 - 09:20 AM
RedVar V1.0.0


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:
SpoilerOn the computer you want to use as the variable server all you need to do is call the function
RedVar.server( modemSide )
And then on any computer you want to use as a client do something like this
To 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:
Spoiler1. Download the file
2a. 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:
SpoilerV1.0.0: DL Link
Note: Right-Click and Save-As

Changelog:
Spoiler11-05-2012: First Release
Tiin57 #2
Posted 15 July 2012 - 03:13 PM
Does this work with 1.33? I would assume so, seeing as the OP post date was May 11, but I want to make sure.
Xtansia #3
Posted 16 July 2012 - 05:01 AM
Does this work with 1.33? I would assume so, seeing as the OP post date was May 11, but I want to make sure.

It should work I think that's what I was using when I made this.
Xtansia #4
Posted 31 August 2012 - 12:38 AM
Fixed download link.
Wolvan #5
Posted 01 September 2012 - 11:53 AM
I wanted to ask… may I am allowed to add this functions into my advanced rednet api? with giving full credit of course
Xtansia #6
Posted 01 September 2012 - 12:07 PM
Yeah do whatever, :)/>/>
Wolvan #7
Posted 01 September 2012 - 12:43 PM
Yeah do whatever, :)/>/>
Thank you really much *.*