Jump to content

Do u see error here?Because Lua does.


Pirulax

Recommended Posts

  • Discord Moderators

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
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 by pa3ck
  • Like 1
Link to comment

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
10 minutes ago, AfterAll14 said:

But you can use table as key in lua 9_9. 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...