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

[Lua][Help] Storing Variables

Started by soccer16x, 30 January 2013 - 11:57 AM
soccer16x #1
Posted 30 January 2013 - 12:57 PM
So what I am creating is a button press calculator, I have all of the things i need to write everything to the screen but what i can not figure out is how to do the operations for the calculator. Currently what I am doing is I have a variable that stores the things that were written to the screen and it stores it in a variable then sets itself back to nothing, but then I also need to use this same variable for storing in a second variable which later gets used to do the operation of the 2 variables but what ends up happening is the first variable loses itself and becomes nothing and all it leaves me with is the last variable.

Here's my code in its current "not" working state if you would like to check it out and give me a hand : http://pastebin.com/EeJVNaga

And sorry about the way that the spacing is, it didnt copy over exactly right with the spacing.
Also sorry if my wording above is confusing, but looking at the code should hopefully clear it up for you.
ChunLing #2
Posted 30 January 2013 - 03:46 PM
Use a table and an index value (initialized to 1). Store your value in the table at the index, then increment the index. Repeat until you have all the variables stored in the table.
soccer16x #3
Posted 30 January 2013 - 04:26 PM
Use a table and an index value (initialized to 1). Store your value in the table at the index, then increment the index. Repeat until you have all the variables stored in the table.

Thanks a lot works perfectly as of right now.