passing table and value to add to table as raiseEvent arguments
Posted: Tue Aug 03, 2021 6:03 pm
In one script, I declare a bunch of tables, among them, table_a, with:
Another script, table_adder, is set up with the function:
The script has "table_adder" registered as an event handler. The purpose of the script is to accept the name of any of my previously declared tables and a numeric value and add the value to the table.
When I raise the table_adder event and call the function with:
I get an error: bad argument #1 to 'insert' (table expected, got string). When I check the value of table within the function, I can see that its value is table_adder, the name of the function, not table_a, the table I was trying to pass. What am I doing wrong?
Code: Select all
table_a = {}
Code: Select all
function table_adder (table, value)
table.insert(table, value)
end
When I raise the table_adder event and call the function with:
Code: Select all
raiseEvent("table_adder", table_a, 1)