Can one NewGRF reference a base set?
Moderator: Graphics Moderators
Re: Can one NewGRF reference a base set?
Since the code you've shown us looks correct, could the error in the graphics callback handler not being updated to point to the random action2 rather than the standard one?
~ Lakie
~ Lakie
TTDpatch Developer 2005 - 2010 ~ It all started because of shortened vehicle not loading correctly, now look where I've gone with it!
Grfs coded ~ Finnish Train Set (Teaser) | Bm73 (Release 3) | Emu 680 (Release 3)| Glass Station (Release 1) | UK Roadset (Version 1.1a) | New Water Coasts (Version 7)
Pikka: "Lakie's a good coder, but before he'll add any feature to TTDP you have to convince him that you're not going to use it to destroy the world as we know it."
Grfs coded ~ Finnish Train Set (Teaser) | Bm73 (Release 3) | Emu 680 (Release 3)| Glass Station (Release 1) | UK Roadset (Version 1.1a) | New Water Coasts (Version 7)
Pikka: "Lakie's a good coder, but before he'll add any feature to TTDP you have to convince him that you're not going to use it to destroy the world as we know it."
Re: Can one NewGRF reference a base set?
DJ Nekkid wrote:-1 * 0 02 04 A0 // Action2, ID A0
00 01 // 0 when loading, 1 when running (or vica verca)
\w0 // First set in the prev. Action1
-1 * 0 02 04 A1 // Action2, ID A1
00 01 // blabla
\w1
[/code]
Then for the var2, looks correct as far as i can see, but let me try
Now, remember to refrence B0 in the Action, or the next var2/callback chain.Code: Select all
-1 * 0 02 04 B0 80 // Action2, stations, ID, Random 00 00 // See below ** 02 // Number of randoms A0 00 // First random obj A1 00 // Second random obj
** According to the specs might the first set of 00's be: (or 00 if none of theese)The second pair of 00's are might need to be 02 as well, but 00 should work fine as well as far as i've understood the wiki.Code: Select all
Bit Value Trigger 0 01 new cargo waiting 1 02 no more cargo 2 04 train arrives (starts unloading/loading) 3 08 train leaves (done unloading & loading) 4 10 train loads or unloads cargo 5 20 train reserves platform (using PBS)
For NuTracks i use some random things as well, and your code looks pretty much like mine...Code: Select all
*Action1 with 4 sets -1 * 0 02 10 41 00 01 \w0 -1 * 0 02 10 42 00 01 \w1 -1 * 0 02 10 43 00 01 \w2 -1 * 0 02 10 44 00 01 \w3 -1 * 0 02 10 4C 80 00 00 04 41 00 42 00 43 00 44 00
grrrrr still not working :/
using this code
Code: Select all
###########################################################################
// Station tile referencing flat plain grass for ground sprite
// substitute "SetID" for "cargoID" if necessary
// Action 00 : define a station tile
3 * 142 00 // 00 <Feature> <Num-props> <Num-info> <Id> (<Property <New-info>)...
04 07 01 // 04 = Stations ; numProperties ; change 1 station
00 // STAT-ID
08 "DWSA" // StationClass
15 FF 11 00 14 FF // non-track ; no catenary ; no wires
// subtract appropriate number from sprite number for monorail and maglev
09 08 // var 09 = sprite layout - Define (2 orientations * 3 tiles) = 6 layouts
//** plus two layouts for build menu **
8D 0F 00 00 // ground sprite = flat plain grass
00 00 00 0F 0F 10 // offsets; sizes
2D 04 00 00 // draw sprite 042D (first linked Action 01 sprite)
80 // next Layout
8D 0F 00 00 // ground sprite = flat plain grass
00 00 00 0F 0F 10 // offsets; sizes
2E 04 00 00
80 // next Layout
3B 0F 00 00 // ground sprite = flat plain grass - 82
00 00 00 0F 0F 10 // offsets; sizes
2D 04 00 00
80 // next Layout
3B 0F 00 00 // ground sprite = flat plain grass - 82
00 00 00 0F 0F 10 // offsets; sizes
2E 04 00 00
80 // next Layout
E9 0E 00 00 // ground sprite = flat plain grass - 164
00 00 00 0F 0F 10 // offsets; sizes
2D 04 00 00
80 // next Layout
E9 0E 00 00 // ground sprite = flat plain grass - 164
00 00 00 0F 0F 10 // offsets; sizes
2E 04 00 00
80 // next Layout
//** build menu **
F4 03 00 00 //** draw rail sprite since it is always flat **
00 00 00 0F 0F 10
2D 04 00 00 //** then draw Action 1 sprite over it. Should look ok as long as the sprite covers the whole tile **
80
F3 03 00 00
00 00 00 0F 0F 10
2E 04 00 00
80
0B 03 // callbacks: custom sprite layout
13 01
// Action 01 : define a set of graphics
4 * 4 01 04 02 02
5 sprites\test1.pcx 175 25 01 35 64 -31 -4
6 sprites\test1.pcx 250 25 01 35 64 -31 -4
7 sprites\test1.pcx 25 25 09 47 64 -32 -16
8 sprites\test1.pcx 100 25 09 47 64 -32 -16
// Action 02 : define a Set
##9 * 7 02 04 00 00 01 00 00
##10 * 7 02 04 16 00 01 01 00
9 * 7 02 04 00 00 01 \w0
10 * 7 02 04 16 00 01 \w1
11 * 11 02 // action 2
04 // 04 for stations
15 // just some random ID for this action
80 // Use 80 to randomize the object (vehicle, station, building, industry) based on its own triggers and bits.
00 // not used? thus 00 - (when present) Location of controlling vehicle.
00 // should this be 10 ??
02 // nr of sets to pic from
00 00 // first pick from set 00
16 00 // second pick from set 16
// make available from 1950
12 * 14 02 04 0a 81 01 00 FF 01
00 80 00 1E // XX - 1920. So for 1950 = 00 80 00 1E
01 80 // allow
// callback : check var42 for the track type and return a sprite layout from Action 00 (layouts are zero-indexed)
13 * 23 02 04
01 // Set-ID A
85 // get word
42 // get var42 (track type)
00 \wxFF00 // do not add ; mask lower byte
02 // numRanges
02 80 \wx0200 \wx0200 // use layout 02 if monorail
04 80 \wx0300 \wx0300 // use layout 04 if maglev
00 80 // else use layout 00
//** callback handler for normal graphics (non-build menu)**
// switch between callback and graphics branches
14 * 17 02 04
02 // Set-ID B
85 0C 00 FF FF // get word, check if callback
01 // one range
01 00 14 00 14 00 // Set to use during callback 14
00 00 // else graphics Set
//** callback handler for build menu **
// switch between callback and graphics branches
15 * 23 02 04
03 // Set-ID 03
85 0C 00 FF FF // get word, check if callback
02 // one range
0A 00 13 00 13 00
06 80 14 00 14 00 // use layouts 06/07 during callback 14
00 00 // else graphics Set
16 * 10 03 04
01 // <n-id> : one ID
00 // STAT-ID // support station ID
01 // <num-cid> : support 1 cids
FF \wx03 // FF STAT-ID 00 // ID FF = build menu ; use ID 03
02 00 // <def-cid> : always use
17 * 22 04 04 FF 01 \wxC500 "ÅFence MID-Wall" 00 //** Use langID FF for all languages. Use C5xx for station names **
it only places the sprite as it should, but not the one from the second set.
my thought is that it somehow clashes with the other action 2 sprites behind it ?
attached the test nfo/pcx/grf
- zero.eight
- Traffic Manager
- Posts: 128
- Joined: 15 Jun 2007 01:14
Re: Can one NewGRF reference a base set?
Changes between //** and **.
Randomizer was not being referenced anywhere. Make sure you can work through the code and find a chain for each of the outcomes you want.
And a small change to the sprite offsets.
Randomizer was not being referenced anywhere. Make sure you can work through the code and find a chain for each of the outcomes you want.
And a small change to the sprite offsets.
- Attachments
-
- test1.nfo
- (8.12 KiB) Downloaded 111 times
OpenTTD: VAST - station tiles and objects | MICS - urban monorail graphical conversion | Universal Rail Type - easier train replacement
Re: Can one NewGRF reference a base set?
W00t w00t!
working
now i will try to understand how
and can get back to the drawing board to get those kick-ass sprites drawn 
working

