[m4nfo] Changing sprites based on test_position

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

Moderator: Graphics Moderators

Post Reply
User avatar
Erato
Route Supervisor
Route Supervisor
Posts: 385
Joined: 25 May 2015 09:09
Location: The Netherlands

[m4nfo] Changing sprites based on test_position

Post by Erato » 06 Aug 2018 14:46

So I managed to get some stations made with m4nfo, and now I want to make a station building that's either 1x1 or 1x3. For this I would like the 1x1 to use one sprite, and the 1x3 three different sprites, like the "Douma style" building from the Dutch Stations Addition set.
The layout block:
[+] Spoiler

Code: Select all

layout(041,
//[0,1] Lone sprite
    tile(,
      ground(1012)
      regular(46, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(47, xyz(0,0,0),dxdydz(5,16,7))
    )
//[2,3] Centre sprite
    tile(
      ground(1012)
      regular(50, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(51, xyz(0,0,0),dxdydz(5,16,7))
    )
//[4,5] Top sprites
    tile(
      ground(1012)
      regular(58, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(59, xyz(0,0,0),dxdydz(5,16,7))
    )
//[6,7] Bottom sprites
    tile(
      ground(1012)
      regular(54, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(55, xyz(0,0,0),dxdydz(5,16,7))
    )
)
layout(042,//Kwangok back
    tile(,
      ground(1012)
      regular(48, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(49, xyz(0,0,0),dxdydz(5,16,7))
    )
)
From the tutorial, I gathered that I needed something like this to get different sprites:

Code: Select all

def(2) test_position(
	cbr(4) if(nibble(0,0))
	cbr(6) if(nibble(2,0))
	cbr(2) else
)
def(3) test_length(
	cbr(0) if(1)
	ref(1) else
)
def(4) callback(
	ref(3) if(CB_LAYOUT)
	ref(1) else
)
However, this causes the 1x1 and the center of the 1x3 to have the same sprite (only the center has the right sprite) and the sides of the 1x3 to get the sprite of the 1x1.

How would I go about getting this to work?
No pics no clicks. Seriously.
ImageImageImageImageImageImage

Eddi
Tycoon
Tycoon
Posts: 7395
Joined: 17 Jan 2007 00:14

Re: [m4nfo] Changing sprites based on test_position

Post by Eddi » 06 Aug 2018 15:22

in "def(3)", shouldn't that "ref(1)" be "ref(2)"?
You might not exactly be interested in Ferion, but if you are, have fun :)

michael blunck
Tycoon
Tycoon
Posts: 5269
Joined: 27 Apr 2005 07:09
Contact:

Re: [m4nfo] Changing sprites based on test_position

Post by michael blunck » 06 Aug 2018 17:07

Like Eddi said.

BTW, why are you including an empty label in some of your functions tile()? Like this:

Code: Select all

tile(,
?

And why are you using functions test_position() and test_length()? Instead of the plt_*() functions? You´d only use those test_*() functions when being in a tiletype callback (CB_TILETYPE), testing if a certain station tile can be built?

regards
Michael
Image

User avatar
Erato
Route Supervisor
Route Supervisor
Posts: 385
Joined: 25 May 2015 09:09
Location: The Netherlands

Re: [m4nfo] Changing sprites based on test_position

Post by Erato » 06 Aug 2018 18:46

Eddi wrote:in "def(3)", shouldn't that "ref(1)" be "ref(2)"?
Ah yes, that was a remnant from testing a few things.
michael blunck wrote:BTW, why are you including an empty label in some of your functions tile()? Like this:

Code: Select all

tile(,
?
And why are you using functions test_position() and test_length()? Instead of the plt_*() functions? You´d only use those test_*() functions when being in a tiletype callback (CB_TILETYPE), testing if a certain station tile can be built
As for the empty tag, I tried it with tags, without tags, using cbr() with label, cbr() with number, using ref() with label, using reftile() with label, nothing worked. So I must've missed that comma. But unfortunately, removing that comma did not help me at all.
As for the plt_*() functions, I did not know they exist. TIL.
I tested some more, and skipping the callback and switches and everything has the same effect as having them there, suggesting that it doesn't seem to check anything at all.
Perhaps I made a mistake here that could have caused it:

Code: Select all

makestation(041,
	default(ref(4))
)
No pics no clicks. Seriously.
ImageImageImageImageImageImage

michael blunck
Tycoon
Tycoon
Posts: 5269
Joined: 27 Apr 2005 07:09
Contact:

Re: [m4nfo] Changing sprites based on test_position

Post by michael blunck » 06 Aug 2018 19:23

You mean, it still "does not work"?

And BTW, that "041" is more than dubious. What is it: a trailing O or zero? I don´t think it´s a proper ID, since IDs have to be numbers. Or you have a definition somewhere else in your source which translates it into a proper number?

[edit]
Erato wrote: As for the plt_*() functions, I did not know they exist.
Those functions return information about the current tile, i.e., which platform it is on and how far along the platform. E.g., drawing different sprites for 3 station tiles (0, 2, 4) on a single platform, you should code it like this:

Code: Select all

// get position on platform
def(1) plt_pos(
	ref(0) if(0) // top tile
	ref(2) if(1) // middle tile
	ref(4) else // bottom tile
)
In case you have two platforms with different sprites for all 6 station tiles, you´d do it like this:

Code: Select all

def(1) plt_pos(
	ref(0) if(0) // top tile
	ref(2) if(1) // middle tile
	ref(4) else // bottom tile
)

def(2) plt_pos(
	ref(6) if(0) // top tile
	ref(8) if(1) // middle tile
	ref(10) else // bottom tile
)

// get platform number
def(3) plt_num(
	ref(1) if(0) // left platform
	ref(2) else // right platform
)
etc.

HTH
[/edit]

regards
Michael
Image

User avatar
Erato
Route Supervisor
Route Supervisor
Posts: 385
Joined: 25 May 2015 09:09
Location: The Netherlands

Re: [m4nfo] Changing sprites based on test_position

Post by Erato » 06 Aug 2018 20:23

michael blunck wrote:You mean, it still "does not work"?
Yes it stil does not work. It still causes the 1x1 and the center of the 1x3 to have the same sprite (only the center has the right sprite) and the sides of the 1x3 to get the sprite of the 1x1. Exactly as I said in the OP. And I seem to have deduced that this problem is caused by the game not properly registering the switches and callbacks.
michael blunck wrote:And BTW, that "041" is more than dubious. What is it: a trailing O or zero? I don´t think it´s a proper ID, since IDs have to be numbers. Or you have a definition somewhere else in your source which translates it into a proper number
It's not dubious at all. It's a proper number. I intend to have more than 100 things and I find it more aesthetically pleasing if all IDs have the same amount of digits.

Edit:
As for the plt_*() functions, I see now.

As for your proposed fix, using ref() there caused the game to crash, and using other functions causes the problem to persist.

My code now looks like this:

Code: Select all

layout(041,
//[0,1] Lone sprite
    tile(
      ground(1012)
      regular(46, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(47, xyz(0,0,0),dxdydz(5,16,7))
    )
//[2,3] Centre sprite
    tile(
      ground(1012)
      regular(50, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(51, xyz(0,0,0),dxdydz(5,16,7))
    )
//[4,5] Top sprites
    tile(
      ground(1012)
      regular(58, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(59, xyz(0,0,0),dxdydz(5,16,7))
    )
//[6,7] Bottom sprites
    tile(
      ground(1012)
      regular(54, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(55, xyz(0,0,0),dxdydz(5,16,7))
    )
)

def(2) plt_pos(
	cbr(4) if(0)
	cbr(2) if(1)
	cbr(6) else
)
def(3) plt_length(
	cbr(0) if(1)
	ref(2) else
)
def(4) callback(
	ref(3) if(CB_LAYOUT)
	ref(1) else
)
makestation(041,
	default(ref(4))
)
No pics no clicks. Seriously.
ImageImageImageImageImageImage

michael blunck
Tycoon
Tycoon
Posts: 5269
Joined: 27 Apr 2005 07:09
Contact:

Re: [m4nfo] Changing sprites based on test_position

Post by michael blunck » 06 Aug 2018 21:19

Erato wrote: It's not dubious at all. It's a proper number. I intend to have more than 100 things and I find it more aesthetically pleasing if all IDs have the same amount of digits.
LOL. But you realize that "041" is an octal number? I.e. decimal "33"?

If you will have "more tha 100 things" (stations?), than it would be much better to give them names/labels than just numbers:

define(LEIDEN,100)
define(GRONINGEN,101)
...

definestation(LEIDEN,
...
)

makestation(LEIDEN,
...
)

etc.
Erato wrote: My code now looks like this:
But that´s only part of your code. So, your ref(1) references a spriteset()? Which in turn references sprites given in a spriteblock()?

regards
Michael
Image

User avatar
Erato
Route Supervisor
Route Supervisor
Posts: 385
Joined: 25 May 2015 09:09
Location: The Netherlands

Re: [m4nfo] Changing sprites based on test_position

Post by Erato » 06 Aug 2018 21:37

michael blunck wrote:But that´s only part of your code. So, your ref(1) references a spriteset()? Which in turn references sprites given in a spriteblock()?
Oh sorry, that would be this:

Code: Select all

def(1) spriteset(little(0),lots(0))
Not sure what it does, I just took it from the tutorial. It wasn't really explained there.
No pics no clicks. Seriously.
ImageImageImageImageImageImage

michael blunck
Tycoon
Tycoon
Posts: 5269
Joined: 27 Apr 2005 07:09
Contact:

Re: [m4nfo] Changing sprites based on test_position

Post by michael blunck » 06 Aug 2018 21:43

Erato wrote:
michael blunck wrote:But that´s only part of your code. So, your ref(1) references a spriteset()? Which in turn references sprites given in a spriteblock()?
Oh sorry, that would be this:

Code: Select all

def(1) spriteset(little(0),lots(0))
Not sure what it does, I just took it from the tutorial. It wasn't really explained there.
It references the sprites being defined in a spriteblock and links them to the layout (by using the layout callback).

From "the tutorial":

Code: Select all

spriteblock(
    set(
// [0 .. 5] locomotive shed
	sprite(shed5.pcx 10 10 09 16 21 -31 4)
	sprite(shed5.pcx 35 10 09 27 43 -32 -7)
	sprite(shed5.pcx 80 10 09 41 66 -31 1)
	sprite(shed5.pcx 150 10 09 41 66 -33 1)
	sprite(shed5.pcx 220 10 09 27 43 -9 -7)
	sprite(shed5.pcx 270 10 09 16 21 12 4)
...
// [10 .. 13] walls & doors
	sprite(shed5.pcx 10 110 09 18 15 0 0)
	sprite(shed5.pcx 28 110 09 18 15 0 0)
	sprite(shed5.pcx 46 110 09 18 15 0 0)
	sprite(shed5.pcx 64 110 09 18 15 0 0)
// [14 .. 15] locomotive shed (snowy roof)
	sprite(shed5.pcx 10 130 09 41 66 -31 1)
	sprite(shed5.pcx 80 130 09 41 66 -33 1)
...

// [18 .. 19] icon locomotive shed
	sprite(shed5.pcx 10 223 09 46 66 -31 -15)
	sprite(shed5.pcx 80 223 09 46 66 -31 -15)
...
   )
)

def(1) spriteset(little(0),lots(0))
HTH
Michael
Image

User avatar
Erato
Route Supervisor
Route Supervisor
Posts: 385
Joined: 25 May 2015 09:09
Location: The Netherlands

Re: [m4nfo] Changing sprites based on test_position

Post by Erato » 06 Aug 2018 22:02

michael blunck wrote:It references the sprites being defined in a spriteblock and links them to the layout (by using the layout callback)
I see now. I still don't quite understand how I would have to change this:

Code: Select all

spriteblock(
    set(
// [0..3] Base platform
	sprite(NormalPlatforms.png 0 0 09 70 64 -31 -23) //front
	sprite(NormalPlatforms.png 65 0 09 70 64 -31 -23) //front
	sprite(NormalPlatforms.png 0 71 09 70 64 -31 -39)
	sprite(NormalPlatforms.png 65 71 09 70 64 -31 -39)
// [4..7] Base platform w/ sign 1
	sprite(NormalPlatforms.png 0 142 09 70 64 -31 -23) //front
	sprite(NormalPlatforms.png 65 142 09 70 64 -31 -23) //front
	sprite(NormalPlatforms.png 0 213 09 70 64 -31 -39)
	sprite(NormalPlatforms.png 65 213 09 70 64 -31 -39)
// [8..11] Base platform w/ sign 2
	sprite(NormalPlatforms.png 130 0 09 70 64 -31 -23) //front
	sprite(NormalPlatforms.png 195 0 09 70 64 -31 -23) //front
	sprite(NormalPlatforms.png 130 71 09 70 64 -31 -39)
	sprite(NormalPlatforms.png 195 71 09 70 64 -31 -39)
// [12..15] Base platform w/ sign 3
	sprite(NormalPlatforms.png 130 142 09 70 64 -31 -23) //front
	sprite(NormalPlatforms.png 195 142 09 70 64 -31 -23) //front
	sprite(NormalPlatforms.png 130 213 09 70 64 -31 -39)
	sprite(NormalPlatforms.png 195 213 09 70 64 -31 -39)
// [16..19] Base platform w/ sign 4
	sprite(NormalPlatforms.png 130 284 09 70 64 -31 -23) //front
	sprite(NormalPlatforms.png 195 284 09 70 64 -31 -23) //front
	sprite(NormalPlatforms.png 130 355 09 70 64 -31 -39)
	sprite(NormalPlatforms.png 195 355 09 70 64 -31 -39)
// [20..23] Base platform w/ propaganda
	sprite(NormalPlatforms.png 130 426 09 70 64 -31 -23) //front
	sprite(NormalPlatforms.png 195 426 09 70 64 -31 -23) //front
	sprite(NormalPlatforms.png 130 497 09 70 64 -31 -39)
	sprite(NormalPlatforms.png 195 497 09 70 64 -31 -39)
// [24..25] Crossing back
	sprite(NormalPlatforms.png 260 71 09 70 64 -31 -39) //front
	sprite(NormalPlatforms.png 325 71 09 70 64 -31 -39) //front
// [26..29] Crossing high
	sprite(NormalPlatforms.png 260 0 09 70 64 -31 -39) //front
	sprite(NormalPlatforms.png 325 0 09 70 64 -31 -39) //front
	sprite(NormalPlatforms.png 260 142 09 70 64 -31 -23)
	sprite(NormalPlatforms.png 325 142 09 70 64 -31 -23)
// [30..33] Platform end straight back
	sprite(NormalPlatforms.png 390 0 09 70 64 -31 -23) //front
	sprite(NormalPlatforms.png 455 0 09 70 64 -31 -23) //front
	sprite(NormalPlatforms.png 390 71 09 70 64 -31 -39)
	sprite(NormalPlatforms.png 455 71 09 70 64 -31 -39)
// [34..37] Platform end straight front
	sprite(NormalPlatforms.png 390 142 09 70 64 -31 -23) //front
	sprite(NormalPlatforms.png 455 142 09 70 64 -31 -23) //front
	sprite(NormalPlatforms.png 390 213 09 70 64 -31 -39)
	sprite(NormalPlatforms.png 455 213 09 70 64 -31 -39)
// [38..41] Platform end sloped back
	sprite(NormalPlatforms.png 390 284 09 70 64 -31 -23) //front
	sprite(NormalPlatforms.png 455 284 09 70 64 -31 -23) //front
	sprite(NormalPlatforms.png 390 355 09 70 64 -31 -39)
	sprite(NormalPlatforms.png 455 355 09 70 64 -31 -39)
// [42..45] Platform end sloped front
	sprite(NormalPlatforms.png 390 426 09 70 64 -31 -23) //front
	sprite(NormalPlatforms.png 455 426 09 70 64 -31 -23) //front
	sprite(NormalPlatforms.png 390 497 09 70 64 -31 -39)
	sprite(NormalPlatforms.png 455 497 09 70 64 -31 -39)
//----------------------------------------------------------------------------------------------------
//	Station Buildings
//----------------------------------------------------------------------------------------------------
// [46..53] Kwangok central building
	sprite(NormalBuildings.png 0 0 09 70 64 -31 -39)
	sprite(NormalBuildings.png 65 0 09 70 64 -31 -39)
	sprite(NormalBuildings.png 0 71 09 70 64 -31 -39)
	sprite(NormalBuildings.png 65 71 09 70 64 -31 -39)
	
	sprite(NormalBuildings.png 0 142 09 70 64 -31 -39)
	sprite(NormalBuildings.png 65 142 09 70 64 -31 -39)
	sprite(NormalBuildings.png 0 213 09 70 64 -31 -39)
	sprite(NormalBuildings.png 65 213 09 70 64 -31 -39)
// [54..61] Kwangok side building
	sprite(NormalBuildings.png 130 0 09 70 64 -31 -39)
	sprite(NormalBuildings.png 195 0 09 70 64 -31 -39)
	sprite(NormalBuildings.png 130 71 09 70 64 -31 -39)
	sprite(NormalBuildings.png 195 71 09 70 64 -31 -39)
	
	sprite(NormalBuildings.png 130 142 09 70 64 -31 -39)
	sprite(NormalBuildings.png 195 142 09 70 64 -31 -39)
	sprite(NormalBuildings.png 130 213 09 70 64 -31 -39)
	sprite(NormalBuildings.png 195 213 09 70 64 -31 -39)
// [62..69] Kwangok side building w/ eyecandy
	sprite(NormalBuildings.png 260 0 09 70 64 -31 -39)
	sprite(NormalBuildings.png 325 0 09 70 64 -31 -39)
	sprite(NormalBuildings.png 260 71 09 70 64 -31 -39)
	sprite(NormalBuildings.png 325 71 09 70 64 -31 -39)
	
	sprite(NormalBuildings.png 260 142 09 70 64 -31 -39)
	sprite(NormalBuildings.png 325 142 09 70 64 -31 -39)
	sprite(NormalBuildings.png 260 213 09 70 64 -31 -39)
	sprite(NormalBuildings.png 325 213 09 70 64 -31 -39)
   )
)

def(1) spriteset(little(0),lots(0))
So that this:

Code: Select all

//----------------------------------------------------------------------------------------------------
//	Station Building
//----------------------------------------------------------------------------------------------------
layout(KWANGOK_FRONT,
//[0,1] Lone sprite
    tile(
      ground(1012)
      regular(46, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(47, xyz(0,0,0),dxdydz(5,16,7))
    )
//[2,3] Centre sprite
    tile(
      ground(1012)
      regular(50, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(51, xyz(0,0,0),dxdydz(5,16,7))
    )
//[4,5] Top sprites
    tile(
      ground(1012)
      regular(58, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(59, xyz(0,0,0),dxdydz(5,16,7))
    )
//[6,7] Bottom sprites
    tile(
      ground(1012)
      regular(54, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(55, xyz(0,0,0),dxdydz(5,16,7))
    )
)

def(2) 

def(3) plt_pos(
	cbr(4) if(0)
	cbr(2) if(1)
	cbr(6) else
)
def(4) plt_length(
	cbr(0) if(1)
	ref(2) else
)
def(5) callback(
	ref(3) if(CB_LAYOUT)
	ref(3) else
)
makestation(KWANGOK_FRONT,
	default(ref(5))
)
works to provide the Lone sprite when length is 1, and if the length is 3 the Top sprite at (0,0), the Center sprite in at (0,1) and the Bottom sprite at (0,2)?
Seeing as using reftile(_label) -which is used in that tutorial- does not seem to work.
No pics no clicks. Seriously.
ImageImageImageImageImageImage

michael blunck
Tycoon
Tycoon
Posts: 5269
Joined: 27 Apr 2005 07:09
Contact:

Re: [m4nfo] Changing sprites based on test_position

Post by michael blunck » 06 Aug 2018 22:15

Erato wrote: I see now. I still don't quite understand how I would have to change this:

Code: Select all

spriteblock(
    set(
// [0..3] Base platform
            ...
	sprite(NormalBuildings.png 325 213 09 70 64 -31 -39)
   )
)

def(1) spriteset(little(0),lots(0))
So that this:

Code: Select all

//----------------------------------------------------------------------------------------------------
//	Station Building
//----------------------------------------------------------------------------------------------------
layout(KWANGOK_FRONT,
    ...
)

def(2) 

def(3) plt_pos(
	cbr(4) if(0)
	cbr(2) if(1)
	cbr(6) else
)
def(4) plt_length(
	cbr(0) if(1)
	ref(2) else
)
)
works to provide the Lone sprite when length is 1, and if the length is 3 the Top sprite at (0,0), the Center sprite in at (0,1) and the Bottom sprite at (0,2)?
Your def(2) is undefined!?

should look like

Code: Select all

def(3) plt_pos(
	cbr(4) if(0)
	cbr(2) if(1)
	cbr(6) else
)

def(4) plt_length(
	cbr(0) if(1)
	ref(3) else
)
Erato wrote: Seeing as using reftile(_label) -which is used in that tutorial- does not seem to work.
It does work, but it is not needed, you can always use the real tile numbers in the layout callback. It might be convenient, though.

regards
Michael
Image

User avatar
Erato
Route Supervisor
Route Supervisor
Posts: 385
Joined: 25 May 2015 09:09
Location: The Netherlands

Re: [m4nfo] Changing sprites based on test_position

Post by Erato » 06 Aug 2018 22:46

Well it sure seems to me like both reftile and cbr don't do anything, seeing as:

Code: Select all

def(1) spriteset(little(0),lots(0))
layout(KWANGOK_FRONT,
//[0,1] Lone sprite
    tile(_lone,
      ground(1012)
      regular(46, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(47, xyz(0,0,0),dxdydz(5,16,7))
    )
//[2,3] Centre sprite
    tile(_centre,
      ground(1012)
      regular(50, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(51, xyz(0,0,0),dxdydz(5,16,7))
    )
//[4,5] Top sprites
    tile(_top,
      ground(1012)
      regular(58, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(59, xyz(0,0,0),dxdydz(5,16,7))
    )
//[6,7] Bottom sprites
    tile(_bottom,
      ground(1012)
      regular(54, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(55, xyz(0,0,0),dxdydz(5,16,7))
    )
)

def(2) plt_pos(
	reftile(_top) if(0)
	reftile(_centre) if(1)
	reftile(_bottom) else
)
def(3) plt_length(
	reftile(_lone) if(1)
	ref(2) else
)
def(4) callback(
	ref(3) if(CB_LAYOUT)
	ref(1) else
)
makestation(KWANGOK_FRONT,
	default(ref(4))
)

Code: Select all

def(1) spriteset(little(0),lots(0))
layout(KWANGOK_FRONT,
//[0,1] Lone sprite
    tile(
      ground(1012)
      regular(46, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(47, xyz(0,0,0),dxdydz(5,16,7))
    )
//[2,3] Centre sprite
    tile(
      ground(1012)
      regular(50, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(51, xyz(0,0,0),dxdydz(5,16,7))
    )
//[4,5] Top sprites
    tile(
      ground(1012)
      regular(58, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(59, xyz(0,0,0),dxdydz(5,16,7))
    )
//[6,7] Bottom sprites
    tile(
      ground(1012)
      regular(54, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(55, xyz(0,0,0),dxdydz(5,16,7))
    )
)

def(2) plt_pos(
	cbr(4) if(0)
	cbr(2) if(1)
	cbr(6) else
)
def(3) plt_length(
	cbr(0) if(1)
	ref(2) else
)
def(4) callback(
	ref(3) if(CB_LAYOUT)
	ref(1) else
)
makestation(KWANGOK_FRONT,
	default(ref(4))
)
and

Code: Select all

def(1) spriteset(little(0),lots(0))
layout(KWANGOK_FRONT,
//[0,1] Lone sprite
    tile(
      ground(1012)
      regular(46, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(47, xyz(0,0,0),dxdydz(5,16,7))
    )
//[2,3] Centre sprite
    tile(
      ground(1012)
      regular(50, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(51, xyz(0,0,0),dxdydz(5,16,7))
    )
//[4,5] Top sprites
    tile(
      ground(1012)
      regular(58, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(59, xyz(0,0,0),dxdydz(5,16,7))
    )
//[6,7] Bottom sprites
    tile(
      ground(1012)
      regular(54, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(55, xyz(0,0,0),dxdydz(5,16,7))
    )
)
makestation(KWANGOK_FRONT,
	default(ref(1))
)
All result in this:
Image
While I want this (mockup):
Image
And I don't know what I could be doing to make this work.
No pics no clicks. Seriously.
ImageImageImageImageImageImage

michael blunck
Tycoon
Tycoon
Posts: 5269
Joined: 27 Apr 2005 07:09
Contact:

Re: [m4nfo] Changing sprites based on test_position

Post by michael blunck » 07 Aug 2018 06:05

Please take a look into your definestation(). Did you specify the usage of the layout callback there? Probably not ...

E.g.:

Code: Select all

define(FRONTS,46 52 4E 54) // class label "FRNT"
define(KWANGOK_FRONT,41) // stat ID

definestation(KWANGOK_FRONT,"Kwangok front",
	class(FRONTS) // class label
	callbacks(CB_LAYOUT)                        
	include_widths(1)
	include_lengths({1,3})
	pylons(TTD_NONE) // no pylons
	wires(TTD_NONE) // no wires
)

spriteblock(
	...
)

def(1) spriteset(little(0),lots(0))

layout(KWANGOK_FRONT,
// [0,1] single
    tile(_lone,
      ground(1012)
      regular(46, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(47, xyz(0,0,0),dxdydz(5,16,7))
    )
// [2,3] centre
    tile(_centre,
      ground(1012)
      regular(50, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(51, xyz(0,0,0),dxdydz(5,16,7))
    )
// [4,5] top
    tile(_top,
      ground(1012)
      regular(58, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(59, xyz(0,0,0),dxdydz(5,16,7))
    )
// [6,7] bottom
    tile(_bottom,
      ground(1012)
      regular(54, xyz(0,0,0),dxdydz(16,5,7))
    )
    tile(
      ground(1011)
      regular(55, xyz(0,0,0),dxdydz(5,16,7))
    )
)

def(2) plt_pos(
   reftile(_top) if(0)
   reftile(_centre) if(1)
   reftile(_bottom) else
)

def(3) plt_length(
   reftile(_lone) if(1)
   ref(2) else
)

def(4) callback(
   ref(3) if(CB_LAYOUT)
   ref(1) else
)

makestation(KWANGOK_FRONT,
   default(ref(4))
)
regards
Michael
Image

User avatar
Erato
Route Supervisor
Route Supervisor
Posts: 385
Joined: 25 May 2015 09:09
Location: The Netherlands

Re: [m4nfo] Changing sprites based on test_position

Post by Erato » 07 Aug 2018 12:33

michael blunck wrote:Please take a look into your definestation(). Did you specify the usage of the layout callback there? Probably not ...
That was absolutely not the case; the everything that needed to be present was there:

Code: Select all

definestation(BUILDING_KWANGOK_FRONT,"Kwangok building front",
	class(CLASS_BUILDING)
	callbacks(CB_LAYOUT)                        
	include_widths(1)
	include_lengths({1,3})
	pylons(TTD_NONE)
	wires(TTD_NONE)
	nontrack(TTD_ALLTILES)
)
But thanks to your code I managed to figure out that the problem was that the classes need labels like railtypes, which I couldn't gather from the documentation's explanation of "class(<Label>)", which suggested that anything would go. I could never have guessed that the problem originate from a faulty class() property either. So thanks for sharing your code with me, it really helped me!
No pics no clicks. Seriously.
ImageImageImageImageImageImage

michael blunck
Tycoon
Tycoon
Posts: 5269
Joined: 27 Apr 2005 07:09
Contact:

Re: [m4nfo] Changing sprites based on test_position

Post by michael blunck » 07 Aug 2018 16:00

Erato wrote: [...] I managed to figure out that the problem was that the classes need labels like railtypes, which I couldn't gather from the documentation's explanation of "class(<Label>)", which suggested that anything would go.
Type <Label> is documented here:
m4nfo User Manual wrote: Simple data types
...
Char <ASCII_char> | <UTF-8_char>
...

Structured data types
...
Label <Char>*4 Definition of (class) labels for stations, cargoes and railtypes
...

http://www.ttdpatch.de/grfspecs/m4nfoMa ... Types.html
Erato wrote: I could never have guessed that the problem originate from a faulty class() property either.
Since a class label must be given in a station definition, everything might get wrong if it´s being missed or ill-formed.

regards
Michael
Image

Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 2 guests