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

var name building from string data

Started by Martin2789, 14 February 2014 - 01:04 PM
Martin2789 #1
Posted 14 February 2014 - 02:04 PM
i found this but i dont understand it how to use it i want to write a little program to fill the screens at spawn for this i want to use JSON which looks something like this:

{"monitornorth": [{
			"firstline": "John",
			"secline": "Doe",
			"txtcol": "colors.white",
			"backcol": "colors.blue"
}]}
Thanks to LBPHacker and this JSON-API i am able to read this data from the server with
print(obj.monitornorth[1].firstline)
I dont want to modify every pc but i will label them is it possible to String concatenate a variable name?
sth. like this?


var varstring = "obj."..os.getComputerLabel().."[1].firstline"
local var = getfenv()[varstring]
But i thinks thats only the "name" of the variable am i right?
Thank you for your time

TL TR: variable build via generated string(os.getComputerLabel())
Edited on 14 February 2014 - 01:04 PM
Lyqyd #2
Posted 14 February 2014 - 02:24 PM

local var = obj[os.getComputerLabel()][1].firstLine
Martin2789 #3
Posted 14 February 2014 - 03:48 PM
Thank you very much works like a charm ;)/>