From 3d56d8a9242bbfdf5a0049b503a5766e3c6ad9ca Mon Sep 17 00:00:00 2001 From: Nahuel Rocchetti Date: Wed, 30 Aug 2023 16:11:27 -0300 Subject: [PATCH] Lua 5.0: Fix for loop for tables --- Assets/Scripts/OpenTS2/Lua/Disassembly/OpCodes/TFORPREP.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Assets/Scripts/OpenTS2/Lua/Disassembly/OpCodes/TFORPREP.cs b/Assets/Scripts/OpenTS2/Lua/Disassembly/OpCodes/TFORPREP.cs index c08d550..ce9a8ee 100644 --- a/Assets/Scripts/OpenTS2/Lua/Disassembly/OpCodes/TFORPREP.cs +++ b/Assets/Scripts/OpenTS2/Lua/Disassembly/OpCodes/TFORPREP.cs @@ -41,6 +41,12 @@ namespace OpenTS2.Lua.Disassembly.OpCodes public override void Disassemble(LuaC50.Context context) { + context.Code.WriteLine("if type(" + context.R(A) + ") == \"table\" then"); + context.Code.Indentation++; + context.Code.WriteLine(context.R((ushort)(A + 1)) + " = " + context.R(A)); + context.Code.WriteLine(context.R(A) + " = next"); + context.Code.Indentation--; + context.Code.WriteEnd(); context.Code.WriteLine("for "+ context.R((ushort)(A + 2)) + ", "+ context.R((ushort)(A + 3)) + " in "+ context.R(A) + ", "+ context.R((ushort)(A + 1)) + " do"); context.Code.Indentation++; //context.Code.WriteLine("-- A: " + A);