Loading/running .pdz files in data directory

Only .pdz files in the application directory is allowed to be loading/running, but it would be nice if the data directory is also allowed!

So far, it seems that even if there is a .pdz file in the Data Directory, it cannot be opened.
TestLua.zip (4.6 KB)

Sample code:

-- main.lua
playdate.file.run("module01")
function playdate.update()
end
-- Module01.lua
print(”Module01 Loaded.”)

Result:

Module01 Loaded.

Result (Deleting Module01.pdz):
Deleting Module01.pdz in the application folder will, of course, result in a file not found.

main.lua:1: file not found: module01
stack traceback:
[C]: in field 'run'
main.lua:1: in main chunk

Result (Moving Module01.pdz):
Moving Module01.pdz to the data folder, the file seems to be found, but I can't seem to open it.

main.lua:1: sd_open returned NULL
stack traceback:
[C]: in field 'run'
main.lua:6: in main chunk

2 Likes

I have been looking into this as well and am having the same issue.
I am trying to allow people to put new functionality into custom levels for Diora, essentially mods.

I'd be curious to know if this is intentional or not, I can imagine it might be due to a security issue, but the error is generic so hopefully not!

4 Likes

Any news on this, or some sort of workaround?

I think this would be more effort than it's worth, but maybe it would be possible to create a sort of "mini-lua" interpreter. You could probably call functions and access variables from this language by doing _G[name_here] or something similar.

(Just spitballing here, lol)

This is one of the things I am doing to support this! In my game, triggers and dialogue can run some pretty sophisticated events like waits, calling _G[name] functions, and stuff like that, its a pretty powerful system. if you want to see how that works its here: Diora Level Editing

1 Like