How can I move AddSetting from info.nut to other file-solved

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
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

How can I move AddSetting from info.nut to other file-solved

Post by Kogut »

Is it possible?
Last edited by Kogut on 02 Oct 2012 16:54, edited 1 time in total.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: How can I move AddSetting from info.nut to other file?

Post by Yexo »

You can include other files in info.nut just like you do in main.nut.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: How can I move AddSetting from info.nut to other file?

Post by Zuu »

In several of my scripts I have a separate file called version.nut that is included by both [info/library].nut and main.nut. In this file I keep constants that need to be available in both places. Typically constants are the script version (hence the file name).

In the Beginner Tutorial I have a special .nut file that is written by a script that defines a constant which tells if the script should allow taking over from earlier versions of the same script or not. In the Bananas version this constant is always false, but in order to upgrade the scenario file that is uploaded to bananas I set this constant to true; load the scenario in scenario editor; save; and then turn off this constant. For this I have a script that automates this process to reduce the risk that I make a mistake.

So yea, you can include files and there define eg. a method that adds settings and then call this method from the right place in info.nut.


A bit of warning though. info.nut is read when OpenTTD scans for available AIs and GSs. Thus don't include more into info.nut than a bare minimum to do what you want to accomplish.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: How can I move AddSetting from info.nut to other file-so

Post by Kogut »

Thanks!
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 11 guests