Page 1 of 1
Industries - cargo sub-type display callback
Posted: 03 Dec 2008 16:43
by andythenorth
I want to set the cargo sub-type display for an industry, so I have set prop 21 to 40.
Code: Select all
2 * 19 04 0A 9F 01 00 DC "Catfood Mine" 00
3 * 28 00 0A 09 01 00 // action 0 for industry
08 00
09 00
10 01 09 // cargo types accepted
17 02
18 02
19 D0
1A 00 00 00 00
1F 00 DC // text string to use for name
21 40 // callback flags
I assume I now need:
- another action 4 to set the ID and contents of text string for the cargo-sub type
- an action 3 and variational action 2 chain referencing the ID of the text string
However I am being very dense and can't figure out the logic of the variational action 2 (or how to terminate it). I am modifying the default coal mine as a learning exercise, I haven't defined any layouts or real sprites for this industry.
Apologies if I am being extra-dim about this, can't seem to shake off jet lag

Re: Industries - cargo sub-type display callback
Posted: 03 Dec 2008 16:58
by michael blunck
Well, it´s straoghtforward:
Code: Select all
//------------------------------------------------------------------
// D001 cargo sub-texts
//------------------------------------------------------------------
-1 * 19 04 00 83 01 01 D0 " (furniture)" 00
-1 * 15 04 00 84 01 01 D0 " (Möbel)" 00
-1 * 17 04 00 88 01 01 D0 " (meubles) 00
-1 * 17 04 00 90 01 01 D0 " (muebles)" 00
[...]
// extra callback info2:
// return subtext for first produced cargo type
-1 * 14 02 0A 0C 81 18 00 FF 01
01 80 03 03 // D001
FF 80
// CBs
-1 * 14 02 0A 0D 81 0C 00 FF 01
0C 00 37 37 // cargo sub-text
0B 00 // industry
// attach industry callbacks to industry
-1 * 7 03 0A 01 07 00 0D 00
HTH
regards
Michael
Re: Industries - cargo sub-type display callback
Posted: 03 Dec 2008 17:14
by andythenorth
michael blunck wrote:Well, it´s straoghtforward:
Brilliant, thankyou.

- catfood (canned).png (39.23 KiB) Viewed 1349 times
One question - I don't have an action 2 to apply graphics, so I have terminated on FF 80, which appears to work. Is that a very stupid thing to do? (It's something I
think remember reading somewhere - I am now avidly reading action 2 documentation to see if I've misremembered it).
EDIT, can't find any documentation on this FF 80 business, I think I've imagined it; as far I can see my code should cause a crash?
What's the correct way to terminate this chain? I don't have any graphics to apply, and I don't need to setup the production callback for this industry.
Code: Select all
// extra callback info2:
// return subtext for first produced cargo type
5 * 14 02 0A 0C
81 18 00 FF 01
01 FF 03 03 // D001
FF FF
// CBs
6 * 14 02 0A 0D
81 0C 00 FF 01
0C 00 37 37 // cargo sub-text
FF 80 // terminate chain
// attach industry callbacks to industry
7 * 7 03 0A 01 00
00 0D 00
Re: Industries - cargo sub-type display callback
Posted: 03 Dec 2008 17:36
by frosch
Industries do not have graphics. Images are assigned to industry tiles.
Industries' action2 is the production callback. Just define one, it won't be used until it is activated by action0.
For other features, which have graphics, you can define a action1 with zero sprites.
Description of Action1 wrote:Since 2.0.1 alpha 63, it is possible to have <num-ent>=0. This is useful for defining an action 1/2 combination that only serves as invalid callback result. If the .grf file defines no graphics otherwise, this way callbacks can return an explicit failure code without needing any actual sprites to be allocated.
Re: Industries - cargo sub-type display callback
Posted: 03 Dec 2008 17:58
by andythenorth
frosch wrote:Industries do not have graphics. Images are assigned to industry tiles.
Industries' action2 is the production callback. Just define one, it won't be used until it is activated by action0.
Thanks Frosch. As the production callback is unused, I've zeroed everything, is this a sensible approach?
6 * 15 02 0A 0A // action 2 setup production callback
00
00 00
00 00
00 00
00 00
00 00
00
Re: Industries - cargo sub-type display callback
Posted: 03 Dec 2008 18:47
by michael blunck
andythenorth wrote:frosch wrote:[...]
Industries' action2 is the production callback. Just define one, it won't be used until it is activated by action0.
Thanks Frosch. As the production callback is unused, I've zeroed everything, is this a sensible approach?
Yes, looks good. In my example above, the 0B branch has been indeed linked with a production CB. Sorry, I missed to post it.
regards
Michael
Re: Industries - cargo sub-type display callback
Posted: 03 Dec 2008 19:06
by andythenorth
Thanks Michael and Frosch, very helpful.
I am now adding a callback 3A to provide extra text in the industry window. This is sprite 8 / Action 2 ID 0B in the code below, and should return the text string at D002. There are no conditions that I want to check, so I am unsure of how to set this up. Needless to say, the code below doesn't produce the desired result (although it doesn't crash either).
Code: Select all
4 * 16 04 00 9F 01 01 D0 " (canned)" 00
5 * 19 04 00 9F 01 02 D0 "\90 Mmmm, cats love it" 00
6 * 15 02 0A 0A // action 2 setup production callback
00
00 00
00 00
00 00
00 00
00 00
00
// extra callback info2:
// return subtext for first produced cargo type
7 * 14 02 0A 0C
81 18 00 FF 01
01 FF 03 03 // D001
FF FF
//
8 * 14 02 0A 0B
81 0C 00 FF 01 // why am I checking 0C? Because I don't want to check anything here and can't figure out how.
02 FF 3A 3A // D002
FF FF
// CBs
9 * 18 02 0A 0D
81 0C 00 FF 02
0C 00 37 37 // cargo sub-text
0B 00 3A 3A // industry window text
0A 00 // default
// attach industry callbacks to industry
10 * 7 03 0A 01 00
00 0D 00
Re: Industries - cargo sub-type display callback
Posted: 03 Dec 2008 19:37
by frosch
If I understand you correctly, remove sprite 8 and replace
by
Edit: however I cannot see, why your code should not work. Did you enable the callback? Or what it the effect in game?
Re: Industries - cargo sub-type display callback
Posted: 03 Dec 2008 19:50
by andythenorth
frosch wrote:Did you enable the callback?
No I did not, and there you have found the source of my problem.

Now corrected:

- catfood_success.png (41.34 KiB) Viewed 1280 times
Thanks!