require call inside a new thread changes the base path
Posted: Sat Jul 15, 2017 11:15 am
Hello there! I'm running on a huge trouble: I'm trying to make an asynchronous load of all my game's content by moving all the steps into a new thread, but the problem is that the base path inside the new thread is different that the one in the main thread. This means that I cannot share required modules so far.
Example
In the load.lua
To make it run, I have (in this case for example) to type something like:
another_module.lua may have other includes for other modules that do work properly if executed in the main thread.
So, the question is, I can avoid this? Or I'll have to make threading more atomic? (Like making a new thread for image loading only and so on...)
Example
Code: Select all
-- The main thread
thread = love.thread.newThread('app/load.lua');
thread:start();
Code: Select all
-- Failing code
local module = require('app.another_module');
-- Bla bla bla
Code: Select all
local module = require('dist.app.another_module');
So, the question is, I can avoid this? Or I'll have to make threading more atomic? (Like making a new thread for image loading only and so on...)