NewGRF and string for accessing a folder

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Post Reply
J0anJosep
Traffic Manager
Traffic Manager
Posts: 145
Joined: 06 Aug 2011 15:51
Location: Spain

NewGRF and string for accessing a folder

Post by J0anJosep »

I'm trying to make a NewGRF and I have several folders that have *.png files like "/10/*.png", "/20/*.png", ...
Given a parameter of the NewGRF, I would like to access to each one of those folders. Now I have this kind of code:

Code: Select all

alternative_sprites(spr0, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP) { [ 0, 0, "gfx/20/cursor.png" ] }
I would like to define a string (in this case folder="20"), so I could replace the previous line by something similar to this:

Code: Select all

alternative_sprites(spr0, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP) { [ 0, 0, "gfx/"+folder+"/cursor.png" ] }
I've tried to do it in several ways, but I can't find the correct way to do so. Any help would be appreciated.
Formerly known as Juanjo
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: NewGRF and string for accessing a folder

Post by planetmaker »

File names within a spriteset definition cannot be parametrized.

If you want to show one sprite (set) instead of another, you need to define two (or more) sprite sets, one for each parameter value and use a switch to branch to the appropriate sprite set.
J0anJosep
Traffic Manager
Traffic Manager
Posts: 145
Joined: 06 Aug 2011 15:51
Location: Spain

[SOLVED] NewGRF and string for accessing a folder

Post by J0anJosep »

Thanks!
I'll write separate .pnml files then.
Formerly known as Juanjo
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 17 guests