myList.valuate(AIStation.IsValidStation)

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
User avatar
Kev!
Engineer
Engineer
Posts: 37
Joined: 21 Jun 2011 16:30
Location: In Da House!
Contact:

myList.valuate(AIStation.IsValidStation)

Post by Kev! »

Howdy,

Is there a way to valuate my list of stations to leave only MY stations?

Please advise,
Kev!
I DO like a nice caboose...
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: myList.valuate(AIStation.IsValidStation)

Post by Zuu »

In fact your list of stations only includes your own stations. It is not even possible to (easily) obtain a list of opponent stations from the API.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
Kev!
Engineer
Engineer
Posts: 37
Joined: 21 Jun 2011 16:30
Location: In Da House!
Contact:

Re: myList.valuate(AIStation.IsValidStation)

Post by Kev! »

Hmm...

Perhaps I should define "my list of stations"?...Since I did not know how to get a list of my stations I did this...

I make a tilelist, add a rectangle around the town and valuate for IsRoadStationTile...this give me a list including other players stations? then I iterate and see if they are mine... using IsValidStaion...

I thought there must be an easier way, and so my question? Maybe I should ask how to get a list of my stations?
..other than keeping track of them as I build them?

Please advise,
Kev!
I DO like a nice caboose...
krinn
Transport Coordinator
Transport Coordinator
Posts: 342
Joined: 29 Dec 2010 19:36

Re: myList.valuate(AIStation.IsValidStation)

Post by krinn »

http://noai.openttd.org/docs/trunk/clas ... nList.html

and for your 2nd question:
from your stations list, valuate it by owner and keep only your own company as :

stationlist=yourlistoftiles
stationlist.Valuate(AITile.IsStationTile);
stationlist.KeepValue(1); // keep only tiles with a station on it
stationslist.Valuate(AITile.GetOwner)
local me=AICompany.ResolveCompanyID(AICompany.COMPANY_SELF);
stationslist.KeepValue(me); // keep only your own stations
Last edited by krinn on 09 Jul 2011 23:51, edited 1 time in total.
User avatar
Kev!
Engineer
Engineer
Posts: 37
Joined: 21 Jun 2011 16:30
Location: In Da House!
Contact:

Re: myList.valuate(AIStation.IsValidStation)

Post by Kev! »

WOW!

I guess AIStationList would do the trick? and valuate on IsWithinTownInfluence...yeah...that's the ticket!

Sorry for the fuss, nothing to see here...heh...I'll just stop typing now?


Thanks,

Kev!
I DO like a nice caboose...
krinn
Transport Coordinator
Transport Coordinator
Posts: 342
Joined: 29 Dec 2010 19:36

Re: myList.valuate(AIStation.IsValidStation)

Post by krinn »

look here, i've done it for depot tiles (similar to you, but with depot, and this is easier this time than browsing depot list)
http://dev.openttdcoop.org/projects/ai- ... uilder.nut
look at line 175
User avatar
Kev!
Engineer
Engineer
Posts: 37
Joined: 21 Jun 2011 16:30
Location: In Da House!
Contact:

Re: myList.valuate(AIStation.IsValidStation)

Post by Kev! »

Krinn!

You da man. :bow: Thank you so much! I could not figure out the depots...that was gonna be my next question!

You read my mind...

Now to buy a bus, give some orders and send it off! Very exciting!

Thanks again,
Kev!
I DO like a nice caboose...
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 10 guests