now i will try to understand how


Re: Can one NewGRF reference a base set?
just 1 more quick thought, and i think it should not have big changes, but i cant find how...
how do i make the sprite change depending on cargo ? (with that same code from zero.eight 2 posts above this one)
how do i make the sprite change depending on cargo ? (with that same code from zero.eight 2 posts above this one)
- zero.eight
- Traffic Manager
- Posts: 128
- Joined: 15 Jun 2007 01:14
Re: Can one NewGRF reference a base set?
Two ways to do that. First one is by specifying cargo IDs in the station's Action 3 and linking them to Action 2s. That doesn't look particularly fun so I haven't tried it yet but I will at some point.
Another way is with a VarAction 2 using var60. Var60 takes a cargo type number as its parameter and returns the amount of cargo waiting for that cargo type. You can then create ranges to choose a graphics set if the value is within a particular range. I haven't tested the code and it won't work straight away. You will need to choose Action 2s to use for each of the ranges and put the sprite itself (I numbered it 16) into the graphics chain. You will probably want to put it before the Random Action 2 (15) and change all the references to 15 to 16. You might need to add more graphics as well
Another way is with a VarAction 2 using var60. Var60 takes a cargo type number as its parameter and returns the amount of cargo waiting for that cargo type. You can then create ranges to choose a graphics set if the value is within a particular range. I haven't tested the code and it won't work straight away. You will need to choose Action 2s to use for each of the ranges and put the sprite itself (I numbered it 16) into the graphics chain. You will probably want to put it before the Random Action 2 (15) and change all the references to 15 to 16. You might need to add more graphics as well

- Attachments
-
- test1.nfo
- (8.79 KiB) Downloaded 117 times
OpenTTD: VAST - station tiles and objects | MICS - urban monorail graphical conversion | Universal Rail Type - easier train replacement
-
- Tycoon
- Posts: 5954
- Joined: 27 Apr 2005 07:09
- Contact:
Re: Can one NewGRF reference a base set?
Another nice possibility is to make the action2s returning results for CB14 directly. In this way, you´ll get the increments of cargo amount automatically (via <numlittlesets> and <numlotssets>). This is the method NewStations uses for displaying passengers on platforms.zero.eight wrote:Two ways to do that. First one is by specifying cargo IDs in the station's Action 3 and linking them to Action 2s. [...] Another way is with a VarAction 2 using var60. Var60 takes a cargo type number as its parameter and returns the amount of cargo waiting for that cargo type. You can then create ranges to choose a graphics set if the value is within a particular range.Dante123 wrote: how do i make the sprite change depending on cargo ?
regards
Michael
Who is online
Users browsing this forum: Amazon [Bot] and 12 guests