Help: Function to load pngs from a list...

BlitzMax Forums/BlitzMax Beginners Area/Help: Function to load pngs from a list...

Okay, here's what I want to do: I don't want to have to write out:

Incbin "sprites/hero.png"
Global hero:Timage=LoadImage( "sprites/hero.png" )

Incbin "sprites/plants.png"
Global hero:Timage=LoadImage( "sprites/hero.png" )

Incbin "sprites/grass.png"
Global hero:Timage=LoadImage( "sprites/hero.png" )

...etc


for each PNG file that my game will use. I would much rather create a list of known PNG files in one place in my code (or maybe even read a list of all the PNG files in a directory) and then cycle through the list to load each item on it.

I tried to do it this way:

Strict

Function InitializeSprites()
	Local arr:String[]=["hero", "plants", "grass"]
	For Local t:String=EachIn arr
		t="sprites/"+t+".png"
		Print "loading "+ t
		Incbin t
		Global hero:Timage=LoadImage( t )
	Next
End Function

initializeSprites()


Compile Error: Expecting string literal but encountered identifier

I guess this means I can't plug a variable into Timage=LoadImage. If that's true, I can't really think of ANY way to load graphics dynamically. Which would suck, because it means it's impossible to ever make a moddable game that uses user-defined content.

Any suggestions? :/ Or is there a seperate command/technique for loading graphics from a directory?