rxi / lovedos

A framework for making 2D DOS games in Lua
MIT License
677 stars 47 forks source link

Does dofile/require work? [FIXED] #3

Closed FailMelon closed 7 years ago

FailMelon commented 7 years ago

Been trying to figure out if dofile/require actually works to include external files into the main, I've tried multiple paths to find my lua file but none seem to work.

Setup: MOUNT C: C:\Users\FailMelon\Dropbox\LuaDOSGames C:

Game folder: C:\Users\FailMelon\Dropbox\LuaDOSGames\GAME1

Love: C:\Users\FailMelon\Dropbox\LuaDOSGames\love.exe

Things tried: dofile("TESTMODULE.LUA") dofile("C:\GAME1\TESTMODULE.LUA") dofile("GAME1\TESTMODULE.LUA") dofile("C:\Users\FailMelon\Dropbox\LuaDOSGames\GAME1\TESTMODULE.LUA")

Also have tried all these with require but it doesn't seem to find the file.

wenright commented 7 years ago

Yes, they should work.

DOS only allows filenames of 8 characters, with a 3 character file type. So, you would have to rename your testmodule.lua to something smaller, like test.lua

FailMelon commented 7 years ago

ah that makes sense sorry i'm a DOS noob sorry, forgot about the 8 character limit it works now thanks :)

rxi commented 7 years ago

In addition to what @wenright said it should probably be mentioned that dofile() should be avoided in LoveDOS. require() uses a custom package loader which uses love.filesystem.read() to load a file, where as dofile() does not. dofile() and the io module may work during development, but will fail once the game is packaged.

htv04 commented 3 years ago

Is there any way around this issue? I would like to try to port a game I'm working on in Love2D to LoveDOS, but the game uses love.filesystem.load([lua file])() for loading data. This function doesn't seem to exist in LoveDOS.