spritelayout and random sprites in NML

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

Moderator: Graphics Moderators

Post Reply
MarkyParky
Engineer
Engineer
Posts: 89
Joined: 20 Nov 2003 15:20

spritelayout and random sprites in NML

Post by MarkyParky »

Hello,

I would like to have a building tile, where there are two adjacend buildings placed, both from same random pool of 4 versions of this sprite. I have tried following code, but NMLC doesn't allow me to compile.

Code: Select all

random_switch(FEAT_HOUSES,SELF,rnd_streethouses_NW){
 1: s_streethouse1_NW;
 1: s_streethouse2_NW;
 1: s_streethouse3_NW;
 1: s_streethouse4_NW;
}

spritelayout l_streethouses_NW {
  ground { sprite: GROUNDSPRITE_CONCRETE; }
  building {
    sprite:  rnd_streethouses_NW; 
    xextent: 8;
    yextent: 8;
    zextent: 16;
    xoffset: 0;
    yoffset: 4;
    zoffset: 0;
  }
  building {
    sprite:  rnd_streethouses_NW; 
    xextent: 8;
    yextent: 8;
    zextent: 16;
    xoffset: 8;
    yoffset: 4;
    zoffset: 0;
  }
}
The NML compiller is reportin 1 ERROR and 1 WARNING:
* Block 'rnd_houses_NW' is not referenced, ignoring. - for line with random switch definition.
* Expected a reference to a spriteset. for line with sprite layour reference to sprite

I assume, that it means, I can't use rnd_switch once I am assigning sprites via sprite_layout, is that so?

Do you have any other idea, how to implement such a random sprite selection together with spritelayout?


Thank you very much.
TadeuszD
Transport Coordinator
Transport Coordinator
Posts: 329
Joined: 07 Nov 2011 19:32
Location: PL

Re: spritelayout and random sprites in NML

Post by TadeuszD »

MarkyParky wrote:I assume, that it means, I can't use rnd_switch once I am assigning sprites via sprite_layout, is that so?

Do you have any other idea, how to implement such a random sprite selection together with spritelayout?
You can not assign switch or random switch to 'sprite' property. You can assign only static sprite or spriteset.
In your case you should define 4 spritelayouts (for 4 versions of your building) and use them in random switch triggered by 'default' callback.
Or, you can define one spriteset with 4 sprites (for 4 versions of your building) and use them in your spritelayout with manual selecting which sprite (building version) should be displayed (previously you should use STORE_TEMP(sprite_number, XXX) to select apropriate sprite):

Code: Select all

spritelayout my_house_spritelayout {
    ground {
        [...]
 	}
    building {
        sprite: my_house_spriteset(LOAD_TEMP(XXX));
        [...]
    }
}
Image
MarkyParky
Engineer
Engineer
Posts: 89
Joined: 20 Nov 2003 15:20

Re: spritelayout and random sprites in NML

Post by MarkyParky »

Thnx,

The second option seems fine, I'll try it.
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 4 guests