AIRail::BuildNewGRFRailStation
Moderator: OpenTTD Developers
Re: Sleep problem
Because Sleep is not a global function, it's a static function of AIController. Just call AIController.Sleep() and it'll work.
Re: Sleep problem
A bit OT, but I thought it would help you: Ever since r19166, only the relative path to the error is shown, eg \ai\... If you use a version r19166 or newer, you won't have to edit out those personal lines.Kogut wrote:So why:
Re: Sleep problem
Correct new statementpetert wrote:A bit OT, but I thought it would help you: Ever since r19166, only the relative path to the error is shown, eg \ai\... If you use a version r19166 or newer, you won't have to edit out those personal lines.Kogut wrote:So why:
Edit: I was wrong, in newer versions of OpenTTD* the full path is truncated also for AIs in plain directories - not just those in tars.
* Probably the same as PeterT posted above.
So forget everything I said in this post, and follow PeterT's advice.
Wrong old statement:
That is only true for AIs that remain inside tars. For AIs that are in plain directories the paths are not truncated.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Re: Sleep problem
Thanks for help!
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
AIAI - AI for OpenTTD
Re: Sleep problem [solved]
How to get current order? //post recreated
--- mess --- //post edited when another user replied
--- mess --- //post edited when another user replied
Last edited by Kogut on 08 Mar 2010 14:17, edited 3 times in total.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
AIAI - AI for OpenTTD
Re: ORDER_CURRENT problem
You mean the current order index? That's quite tricky because the "GetOrder(current order index)" != "current order". For example when loading/unloading the order isn't OT_GOTO_STATION <station where it is> but rather OT_LOADING.
Re: ORDER_CURRENT problem
I found how to do it (there was language problem) by AIOrder.ResolveOrderPosition(veh, AIOrder.CURRENT_ORDER).
Now I have next problem - how to force vehicle to skip to next (order) position?
====
What I need: I want to skip current order and force vehicle to execute next.
I need - SkipOrderFunction(vehicle)
Or SkipToOrderPosition(vehicle) and GetCurrentOrder(vehicle) <- I found it
Is it possible to do it?
====
edit: yes
SkipToOrder (VehicleID vehicle_id, OrderPosition next_order)
Now I have next problem - how to force vehicle to skip to next (order) position?
====
What I need: I want to skip current order and force vehicle to execute next.
I need - SkipOrderFunction(vehicle)
Or SkipToOrderPosition(vehicle) and GetCurrentOrder(vehicle) <- I found it
Is it possible to do it?
====
edit: yes
SkipToOrder (VehicleID vehicle_id, OrderPosition next_order)
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
AIAI - AI for OpenTTD
Re: Is it possible to switch off dump log after exception?
Is it possible to switch off dump log after exception?
- Attachments
-
- Przechwytywanie.PNG (11.99 KiB) Viewed 3370 times
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
AIAI - AI for OpenTTD
Re: Is it possible to switch off dump log after exception?
No. I think this issue has been raised before and back then there was no easy solution to this.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Re: Is it possible to switch off dump log after exception?
I try to incorporate choochoo into AIAI (after buxfixes, with ability to terraform for stations and support for newgrf). Unfortunatelly that red "Your script made an error" turn log into completely mess. And it is impossible to get rid of it without removing all exceptions (= recoding choochoo), right?
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
AIAI - AI for OpenTTD
Re: Is it possible to switch off dump log after exception?
Or rewriting the Squirrel VM. So, yeah, I'm going with "yes" 

Re: Is it possible to switch off dump log after exception?
So it is better to write new ai and reuse some ideas (reusing code seems impossible
).

Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
AIAI - AI for OpenTTD
Re: Is it possible to switch off dump log after exception?
Is it possible to change that code to allow execution Win() from Fail() function? [without removing ability to show points]
Is it possible to have reference to parent?
Code: Select all
class Example
{
function Fail()
{
AILog.Info("FAIL!");
MyNewAI.Win();
}
}
class MyNewAI extends AIController
{
points = null;
function Start()
{
points = AIBase.Rand();
local a = Example();
a.Fail();
}
function Win()
{
AILog.Info("WIN!" + points);
}
}
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
AIAI - AI for OpenTTD
Re: Is it possible to switch off dump log after exception?
There is no "parent". If you want to have a reference to a specific instande of MyNewAI you have to give it to the Fail() function. This should work:Kogut wrote:Is it possible to change that code to allow execution Win() from Fail() function? [without removing ability to show points]
...
Is it possible to have reference to parent?
Code: Select all
class Example
{
function Fail(ai_instance)
{
AILog.Info("FAIL!");
ai_instance.Win();
}
}
class MyNewAI extends AIController
{
points = null;
function Start()
{
points = AIBase.Rand();
local a = Example();
a.Fail(this);
}
function Win()
{
AILog.Info("WIN!" + points);
}
}
Re: Code structure problem
thanks, another version:
Code: Select all
class Example
{
rodzic = null; //rodzic (polish) = parent (english, but parent is restricted)
par = 0;
function Fail()
{
AILog.Info("FAIL!");
if(par>10)rodzic.Win();
}
}
class MyNewAI extends AIController
{
points = null;
function Start()
{
points = AIBase.Rand();
local a = Example();
a.rodzic = this;
while(true)
{
a.Fail();
points++;
a.par++;
AILog.Info("game: " + points);
}
}
function Win()
{
AILog.Info("WIN!" + points);
}
}
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
AIAI - AI for OpenTTD
Re: Solved
Could you name back the thread title to something descriptive (you can add "(solved)" at the end)? This way someone else who might have the same problem in future may find the thread easier than like it is now.
Re: lumber mill - how to recognize?
I just discovered that tropical lumber mill needs trees to work.
lumber mill - how to recognize?
- now ai completely ignore that need, but I prefer to change it (it is, unfortunatelly, default industry)
Main problem is - is it possible to get information that certain industry type need trees to work (probably no and function IsItIndustryConsumingTreesAround() will be never added to noai api)
So, another way is hardcoding it. Unfortunatelly simple hardcoding industry id will end with planting trees around ECS coal mine. So: how to recognise standard tropical lumber mill and compare it with, for example - FIRS lumber mill?
lumber mill - how to recognize?
- now ai completely ignore that need, but I prefer to change it (it is, unfortunatelly, default industry)
Main problem is - is it possible to get information that certain industry type need trees to work (probably no and function IsItIndustryConsumingTreesAround() will be never added to noai api)
So, another way is hardcoding it. Unfortunatelly simple hardcoding industry id will end with planting trees around ECS coal mine. So: how to recognise standard tropical lumber mill and compare it with, for example - FIRS lumber mill?
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
AIAI - AI for OpenTTD
Re: lumber mill - how to recognize?
Unless you haven't already had this discussion on IRC I would suggest that you make a API suggestion for functions that you think are missing in the API expansion ideas thread. A feature request at bugs.openttd.org would probably also work. That way it will be remembered and introduced when someone has time to implement it.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Re: lumber mill - how to recognize?
I want to modify library road pathfinder to get route without bridges to start or end of route. How to do it?
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
AIAI - AI for OpenTTD
Re: Pathfinder question
I think you have to override the neighbour function and simply make it not generate bridge neighbours if the other end of the bridge is the target tile. And don't consider bridge neighbours at all from start tiles.
You can see CluelessPlus for how it implements its own neighbour function where it checks for rails to build bridge over.
You can see CluelessPlus for how it implements its own neighbour function where it checks for rails to build bridge over.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Who is online
Users browsing this forum: No registered users and 9 guests