Lua language fork?

I had some issues and this came up.

I think it would be useful for playdate devs to look at, and decide if they want that or not.

The reason require is not used it because it's a runtime directive, whereas import is a compile time directive which is what is needed for Playdate. You can do most of what require does with import and a little bit of care. All Lua is combined into one long file for compilation.

I'm sure @dave can better explain the thinking and decisions behind this.

Your issues seem to be that you're using a language that compiles to Lua but that has no awareness of Playdate's differences. You'd have to add in support for those differences as you're seeing.

The differences are mentioned in the docs:

I think import deserves it's own section alongside the others, with an explanation of how to work with it and how to use code/libraries that rely on require.


I think a section explaining why and also how to do a few things would help a lot.

For the specific issue, it is kinda special I guess since it's another lang compiling to Lua, bit it would be useful to know how to import/require libs in pure Lua, like say GitHub - daurnimator/luatz: Time, Date and Timezone library for lua if it's possible at all.

thank you for the reply!

The short (and unsatisfying) answer is that back in early 2013 when I first added the Lua runtime to the project we didn't even have a filesystem yet so I took out package because there was no way to load code at runtime. I added import as a replacement for require and the compiler generated flat pdx files, not folders. After adding external flash and a filesystem I never went back and reevaluated that because import was working fine, and also because we'd seen a number of game devs build huge Lua frameworks that ran okay in the simulator but tanked the device. Lua's package feature always felt to me like a desktop thing, not appropriate for an embedded platform.

Yes, we need to make it clearer that we support the core Lua language but not the package ecosystem. I've got that filed, will take care of it soon.


I'd like a way to load small bits of code dynamically

ie: A script for a specific room of an RPG rather than having the entire game's script loaded all at once. Or a single level at a time.

I'd like to make a game with a lot of levels, and having all the code loaded together would be unfeasible

Check out playdate.file.load() and Let me know if those don't do what you need!


At first I was upset at myself for wasting your time cause I googled the flip out of this (and found this topic)

But at least I did google it first... It's just that the other Lua methods don't work. Trying it now, thanks

EDIT: works perfectly, I just have to return all the functions in a table