lua: main.lua:1: '}' expected near '=' table = {[1] = {'job1' = 0, 'job2' = 0, 'job3' =…
- User
lua: main.lua:1: '}' expected near '='
table = {[1] = {'job1' = 0, 'job2' = 0, 'job3' = 0, 'job4' = 0}, [2] = {'job1' = 0, 'job2' = 0, 'job3' = 0, 'job4' = 0}}
- Assistant
You have a syntax error in your table definition. You should be using colons (:) instead of equals signs (=) to define the key-value pairs within each subtable. Here's the corrected code:
luatable = { [1] = {'job1': 0, 'job2': 0, 'job3': 0, 'job4': 0}, [2] = {'job1': 0, 'job2': 0, 'job3': 0, 'job4': 0} }However, this will also give you an error because key-value pairs with colons are not valid in table constructors. In Lua, you should use
=for key-value pairs in tables. You can rewrite the table using a more appropriate table structure:luatable = { [1] = {job1 = 0, job2 = 0, job3 = 0, job4 = 0}, [2] = {job1 = 0, job2 = 0, job3 = 0, job4 = 0} }In this example, the keys are now represented as variable (or key) names instead of strings, which allows you to use the
=for key-value pairs in the table constructor. This will work as expected in Lua.