if you can pass into a function, you can then affect it. thus you can reset it.
when you start a new function it is considered a NEW block of code OR
what the programmers call a BLOB of code. All variables created in that function
are LOCAL to that function. And if you make any changes to these variables
that will not affect variables outside the function.
now you can create a GLOBAL variable or a table. like this, a1={}
a1 is a table at this point AND if you use print(type(a1))
you will see TABLE in the the DEBUG console.
now also try to print(a1), you will see the output in a DEBUG console
say something like “nil”
this means the TABLE a1 has nothing assigned to it.
So try assigning a value to it BEFORE entering the function. like so,
a1[1] = 12345
now use the debug statements print(a1[1]) to see if you echo that value out to
the DEBUG console. btw, you should see 12345 if you used the above print command.
you have got to grasp this programming concept.
however, you should only use GLOBAL variable(tables) sparingly.
buy the book programming in LUA(2nd edition) and actually try to copy the code
into a main.lua program and try to replicate the books results.
try to write simple functions and learn how to get variables/table into and out of functions.
learn all the different techniques and functionaity of lua.
now some people will give you code. but unless you take it apart and learn for it
and realise the intraciries of functions and how to use them, your just gonna get blurred eyed
everytime you wanna do something in corona. even the simple stuff like setting
a variable.
im not pretend to know everything. and god know I have asked for code and people have
giving me code thanks peach and al the others !!! but until you try to you will never truly learn. [import]uid: 11094 topic_id: 18462 reply_id: 71353[/import]