I want to make tool like factorio-calculator by python 3(using pyqt5).
So I use this code for taking factorio data (like data.raw).
Code: Select all
import os
import lupa
path_factorio = 'E:\\[Working]\\FactorioCalculator\\facback_1.1.26'
list_func = [\
'function math.pow(num1, num2) return (num1 ^ num2) end'\
]
path_data = os.path.join(path_factorio, 'data')
#path_data = path_factorio
path_base = os.path.join(path_data, 'base')
path_core = os.path.join(path_data, 'core')
lua = lupa.LuaRuntime(unpack_returned_tuples=True)
lua.globals().package.path += ';' + os.path.join(path_data, '?.lua') \
+ ';' + os.path.join(path_core, '?.lua') \
+ ';' + os.path.join(path_core, 'lualib', '?.lua') \
+ ';' + os.path.join(path_base, '?.lua')
#add missing function
for func in list_func:
lua.execute(func)
#load core
lua.require('dataloader')
lua.require('defines')
lua.require('core.data')
lua.require('base.data')
But it don't work after v1.1.26.
I am attaching the error message below.
There is no problem when running, loading, and saving the game with the data generating the above error.Traceback (most recent call last):
File ".\lua_test.py", line 38, in <module>
lua.require('base.data')
File "lupa\_lupa.pyx", line 317, in lupa._lupa.LuaRuntime.require
File "lupa\_lupa.pyx", line 1306, in lupa._lupa.call_lua
File "lupa\_lupa.pyx", line 1332, in lupa._lupa.execute_lua_call
File "lupa\_lupa.pyx", line 1268, in lupa._lupa.raise_lua_error
lupa._lupa.LuaError: ...io\data\base\prototypes\entity\spidertron-animations.lua:521: module '__base__/prototypes/entity/spidertron-light-positions' not found:
no field package.preload['__base__/prototypes/entity/spidertron-light-positions']
no file 'C:\Users\danak\AppData\Local\Programs\Python\Python37\lua\__base__/prototypes/entity/spidertron-light-positions.lua'
no file 'C:\Users\danak\AppData\Local\Programs\Python\Python37\lua\__base__/prototypes/entity/spidertron-light-positions\init.lua'
no file 'C:\Users\danak\AppData\Local\Programs\Python\Python37\__base__/prototypes/entity/spidertron-light-positions.lua'
no file 'C:\Users\danak\AppData\Local\Programs\Python\Python37\__base__/prototypes/entity/spidertron-light-positions\init.lua'
no file 'C:\Users\danak\AppData\Local\Programs\Python\Python37\..\share\lua\5.3\__base__/prototypes/entity/spidertron-light-positions.lua'
no file 'C:\Users\danak\AppData\Local\Programs\Python\Python37\..\share\lua\5.3\__base__/prototypes/entity/spidertron-light-positions\init.lua'
no file '.\__base__/prototypes/entity/spidertron-light-positions.lua'
no file '.\__base__/prototypes/entity/spidertron-light-positions\init.lua'
no file 'C:\Program Files (x86)\Steam\steamapps\common\Factorio\data\__base__/prototypes/entity/spidertron-light-positions.lua'
no file 'C:\Program Files (x86)\Steam\steamapps\common\Factorio\data\core\__base__/prototypes/entity/spidertron-light-positions.lua'
no file 'C:\Program Files (x86)\Steam\steamapps\common\Factorio\data\core\lualib\__base__/prototypes/entity/spidertron-light-positions.lua'
no file 'C:\Program Files (x86)\Steam\steamapps\common\Factorio\data\base\__base__/prototypes/entity/spidertron-light-positions.lua'
no file 'C:\Users\danak\AppData\Local\Programs\Python\Python37\__base__/prototypes/entity/spidertron-light-positions.dll'
no file 'C:\Users\danak\AppData\Local\Programs\Python\Python37\..\lib\lua\5.3\__base__/prototypes/entity/spidertron-light-positions.dll'
no file 'C:\Users\danak\AppData\Local\Programs\Python\Python37\loadall.dll'
no file '.\__base__/prototypes/entity/spidertron-light-positions.dll'
stack traceback:
[C]: in function 'require'
...io\data\base\prototypes\entity\spidertron-animations.lua:521: in function 'spidertron_torso_graphics_set'
...common\Factorio\data\base\prototypes\entity\entities.luain function 'create_spidertron'
...common\Factorio\data\base\prototypes\entity\entities.luain main chunk
[C]: in function 'require'
...(x86)\Steam\steamapps\common\Factorio\data\base\data.lua:5: in main chunk
[C]: in function 'require'
Can you tell me how to fix the error or a new way to load the data?
To help you understand, I attached an image of the tool I was making.
