Reputation: 11
I am making a game with Monogame and NLua, but running into an error.
This is the Lua script, where the issue occurs on the third line, and stops before moving into the C# method:
function instant_growth.activate()
local farmList = Environment:GetMapFeatures("farm")
local farmTable = LsLua.ConvertToLuaTable(farmList) -- error here
for i, farmObj in ipairs(farmTable) do
farmObj.LuaData.growProgress = farm.growTime
end
return nil
end
This is the generic C# method (inside of the static LsLua class):
public static LuaTable ConvertToLuaTable<T>(List<T> list)
{
LuaTable table = CreateEmptyTable();
foreach (var item in list)
{
_addToTable.Call(table, null, item);
}
return table;
}
And this is the error:
InvalidOperationException: Late bound operations cannot be performed on types or methods for which ContainsGenericParameters is true.
The bizarre thing to me is, it works perfectly the first time, but activate the ability and run it again, it breaks. Re-initialising the Lua state works and prevents the issue, but I don't really want to be doing that.
So even doing this breaks:
local farmList = Environment:GetMapFeatures("farm")
local farmTable = LsLua.ConvertToLuaTable(farmList)
farmTable = LsLua.ConvertToLuaTable(farmList)
If I don't find a solution, I will probably just change the method so it is not generic, but any help would be greatly appreciated.
Upvotes: 1
Views: 27