• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Iterate through included files/datafiles

P

preinheimer

Guest
I'm defining what levels will look like in JSON files. Read them in, create the level, works great.

But currently I hard code the array listing all the files.


Is there a way to pull in a directory listing or similar?
 
S

Sam (Deleted User)

Guest
For a solution that isn't limited to Windows, but also supports Mac and Linux, try directory_contents() and directory_contents_ext()


The filter/pattern argument can be used like:
"*.jpg;*.gif;*.png" or "*.*" to allow all file types. There is a boolean argument for whether to include directories and bundles, (bundles are a mac thing). You can also use @YellowAfterlife's string split script from his blog if you want to parse the returned files and directories into an array. The new line character "\n" is used for a delimiter.
 
P

preinheimer

Guest
Thanks!

It seems weird to me that we're given this sandbox, which I'm completely happy to stay in, but no easy built-in ways of seeing what's in the sandbox.
 
S

Sam (Deleted User)

Guest
Are you using GMS 1.4 or 2.x? You can turn off the sandbox in 2.x. if you are using 1.4, you can get the extension for 1.4 here: https://samuel-venable.itch.io/dialog-module

It's under the downloads section despite the discription and screenshots being about something else (I got kinda lazy and didnt make separate pages for each asset yet)
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
file_find_first("*.json", 0) and other file_find_* functions should work for enumerating included files, I think on any platform.
 
Top