Getting cargo name

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
krinn
Transport Coordinator
Transport Coordinator
Posts: 342
Joined: 29 Dec 2010 19:36

Getting cargo name

Post by krinn »

Hi guys,

I have 2 questions
How do i get the cargo name (not the cargo label), the real cargo name, it depend on localisation.
like IORE = iron ore
As the doc says, because GRF can change it, i will just use that for cosmetic purpose (yeah i won't die if i can't get it).



Another question, how do i dup something in squirrel without duplicate the instance, but its content ? So both get the same content, but not sharing their instance. Like if i do "a=z" and altering "z" won't change any "a" values ? i'm looking for something that might appears simple for anyone, but i can't put my hand on it.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Getting cargo name

Post by Zuu »

If you want to duplicate/clone/copy an AIList, create a new one and then use the member function AddList.

Code: Select all

local t = AITownList()
t.Valuate(AITown.GetPopulation);
t.KeepAbove(300);
local t2 = AIList();
t2.AddList(t);
Disclaimer: I haven't checked the API docs or if it compiles. So take a look there if my memory fails on some details. AddList might be AppendList for example.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
krinn
Transport Coordinator
Transport Coordinator
Posts: 342
Joined: 29 Dec 2010 19:36

Re: Getting cargo name

Post by krinn »

thank you, that's what i was looking for
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 5 guests