factoriolib / flib

A set of high-quality, commonly-used utilities for creating Factorio mods.
https://mods.factorio.com/mod/flib
MIT License
61 stars 15 forks source link

YAFC crashes with newer versions of flib #67

Closed exfret closed 3 months ago

exfret commented 3 months ago

YAFC, the external calculator I use with larger factorio mods, crashes on startup with the following error when loading flib. I tried with flib 0.12.6 and other mods with no problems.

I understand that this is more likely YAFC's fault due to its age and lack of updates, but I wanted to post this here in case there was an easy fix, or at least a line of code I can comment out/modify to make things work. If not, I understand as well.

Factorio still loads (version 1.1.104) with any flib version even when YAFC does not work, by the way.


Unhandled exception. YAFC.Parser.LuaException: (flib, prototypes/style.lua):160: attempt to index local 'data_util' (a nil value)
stack traceback:
[C]: in function '__index'
(flib, prototypes/style.lua):160: in main chunk
[C]: in function 'require'
(flib, data.lua):2: in main chunk
   at YAFC.Parser.LuaContext.Exec(ReadOnlySpan`1 chunk, String mod, String name, Int32 argument) in C:\projects\YAFC\YAFCparser\LuaContext.cs:line 412
   at YAFC.Parser.LuaContext.Require(IntPtr lua) in C:\projects\YAFC\YAFCparser\LuaContext.cs:line 352
   at YAFC.Parser.LuaContext.lua_pcallk(IntPtr state, Int32 nargs, Int32 nresults, Int32 msgh, IntPtr ctx, IntPtr k)
   at YAFC.Parser.LuaContext.Exec(ReadOnlySpan`1 chunk, String mod, String name, Int32 argument) in C:\projects\YAFC\YAFCparser\LuaContext.cs:line 407
   at YAFC.Parser.LuaContext.DoModFiles(String[] modorder, String fileName, IProgress`1 progress) in C:\projects\YAFC\YAFCparser\LuaContext.cs:line 435
   at YAFC.Parser.FactorioDataSource.Parse(String factorioPath, String modPath, String projectPath, Boolean expensive, IProgress`1 progress, ErrorCollector errorCollector, String locale, Boolean renderIcons) in C:\projects\YAFC\YAFCparser\FactorioDataSource.cs:line 283
   at YAFC.WelcomeScreen.LoadProject() in C:\projects\YAFC\YAFC\Windows\WelcomeScreen.cs:line 302
Fatal error. Internal CLR error. (0x80131506)
   at YAFC.Parser.LuaContext.lua_pcallk(IntPtr, Int32, Int32, Int32, IntPtr, IntPtr)
   at YAFC.Parser.LuaContext.lua_pcallk(IntPtr, Int32, Int32, Int32, IntPtr, IntPtr)
   at YAFC.Parser.LuaContext.Exec(System.ReadOnlySpan`1<Byte>, System.String, System.String, Int32)
   at YAFC.Parser.LuaContext.DoModFiles(System.String[], System.String, System.IProgress`1<System.ValueTuple`2<System.String,System.String>>)
   at YAFC.Parser.FactorioDataSource.Parse(System.String, System.String, System.String, Boolean, System.IProgress`1<System.ValueTuple`2<System.String,System.String>>, YAFC.Model.ErrorCollector, System.String, Boolean)
   at YAFC.WelcomeScreen+<LoadProject>d__32.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[YAFC.WelcomeScreen+<LoadProject>d__32, YAFC, Version=0.5.8.0, Culture=neutral, PublicKeyToken=null]].ExecutionContextCallback(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[YAFC.WelcomeScreen+<LoadProject>d__32, YAFC, Version=0.5.8.0, Culture=neutral, PublicKeyToken=null]].MoveNext(System.Threading.Thread)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[YAFC.WelcomeScreen+<LoadProject>d__32, YAFC, Version=0.5.8.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at YAFC.UI.EnterThreadPoolAwaitable+<>c.<.cctor>b__7_0(System.Object)
   at System.Threading.QueueUserWorkItemCallback+<>c.<.cctor>b__6_0(System.Threading.QueueUserWorkItemCallback)
   at System.Threading.ExecutionContext.RunForThreadPoolUnsafe[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Threading.ExecutionContext, System.Action`1<System.__Canon>, System.__Canon ByRef)
   at System.Threading.QueueUserWorkItemCallback.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
Abort trap: 6
exfret commented 3 months ago

Nevermind, it seems there is a newer version of YAFC and people there are already working on it.

https://github.com/have-fun-was-taken/yafc-ce/issues/83