There is table.new()
additional function in luajit, that can be required with require "table.new"
.
Is it available in defold? Because requiring it end up with an error.
You can require table.new() like this:
package.preload["table.new"]()
You don’t need to use require after that anymore, just put it on the top of your script. The require that Defold uses is a bit different than standard Lua, to only include packages at runtime that it knows will be used, so unexpected modules like a Luajit extensions can require a workaround like that.
package.preload can require the following packages with that method:
ffi,
jit.profile,
jit.util,
string.buffer,
table.clear,
table.new
5 Likes
And if you don’t want the linter to complain about table.new(), you can use:
table.new = package.preload["table.new"]()
It will be saved in table.new anyway, so there is no functional difference besides the linter knowing that table.new is not nil anymore, and stops underlining each call of it.
2 Likes
Thanks