Page 5 of 16

Re: Some API extension ideas

Posted: 23 Aug 2009 20:46
by Blustuff
I didn't find functions to get/set name of stations. I wanted to get the generated station name to make vehicle group name. So this is another extension idea.

Re: Some API extension ideas

Posted: 23 Aug 2009 21:36
by 1009
Blustuff wrote:I didn't find functions to get/set name of stations. I wanted to get the generated station name to make vehicle group name. So this is another extension idea.
Look into Denver & Rio Grande source code. It renames it's stations. So does TransAI.

Re: Some API extension ideas

Posted: 23 Aug 2009 21:59
by Yexo
Blustuff wrote:I didn't find functions to get/set name of stations. I wanted to get the generated station name to make vehicle group name. So this is another extension idea.
AIBaseStation is a superclass of AIStation. As such, all AIBaseStation functions (GetName/SetName/etc.) also work for AIStation.

The above information only holds for trunk. In 0.7 there is no AIBaseStation and GetName/SetName are functions of AIStation.

Re: Some API extension ideas

Posted: 29 Aug 2009 10:14
by svetovoi
Why the API does not have function like AIVehicle::SetServiceInterval(vehicle_id, days)?
It was never requested before, or there is another reason?
Hope name is clear and explain function's purpose.

Re: Some API extension ideas

Posted: 29 Aug 2009 16:01
by Yexo
ac84 wrote:Why the API does not have function like AIVehicle::SetServiceInterval(vehicle_id, days)?
It was never requested before, or there is another reason?
Hope name is clear and explain function's purpose.
It has been suggested before: http://bugs.openttd.org/task/2853

The reason that it's not included yet is that the trunk code is buggy and that needs to be solved first. I've gathered ideas on how to fix it but never got around to implementing a fix.

Re: Some API extension ideas

Posted: 07 Sep 2009 11:43
by Chruker
Could use a function like AIStationList_Vehicle but for depots, so that I can see if any vehicles have specific a depot as part of their orders.

It'll be fine if it also includes vehicles that are currently heading towards the depot (either ordered of because or service interval).

Not Very Important but I need it

Posted: 07 Sep 2009 16:08
by Kogut
I need function (probably it should be in AICompany) that change company colour (blue or yellow is better than pink :D ).

Re: Some API extension ideas

Posted: 07 Sep 2009 16:15
by Lord Aro
yeah but what about multiple instances running?

Re: Some API extension ideas

Posted: 07 Sep 2009 16:18
by Brumi
Lord Aro wrote:yeah but what about multiple instances running?
The function would simply return false then. It's similar to company names.

Re: Not Very Important but I need it

Posted: 08 Sep 2009 20:31
by Dustin
Kogut wrote:I need function (probably it should be in AICompany) that change company colour (blue or yellow is better than pink :D ).
I think this would be nice. Yellow contrasts very nicely with the generally green color of the game. So it's nice for screenshots. It would be nice to be able to set the color and president details and even have a code for keeping the same face.

Re: Not Very Important but I need it

Posted: 09 Sep 2009 00:18
by Michiel
Dustin wrote:I think this would be nice. Yellow contrasts very nicely with the generally green color of the game. So it's nice for screenshots.
I agree, but I "solve" it by hitting reload until the desired colour comes up :)

Re: Some API extension ideas

Posted: 09 Sep 2009 07:44
by svetovoi
Dustin wrote:It would be nice to be able to set the color and president details and even have a code for keeping the same face
And the top of it - portraits/logo import, but, seems, it will be hardly possible.

Re: Some API extension ideas

Posted: 09 Sep 2009 16:46
by Roujin
Okay, maybe it has already been discussed (and rejected? I hope not :/), but I'd really like to have some trigonometric functions.
Sin, cos, tan and their inverses...

Or is there already a library with that?
I can probably live with a rather crude table (say 5° steps) look up... :roll:


If you're wondering what I need that for, my wip AI aims to create nice-looking networks, and I found that I need those functions for the decision where in a town to place the station, so it looks naturally in the end.

(here's a screen of a map where I ran some functions to find a possible network, along with comments to myself on how to go on designing my AI :lol: )
WolfAI teaser.png
(287.96 KiB) Downloaded 43 times
EDIT: could it be that those are already included in squirrel? I feel kinda dumb... :(

Re: Some API extension ideas

Posted: 09 Sep 2009 17:49
by Chruker
Roujin wrote:EDIT: could it be that those are already included in squirrel? I feel kinda dumb... :(
Nope they are not included. It doesnt even have a function for getting square roots. However in regards to the square root function other AIs have their own, so I guess you could search the net for some fancy replacement functions.

Please let us know what if you find anything.

Re: Some API extension ideas

Posted: 09 Sep 2009 17:52
by Rubidium
Roujin wrote:Okay, maybe it has already been discussed (and rejected? I hope not :/), but I'd really like to have some trigonometric functions.
Sin, cos, tan and their inverses...
A simple search would have found topics discussing the exact same idea.

Re: Some API extension ideas

Posted: 09 Sep 2009 18:06
by Roujin
Alright, I'm officially too stupid to search.
Sorry for wasting your time on irc, TrueBrain.
Thanks for your help Chruker and Rubidium.

I somehow don't feel motivated to continue on my AI right now though.
Getting banned like that from the irc channel hurt me.
Maybe I'm just too sensitive for this community. :(

Re: Some API extension ideas

Posted: 09 Sep 2009 22:01
by Chruker
Roujin wrote:I somehow don't feel motivated to continue on my AI right now though.
Getting banned like that from the irc channel hurt me.
Maybe I'm just too sensitive for this community. :(
Join #openttd.noai - the channel where TB doesnt roam :-)

Re: Some API extension ideas

Posted: 09 Sep 2009 22:49
by Roujin
Ok guys, I think the matter is more or less settled now.

The problem was probably me assuming that TrueBrain knew the answer to my question, and was just being unhelpful. That was obviously wrong. I was wrong. Sorry.

Re: Some API extension ideas

Posted: 10 Sep 2009 13:23
by Blustuff
Roujin wrote:The problem was probably me assuming that TrueBrain knew the answer to my question, and was just being unhelpful. That was obviously wrong. I was wrong. Sorry.
I hardly believe he doesn't know. However, I still don't understand why there is no mathematical function. It isn't a matter of speed and I think Yexo told us "your AI don't need such functions". Actually they do.

Re: Some API extension ideas

Posted: 10 Sep 2009 13:30
by Yexo
There already is an implementation in squirrel you can use: http://www.tt-forums.net/viewtopic.php?p=777696#p777696
Blustuff wrote:It isn't a matter of speed and I think Yexo told us "your AI don't need such functions". Actually they do.
I did say that and was wrong. That doesn't mean I'll include those functions in the API. A main reason against including those in the API still is that they are floating point calculations, which OpenTTD tries to avoid as much as possible (because the results are not guaranteed to be the same on each platform). The existing squirrel support for floating point numbers can't be removed because it's used by too many AIs, but that doesn't mean we should add more floating point functions.