AI Question: get event 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

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: AI Problem: Something - I'm not sure what...

Post by Zuu »

okay. I was unsure what exactly you meant by "not the problem lower down". It could mean not the problem at the lower part. Or if you were lazy and omitted a comma, what you wanted to say could have been "not the problem, lower down", which refers to the text lower down in the post.

As for the question itself, I can't tell without taking a look at your code, something I'm not really motivated to do (finding it, download, untar, open the source in an editor, figure out the structure and then find out what you did before that was not working and compare that with your current solution).
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2369
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: AI Question: get event name

Post by Lord Aro »

bump!

question:

is there an easy way of getting the event name (print to debug)

i can do it like...

Code: Select all

case 1: EVENT_###
case 2:EVENT_2###
....
but that seems a little excessive

is there another way?
or is this a feature request? :lol:
AroAI - A really feeble attempt at an AI

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
Brumi
President
President
Posts: 921
Joined: 18 Jul 2009 17:54

Re: AI Question: get event name

Post by Brumi »

I think this is indeed a feature request... :D

I haven't tried it myself, but I think you could do it by creating an array of strinds containing the names, while the event type constants are the indexes. It may require quite a bit of work to create the string array, but then printing it would be easy:

Code: Select all

AILog.Info(eventname[event.GetEventType()]);
// or maybe
AILog.Info(GetEventName(event.GetEventType())); // a bit nicer, but needs an extra function
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 8 guests