Page 1 of 1

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

Posted: 02 Oct 2012 07:18
by Kogut
Is it possible?

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

Posted: 02 Oct 2012 14:01
by Yexo
You can include other files in info.nut just like you do in main.nut.

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

Posted: 02 Oct 2012 14:52
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.

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

Posted: 02 Oct 2012 16:54
by Kogut
Thanks!