How to display images, audio?

cool-dude2
Posted on 2022-05-28 03:30 (edited 2022-05-28 16:51) Link

I'm thinking about making a program in Principia to display images and I once took a class in Python but I'm not a programmer by any means. Do the lua blocks have access to any part of the filesystem or would it be possible to import an image or audio file somehow?

(Avatar)
ROllerozxa
Posted on 2022-06-01 15:13 Link

Principia Lua cannot access the filesystem (at least not in an intentional way), but you can load images as sprites, from an internal sprite canvas each LuaScript object has. There used to be this tool on the official community site written by pajlada that would take an image and convert it into pixel colour data that it draws to the LuaScript's sprite canvas (max. 1024x1024).

I decided to throw it up here if you wanna try it out, but it can be stubborn and hard to use. I'll be working on improving it soon enough though, there's some things I wanna do with it like adding some more information on how to use it, adding settings to configure the sprite size and filtering, etc.

(Avatar)
voxel
Posted on 2025-03-18 01:19 Link

(also this once merged would allow importing custom audio and sound effects:)

https://github.com/Bithack/principia/pull/185

(Avatar)
ROllerozxa
Posted on 2025-03-18 10:30 (edited 2025-03-18 10:38) Link

Posted by voxel
(also this once merged would allow importing custom audio and sound effects:)

The pull request has not seen activity in a long time and the author is known for starting work on something and then abandoning it shortly after. Not that there is anything wrong with losing interest, but someone else would need to adopt and finish it for it to be merged and I don't see that happening.

(I also don't know if importing and loading raw audio samples is a good idea for the LuaScript API. One could of course make an audio file converter like we do with images now, but it's also not a requirement to make the API as low-level as possible.)