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

Set Varible Using Code (Rawset?)

Started by 3ydney, 05 March 2013 - 06:36 PM
3ydney #1
Posted 05 March 2013 - 07:36 PM
How can I set a varible in code for example i want to make a varible called vaild. Its uses a string and another varible to make it…

local vaild = "vaild-" .. id

How can I do this… It has always returned an error…

Can I use rawset?
SuicidalSTDz #2
Posted 05 March 2013 - 07:46 PM
variable = "testVariable"
anotherVariable = ("test"..variable)
print(anotherVariable)
This will return:
test testVariable

Im almost certain this will work
ChunLing #3
Posted 05 March 2013 - 09:24 PM
What was the type of id?
Exerro #4
Posted 06 March 2013 - 12:32 AM
was the error attempt to concatenate string and [something else], if it was then the type of id was not a string so it couldn't join them, fix = 'local valid = "valid-"..tostring( id )'. Other wise, it must be something else in your code.
rawset it for use with metatables i think, it sets the variable without triggering the __index or __newindex metamethod