pick sprite dep. on adjecent one ? Help!

Discuss, get help with, or post new graphics for TTDPatch and OpenTTD, using the NewGRF system, here. Graphics for plain TTD also acceptable here.

Moderator: Graphics Moderators

Post Reply
Dante123
Chief Executive
Chief Executive
Posts: 672
Joined: 11 Aug 2009 16:10
Location: The Nederlands
Contact:

pick sprite dep. on adjecent one ? Help!

Post by Dante123 »

Pretty basic question:
For station tiles, how do i pick a sprite depending on a specific one that is adjacent to it ?

for example i have 4 ways of placing a Bufferstop tile (NE-SE-SW-NW)
now i know how i can code it as pairs, but in that case it will be 2 separate station ID numbers.
i know of some sets that already do that trick (Japanese set/ISR set/...) they have it auto picked once specific tiles are built next to it (so it does not count for any station tile that is next to it)

but i have no idea what action to use for this, (my guess would be action 9 ? ) and i have no idea how it should be looking like.

is there someone that can explain just a bit and maybe (please) add some example code ?
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: pick sprite dep. on adjecent one ? Help!

Post by planetmaker »

You'll need to make use of an varaction2 sequence to decide upon the sprite to be used. Probably variables 45 and 68 and maybe 67 will help you. See http://wiki.ttdpatch.net/tiki-index.php ... y_tiles_68_
Dante123
Chief Executive
Chief Executive
Posts: 672
Joined: 11 Aug 2009 16:10
Location: The Nederlands
Contact:

Re: pick sprite dep. on adjecent one ? Help!

Post by Dante123 »

im really lacking coding skills to code something from scratch :(

maybe anyone can help me with some code example i can look at to be able to understand how it works ?
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: pick sprite dep. on adjecent one ? Help!

Post by planetmaker »

Right... you basically link from the Action3 to the varaction2 which then checks the variable(s), can branch further to further variable check until you (finally) branch to a normal action2. Here an example from a train which I coded, where I check the year in order to decide the sprite being drawn:

Code: Select all

1260 * 6 01 00 \b2 FF \wx0004  // two sets à 4 sprites (loading and loaded)

1261 src/gfx/bulk/rail_bauxite_temperate.png 0 0 01 24 8 -3 -12 
1262 src/gfx/bulk/rail_bauxite_temperate.png 16 0 01 17 22 -14 -9 
1263 src/gfx/bulk/rail_bauxite_temperate.png 48 0 01 12 32 -16 -8 
1264 src/gfx/bulk/rail_bauxite_temperate.png 96 0 01 17 22 -6 -9 

1265 src/gfx/bulk/rail_bauxite_temperate.png 126 0 01 24 8 -3 -12 
1266 src/gfx/bulk/rail_bauxite_temperate.png 142 0 01 17 22 -14 -9 
1267 src/gfx/bulk/rail_bauxite_temperate.png 174 0 01 12 32 -16 -8 
1268 src/gfx/bulk/rail_bauxite_temperate.png 222 0 01 17 22 -6 -9 

// Name: bulk_wagon_bauxite_early_group
1269 * 13 02 00 FD \b2 \b2  // action2 linking early wagon sprites
\w0 \w1 
\w0 \w1 

1270 * 6 01 00 \b2 FF \wx0004 // two sets à 4 sprites (loading and loaded)

1271 src/gfx/bulk/rail_bauxite_temperate.png 0 32 01 24 8 -3 -12 
1272 src/gfx/bulk/rail_bauxite_temperate.png 16 32 01 17 22 -14 -9 
1273 src/gfx/bulk/rail_bauxite_temperate.png 48 32 01 12 32 -16 -8 
1274 src/gfx/bulk/rail_bauxite_temperate.png 96 32 01 17 22 -6 -9 

1275 src/gfx/bulk/rail_bauxite_temperate.png 126 32 01 24 8 -3 -12 
1276 src/gfx/bulk/rail_bauxite_temperate.png 142 32 01 17 22 -14 -9 
1277 src/gfx/bulk/rail_bauxite_temperate.png 174 32 01 12 32 -16 -8 
1278 src/gfx/bulk/rail_bauxite_temperate.png 222 32 01 17 22 -6 -9 

// Name: bulk_wagon_bauxite_modern_group
1279 * 13 02 00 FC \b2 \b2 // action2 linking modern wagon sprites
\w0 \w1 
\w0 \w1 

// Name: bulk_wagon_bauxite_year_switch
1280 * 44 02 00 F8 89 // varaction2 deciding upon sprites used as function of year: action2-ID: F8, type 89
49 00 \dxFFFFFFFF      // check variable 49 (build year); this is a varaction2, no further modification, mask 0xFFFFFFFF (use all bits of var 49)
\b1 // one range check
\wx00FD \dx00000000 \dx000007B2 	// 0 .. 1970: bulk_wagon_bauxite_early_group (ID 0xFD)
\wx00FC // default: otherwise modern group (ID 0xFC)
...
1547 * 9 03 00 01 FF \wx0074 \b0 \wx00F8  // action3, (vehicleID 0x74), use (var)action2 ID 0xF8)
Similar you can do that for a station, sprite with your variables, too.
Dante123
Chief Executive
Chief Executive
Posts: 672
Joined: 11 Aug 2009 16:10
Location: The Nederlands
Contact:

Re: pick sprite dep. on adjecent one ? Help!

Post by Dante123 »

i was also looking at the buffers now how industrial station renewal did it.

his code looks like this:

Code: Select all

   -1 * 82	 00 04 07 01 10 08 "ISRI" 09 04 F4 03 00 00 00 00 00 10 10 01 2D 04 00 00 80 F3 03 00 00 00
	 00 00 10 10 01 2E 04 00 00 80 0E 04 00 00 00 00 00 10 10 01 2D 04 00 00 80 0D 04 00 00 00 00 00
	 10 10 01 2E 04 00 00 80 0B 02 0D FE 11 00 14 FF 15 FF
	 
   -1 * 4	 01 04 03 02
   -1 sprites/bb.pcx 34 3752 01 31 64 -31 0
   -1 sprites/bb.pcx 114 3752 01 31 64 -31 0
   
   -1 sprites/bb.pcx 194 3752 01 31 64 -31 0
   -1 sprites/bb.pcx 274 3752 01 31 64 -31 0
   
   -1 sprites/bb.pcx 354 3752 01 31 64 -31 0
   -1 sprites/bb.pcx 434 3752 01 31 64 -31 0
   
   -1 * 7	 02 04 00 00 01 00 00
   -1 * 7	 02 04 01 00 01 01 00
   -1 * 7	 02 04 02 00 01 02 00
   
   
//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -     
   
  
   -1 * 14	 02 04 06 
						81 
						45 00 01 01 02 00 01 01 01 00
   -1 * 14	 02 04 07 
						81 
						45 01 01 01 06 00 01 01 00 00
   -1 * 18	 02 04 03
						81 
						42 00 FF 02 02 80 01 01 02 80 04 04 00 80
   -1 * 14	 02 04 04 
						81 
						0C 00 FF 01 03 00 14 14 07 00
   -1 * 14	 02 04 05 
						81 
						0C 00 FF 01 00 80 14 14 00 00
   
   
//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -    

   
   
   -1 * 10	 03 04 01 10 01 FF 05 00 04 00
 
the part i should be looking at is the part between // - - - -
will try to make sense out of that with the wiki and you code :)
Dante123
Chief Executive
Chief Executive
Posts: 672
Joined: 11 Aug 2009 16:10
Location: The Nederlands
Contact:

