GetAPIVersion() in info.nut

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Post Reply
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

GetAPIVersion() in info.nut

Post by Yexo »

r17214 added GetAPIVersion() as (for now) optional function to info.nut. Currently there are two valid return values: "0.7" and "0.8". If your AI returns "0.7" a compatibility script will be loaded so the API resembles the 0.7 API as much as possible. If you return "0.8" all functions previously marked as deprecated are now unavailable. Returning "0.8" is currently inadvisable, since the 0.8 api may change before a release is made. For AIs that don't implement this function "0.7" will be assumed for now. In the future this default will be removed and AIs without this functions will then no longer load.
User avatar
fanioz
Transport Coordinator
Transport Coordinator
Posts: 320
Joined: 19 Dec 2008 05:03
Location: Indonesia
Contact:

Re: GetAPIVersion() in info.nut

Post by fanioz »

Is that mean, in the future, API 0.7 would still available (as long as possible) although 0.8 has been released?
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: GetAPIVersion() in info.nut

Post by Yexo »

fanioz wrote:Is that mean, in the future, API 0.7 would still available (as long as possible) although 0.8 has been released?
Yes :). The definition of "as long as possible" is still unclear, but it'll definitely be available in 0.8
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: GetAPIVersion() in info.nut

Post by Rubidium »

Yexo wrote:
fanioz wrote:Is that mean, in the future, API 0.7 would still available (as long as possible) although 0.8 has been released?
Yes :). The definition of "as long as possible" is still unclear, but it'll definitely be available in 0.8
Though in subsequent releases functions can become more expensive in the amount of "ops" they take; if an API wrapper is used it will use some of your N ops per tick.
Chruker
Engineer
Engineer
Posts: 49
Joined: 01 Jun 2009 20:13

Re: GetAPIVersion() in info.nut

Post by Chruker »

So the GetAPIVersion() is only optional for the 0.7x branch?
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: GetAPIVersion() in info.nut

Post by Yexo »

Chruker wrote:So the GetAPIVersion() is only optional for the 0.7x branch?
It'll still be optional in 0.8 (otherwise the 0.7 AIs couldn't be loaded :p) but after that it'll be mandatory. It's best to implement it now because 0.7 will just ignore it.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: GetAPIVersion() in info.nut

Post by Yexo »

Since this topic is still relatively new I'll reuse it to announce some two other changes:

FS#3101 is implemented in r17221. From now on you can give all variables to all string functions requiring a string. Most important use it probably to print integers with AILog::* functions.
FS#2980 is implemented in r17223. From now on if an AI executes a DoCommand / Sleep at an invalid time the AI is crashed. You can't catch this error in squirrel, but you will get a stack trace printed in the AI debug window.
User avatar
fanioz
Transport Coordinator
Transport Coordinator
Posts: 320
Joined: 19 Dec 2008 05:03
Location: Indonesia
Contact:

Re: GetAPIVersion() in info.nut

Post by fanioz »

Yexo wrote: ...
FS#2980 is implemented in r17223. From now on if an AI executes a DoCommand / Sleep at an invalid time the AI is crashed. You can't catch this error in squirrel, but you will get a stack trace printed in the AI debug window.
Thats great, would be helpfull for debugging :D
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 5 guests