Discord Moderators Pirulax Posted June 15, 2017 Discord Moderators Share Posted June 15, 2017 So, heres my table local twonodes = {"login", "rpteszt"} local thirdnodes = {[twonodes[1]] = {"username","password", "rememberMe"}, [twonodes[2]]={"rpteszt"}} local values = {thirdnodes[twonodes[1]]={"false"}} Seems good, right?Yeah, for u,but not for Lua... ERROR: Loading script failed: loginpanel/loginpanelC:112: '}' expected near '='' Link to comment
Scripting Moderators thisdp Posted June 15, 2017 Scripting Moderators Share Posted June 15, 2017 use it instad mytable = {} mytable[key] = value Link to comment
Popular Post AfterAll14 Posted June 15, 2017 Popular Post Share Posted June 15, 2017 How retarded you should be to blame programming language 4 Link to comment
pa3ck Posted June 16, 2017 Share Posted June 16, 2017 (edited) 14 hours ago, Pirulax said: So, heres my table local twonodes = {"login", "rpteszt"} local thirdnodes = {[twonodes[1]] = {"username","password", "rememberMe"}, [twonodes[2]]={"rpteszt"}} local values = {thirdnodes[twonodes[1]]={"false"}} Seems good, right?Yeah, for u,but not for Lua... ERROR: Loading script failed: loginpanel/loginpanelC:112: '}' expected near '='' No, that doesn't seem right at all. local twonodes = { "login", "rpteszt" } local thirdnodes = { [1] = {"username","password", "rememberMe"}, [2]={"rpteszt"} } local values = { [1]={"false"} } How retarded you should be to blame programming language Such a helpful fellow you are. Edited June 16, 2017 by pa3ck 1 Link to comment
AfterAll14 Posted June 16, 2017 Share Posted June 16, 2017 Just now, pa3ck said: Such a helpful fellow you are. Oh thanks, I know . But honestly, what kind of help this guy want. Compiler says ERROR line 112, and the given code doesn't even contain line 112 . Link to comment
PeaceBomb99 Posted June 16, 2017 Share Posted June 16, 2017 @Pirulax http://lua-users.org/wiki/TablesTutorial Link to comment
pa3ck Posted June 16, 2017 Share Posted June 16, 2017 Nah, actually I just looked at your code again, you are not far off from the solution, I see what you are trying to do... the problem is with this line: local values = {thirdnodes[twonodes[1]]={"false"}} Instead of that, it should be something like this: local values = { [ thirdnodes [ twonodes [ 1 ] ][ 1 ] ]={"false"}} So there are two things you missed. You forgot to put the key between [ ] and also that thirdnotes[twonodes[1]] will return the table with {"username", "password", rememberMe"}, which means you wanted the key to be a table. But if you put a [1] after it, the key will be "username". Tested on this: local twonodes = {"login", "rpteszt"} local thirdnodes = {[twonodes[1]] = {"username","password", "rememberMe"}, [twonodes[2]]={"rpteszt"}} local values = { [ thirdnodes[twonodes[1]][1]]={"false"}} print(thirdnodes[twonodes[1]][1]) --[[ Output: username ]] Link to comment
AfterAll14 Posted June 16, 2017 Share Posted June 16, 2017 (edited) But you can use table as key in lua . That will not give you any errors. He complains about syntax error. Edited June 16, 2017 by AfterAll14 Link to comment
pa3ck Posted June 16, 2017 Share Posted June 16, 2017 10 minutes ago, AfterAll14 said: But you can use table as key in lua . That will not give you any errors. He complains about syntax error. That's just stupid, you actually can.. what the hell, never tried that, I just assumed you couldn't. Then the only problem with his code was the missing [ ]. local values = { [ thirdnodes [ twonodes [ 1 ] ] ] ={"false"} } --> no errors local values = { thirdnodes [ twonodes [ 1 ] ] = { "false" } } --> error Link to comment
AfterAll14 Posted June 16, 2017 Share Posted June 16, 2017 Yeah, I guess that's the "line 112" And yes, you can even use ur mum as key in lua 2 Link to comment
Discord Moderators Pirulax Posted June 16, 2017 Author Discord Moderators Share Posted June 16, 2017 Figured it out later the missing "[]" was the problem Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now