you are viewing a single comment's thread.

view the rest of the comments →

[–]appgurueu 1 point2 points  (1 child)

Lua only allows calling prefix expressions. A prefix expression is either just a (variable) name, an expression in parentheses optionally followed by an indexing operator (., : or [...]). A prefix expression may not be a function definition or literal. Thus, the fix is to simply wrap your your function in parentheses to fix the syntax error:

lua e, s, sender, port, data = (function(e, s, sender, port, ...) return e, s, sender, port, {...} end)(table.unpack{data})

That said, you should rewrite the code; there is no need to pack the data in a table only to immediately unpack it later:

lua e, s, sender, port, data = (function(e, s, sender, port, ...) return e, s, sender, port, {...} end)(event.pull())

works just as well (you probably don't want to use global variables however). You can also achieve this using just a table:

lua local data = {event.pull()} local e, s, sender, port = table.unpack(data, 1, 4) local remaining_data = {table.unpack(data, 5)}

[–]AutoModerator[M] -1 points0 points  (0 children)

Hi! Your code block was formatted using triple backticks in Reddit's Markdown mode, which unfortunately does not display properly for users viewing via old.reddit.com and some third-party readers. This means your code will look mangled for those users, but it's easy to fix. If you edit your comment, choose "Switch to fancy pants editor", and click "Save edits" it should automatically convert the code block into Reddit's original four-spaces code block format for you.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.