How to add a label for a negative number in the AI-Options?

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
Steffl
Engineer
Engineer
Posts: 103
Joined: 23 Feb 2010 15:44

How to add a label for a negative number in the AI-Options?

Post by Steffl »

Hi,
I have a problem. This code doesn't work:

Code: Select all

AddSetting({name = "maintain", description = "Maintain existing shuttle services every ... days", min_value = -1, max_value = 9999,easy_value = -1, medium_value = -1, hard_value = -1, custom_value = -1, flags = 0|AICONFIG_INGAME});

		AddLabels("maintain", {_-1="decide automatic",_0="never"});

I don't know how to add a Label to a negative number. I tried with adding spaces but I wasn't successful.

If I remove " _-1="decide automatic" " it works, but it would be very nice if I could avoid one additional option for the automatic maintainance interval.
I plan a new AI-Project and I already see, that I will need to use a lot of options to interact with it. So place in preference menu is very valuble. :-)

Maybe someone had tried this too and can help me.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: How to add a label for a negative number in the AI-Optio

Post by Yexo »

You could try if this works:

Code: Select all

AddLabels("maintain", {"_-1"="decide automatic",_0="never"});
Steffl
Engineer
Engineer
Posts: 103
Joined: 23 Feb 2010 15:44

Re: How to add a label for a negative number in the AI-Optio

Post by Steffl »

No, this doesn't work, too. But thanks.
Maybe it's currently not possible. and would need changes in Openttd itself.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: How to add a label for a negative number in the AI-Optio

Post by Zuu »

You can use rawset which takes key as first argument and value as second argument:

Code: Select all

local labels_table = {_0="never"};
labels_table.rawset("_-1", "decide automatic");
AddLabels("maintain", labels_table);
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Steffl
Engineer
Engineer
Posts: 103
Joined: 23 Feb 2010 15:44

Re: How to add a label for a negative number in the AI-Optio

Post by Steffl »

Cool, this works. Good trick.
Thanks Zuu.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 13 guests