Page 1 of 1

GS -> NewGRF callback (patch)

Posted: 23 Jul 2015 07:27
by Zuu
Hello,

I would like help from someone who know how to make NewGRFs and work with the industry specs. This is needed to try out a patch. Please read background below if you are interested and the patch and a test GS is provided further down.

Background
Currently the line between NewGRF and GS is very clear and there is pretty much no way for GS to tell NewGRF about its desires on industry production, closure etc. It can only build industries and initiate closure, but cannot tell industries to not close, or to increase/decrease production.

There is also some interest in allowing GS to send messages to NewGRF. Perhaps many other not yet though of NewGRF + GS combo things can be created.

Work so far
I, frosch123 and andythenorth has discussed a bit on #openttd IRC channel about how this could be implemented. The relevant parts of the chat log is 2015-07-09 and 2015-07-10.

Proposed commands: https://paste.openttdcoop.org/p0a28hstd

Patch: http://devs.openttd.org/~zuu/newgrf_gs_prod_change/ *.patch
It currently only implements the command to work with specific industries. And not yet the tile animation CB. It is basically just a first patch that has been tested by GS but not yet NewGRF yet. (which is why I write here for help ;-) )

Test GS: IMessengerGS allow you to place signs ontop of industries with integer value to send to industry.

[edit]
Test NewGRF: http://devs.openttd.org/~zuu/newgrf_gs_prod_change/imessenger.grf will store received value in permanent store of coal mines. Which you can read out using the inspector of gui.newgrf_developer_tools.
[/edit]

What to test [edit: no longer needed]
I would like help from someone to make a NewGRF that act upon the bits sent in var 10 of production callback. If you can make it visually show perhaps using NewGRF developer tools in the game some state change, that would be useful. If that is not possible, you could also make it so that some values could be used to trigger very low/high production so it is clearly visible when testing that the response we see is not OpenTTD random production change. Remember, you're the NewGRF expert here so I trust you to be creative and come up with some way that the NewGRF can tell me that the callback was received and the bits in var 10 were received.

I think it would be useful if you can run the tests yourself, but also attach the NewGRF as a testing/verification tool for me.

Future plans
  • GS -> NewGRF is proposed to invoke also animation callback.
  • GS area method has been proposed
  • Later on if we think that GS -> NewGRF works well and may be useful in trunk, it will probably be a separate new callback for NewGRFs so they know when GS call them and when OpenTTD call them. However, as of now it is easiest to not have to modify the spec to try things out.
Note it is possible to propose lot of more things, however, I think it is better now to keep it simple than to extend it too large at this point.