of     1   

KAMIKAZEPOLO
#175487499Sunday, October 04, 2015 2:46 AM GMT

Is there a way to find a difference in tables and identify which index/value it is? For example: table1 = {"cat", "dog"} table2 = {"cat", "dog", "catdog"} if table1 ~= table2 then blah blah end Any replies are appreciated :D.
cntkillme123
#175487685Sunday, October 04, 2015 2:48 AM GMT

You can do something like: local function compareArrays(tbl1, tb2) if #tbl1 ~= #tbl2 then return false; end for key = 1, #tbl1 do if tbl1[key] ~= tbl2[key] then return false; end end return true; end
KAMIKAZEPOLO
#175488134Sunday, October 04, 2015 2:53 AM GMT

Thanks for the reply! What is the purpose of putting local behind function? I understand scopes of variables, but I don't really understand the reasoning behind local functions. Also what's up with the semi-colons?
bosswalrus
#175488290Sunday, October 04, 2015 2:55 AM GMT

it is the same thing like local variables I assume
cntkillme123
#175488996Sunday, October 04, 2015 3:04 AM GMT

'What is the purpose of putting local behind function? I understand scopes of variables, but I don't really understand the reasoning behind local functions.' In Lua, references to functions are held by variables. So: function a() end Is the same as: a = function() end; Whereas: local function a() Is the same as: local a; a = function() end; Also I use semi-colons for no reason, you don't need them.
KAMIKAZEPOLO
#175490521Sunday, October 04, 2015 3:24 AM GMT

Alright, but what is the difference that local makes? I mean, I can see that a variable has a different value based on where you put inside of a function, if it's local.
cntkillme123
#175490637Sunday, October 04, 2015 3:26 AM GMT

It can only be accessed within that scope, so for example: do -- create a new scope local function abc() print("hi"); end abc(); abc(); -- print hi twice end abc(); -- error, abc is nil ehre
KAMIKAZEPOLO
#175491269Sunday, October 04, 2015 3:34 AM GMT

You put semicolons because you used java, right? I know it's not required for LUA, but that's why you use them, right?
BusyCityGuy
#175491337Sunday, October 04, 2015 3:35 AM GMT

What, what is LUA again? -The [Guy]
cntkillme123
#175491343Sunday, October 04, 2015 3:35 AM GMT

Not because of Java, also woops I read what you wanted wrong. Mine gives you whether there were any differences at all or not, not all the differences. All you really need to do though is create a table, for every difference insert the key (remove the return in the loop) and return that table.

    of     1