Re: pick sprite dep. on adjecent one ? Help!

Post by Dante123 »

mm nope, im just not getting it for stations :/

help still needed :(
michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Re: pick sprite dep. on adjecent one ? Help!

Post by michael blunck »

Dante123 wrote: help still needed :(
Read http://wiki.ttdpatch.net/tiki-index.php ... on_info_45_ and be enlightened.

regards
Michael
Image
Dante123
Chief Executive
Chief Executive
Posts: 672
Joined: 11 Aug 2009 16:10
Location: The Nederlands
Contact:

Re: pick sprite dep. on adjecent one ? Help!

Post by Dante123 »

michael blunck wrote:
Dante123 wrote: help still needed :(
Read http://wiki.ttdpatch.net/tiki-index.php ... on_info_45_ and be enlightened.

regards
Michael

well yea that part i have been reading over and over again already. but enlightenment seems to fail :wink:
michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Re: pick sprite dep. on adjecent one ? Help!

Post by michael blunck »

Dante123 wrote:
michael blunck wrote:
Dante123 wrote: help still needed :(
Read http://wiki.ttdpatch.net/tiki-index.php ... on_info_45_ and be enlightened.
well yea that part i have been reading over and over again already. but enlightenment seems to fail :wink:
How about the pictures then? Sometimes, enlightenment comes by sound or touch, it may also come by watching pictures.

regards
Michael
Image
Dante123
Chief Executive
Chief Executive
Posts: 672
Joined: 11 Aug 2009 16:10
Location: The Nederlands
Contact:

Re: pick sprite dep. on adjecent one ? Help!

Post by Dante123 »

1.PNG
1.PNG (20.4 KiB) Viewed 1164 times
-

got it working :)
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 19 guests