I hope this isn't a silly question but I can't figure out how to use AITestMode.
I know I have to instante it to use AITestMode, but how do I destroy it to return back to normal mode?
AITestMode
Moderator: OpenTTD Developers
Re: AITestMode
The end of scope does.
/* Exec Mode */
{
local test = AITestMode();
/* Test Mode */
}
/* Exec Mode */
Easy as pie
/* Exec Mode */
{
local test = AITestMode();
/* Test Mode */
}
/* Exec Mode */
Easy as pie
The only thing necessary for the triumph of evil is for good men to do nothing.
-
- Engineer
- Posts: 72
- Joined: 09 Apr 2006 23:49
- Location: UK
- Contact:
Re: AITestMode
There is a good example of it in the WrightAI. Funnily enough, yeah, you only need braces - nothing actually defining that section apart from them - for it to operate.
There will be eventually some good examples on the wiki too.
There will be eventually some good examples on the wiki too.
Finaldeath
Re: [NoAI] AITestMode
So basically I have to let a local variable get destroyed as it scope ends?
What if I wish to switch between normal and test mode inside a function (lets ignore for the moment if that is good practice or not) would I just have to keep on instantiating AITestMode and AIExecMode instances or is there some equivalent to
local test = AITestMode;
... do some code ...
delete(test);
What if I wish to switch between normal and test mode inside a function (lets ignore for the moment if that is good practice or not) would I just have to keep on instantiating AITestMode and AIExecMode instances or is there some equivalent to
local test = AITestMode;
... do some code ...
delete(test);
Re: [NoAI] AITestMode
The latter works just as well. What you can also do, to make things more readable for yourself:
You can start a scope when ever you want
And if you want to make REALLY sure you get in ExecMode, add:
(a situation might arise where your function is called in TestMode )
Code: Select all
function a() {
{
local test = AITestMode();
/* Test */
}
{
/* Exec */
}
{
local test = AITestMode();
/* Test */
}
}
And if you want to make REALLY sure you get in ExecMode, add:
Code: Select all
local exec = AIExecMode();
The only thing necessary for the triumph of evil is for good men to do nothing.
Re: [NoAI] AITestMode
The equivalent for your example would be (if i'm not mistaken):
because as soon as you set your variable to something else and no variable references the AITestMode anymore, it also goes out of scope.
(please confirm)
Nevertheless, for readability, why not just use blocks like TrueLight suggested?
Code: Select all
local test = AITestMode();
// code
test = null;
(please confirm)
Nevertheless, for readability, why not just use blocks like TrueLight suggested?
Who is online
Users browsing this forum: Ahrefs [Bot] and 27 guests