Schedule syntax
by Chris Labombard · in Technical Issues · 04/03/2005 (5:46 pm) · 21 replies
Hey... I am trying to schedule a think function that I created in my aiController.cs file.
I get the error (in the console):
"Unable to find object: "attempting to call function 'schedule' "
My aiController is not a class, and hence isn't an object. Does it have to be an object to schedule one of it's functions, and does it have to be an object to hold global variables?
EDIT: This is the schedule call I am making:
%this.thinktrigger = %this.schedule($AI_CONTROLLER_THINK_TIME,0,"Think");
I also tried:
%this.thinktrigger = %this.schedule($AI_CONTROLLER_THINK_TIME,"Think");
I get the error (in the console):
"Unable to find object: "attempting to call function 'schedule' "
My aiController is not a class, and hence isn't an object. Does it have to be an object to schedule one of it's functions, and does it have to be an object to hold global variables?
EDIT: This is the schedule call I am making:
%this.thinktrigger = %this.schedule($AI_CONTROLLER_THINK_TIME,0,"Think");
I also tried:
%this.thinktrigger = %this.schedule($AI_CONTROLLER_THINK_TIME,"Think");
About the author
I have been a professional game programmer for over 5 years now. I've worked on virtually every platform, dozens of games and released a few of my own games, including 2 iPhone titles and a title waiting release on Big Fish Games.
#2
Can I use this:
schedule(0,duration,"function"); // There are no parameters
Thank you for your help.
04/04/2005 (7:36 am)
What if there is no dependant object? Can I use this:
schedule(0,duration,"function"); // There are no parameters
Thank you for your help.
#3
schedule(duration, object, function, params...);
Just put 0 if you don't have an object.
The other form of schedule is as an object method:
%object.schedule(duration, function, params...);
04/04/2005 (7:56 am)
Actually Stepehen I think you have it backwards.schedule(duration, object, function, params...);
Just put 0 if you don't have an object.
The other form of schedule is as an object method:
%object.schedule(duration, function, params...);
#4
04/04/2005 (8:15 am)
Thanks guys
#5
in the wrong place--it's always first.
And yes, you can put a 0 object id in the first form if you don't want the scheduled function to depend on any object still existing at the time of the function execution.
04/04/2005 (8:16 am)
@John: Thanks, I actually just had the And yes, you can put a 0 object id in the first form if you don't want the scheduled function to depend on any object still existing at the time of the function execution.
#6
Yeah thats what I meant sorry. you had duration and object reversed :p
04/04/2005 (8:25 am)
Quote:@John: Thanks, I actually just had thein the wrong place--it's always first.
Yeah thats what I meant sorry. you had duration and object reversed :p
#7
function AIController::Think()
{
// Think
schedule($AI_CONTROLLER_THINK_TIME,0,"AIController::Think");
// OR
schedule($AI_CONTROLLER_THINK_TIME,0,"Think");
}
this is what I am using... and both of them give
Think: Unknown command.
AIController::Think: Unknown command.
04/04/2005 (12:54 pm)
Ok... function AIController::Think()
{
// Think
schedule($AI_CONTROLLER_THINK_TIME,0,"AIController::Think");
// OR
schedule($AI_CONTROLLER_THINK_TIME,0,"Think");
}
this is what I am using... and both of them give
Think: Unknown command.
AIController::Think: Unknown command.
#8
04/04/2005 (12:55 pm)
function AIController::Think(%this)
{
%this.schedule($AI_CONTROLLER_THINK_TIME, "Think");
}
#9
change function AIController::Think() to:
function AIController::Think(%this)
and
%this.schedule($AI_CONTROLLER_THINK_TIME, "Think");
Bleh, John beat me to it!
You mentioned however that your "AIController" isn't an object...so I'm curious how you plan on having it work. It's in an object-style namespace, so it needs an object to call it.
Are you planning on having one dispatcher "global" function that parses each and every object that has to "think"? That's a bit counter-productive--a large monolithic polling loop is going to make things pretty cpu intensive for what is already a pretty intensive tasking (AI in general). Normally better to implement it as an object class specific method that is called back via the schedule.
04/04/2005 (1:00 pm)
Since this -is- inside a namespace function, try this:change function AIController::Think() to:
function AIController::Think(%this)
and
%this.schedule($AI_CONTROLLER_THINK_TIME, "Think");
Bleh, John beat me to it!
You mentioned however that your "AIController" isn't an object...so I'm curious how you plan on having it work. It's in an object-style namespace, so it needs an object to call it.
Are you planning on having one dispatcher "global" function that parses each and every object that has to "think"? That's a bit counter-productive--a large monolithic polling loop is going to make things pretty cpu intensive for what is already a pretty intensive tasking (AI in general). Normally better to implement it as an object class specific method that is called back via the schedule.
#10
04/04/2005 (1:03 pm)
I get unable to find Object errors... cause my aiController isn't an object.
#11
04/04/2005 (1:05 pm)
So then I need to make it an object? Does it need to be an object inorder for me to store global variables, like $AI_CONTROLLER_THINK_TIME?
#12
04/04/2005 (1:07 pm)
I need about 200 bots... so it was suggested to me that I don't use scheduling. Hence why I am using an aiController. All it does is seperate the bots into groups then call think on a group... then schedules itself again. Then I don't run into scheduling conflicts and everything thinks in its due time
#13
function AIControllerThink()
and the schedule to
schedule($AI_CONTROLLER_THINK_TIME, AIControllerThink);
Note: my comments/critique above still stand...this is probably not a very efficient way to do AI in script...so your milage may vary!
04/04/2005 (1:08 pm)
Then you shouldn't give it an object namespace...change your function to:function AIControllerThink()
and the schedule to
schedule($AI_CONTROLLER_THINK_TIME, AIControllerThink);
Note: my comments/critique above still stand...this is probably not a very efficient way to do AI in script...so your milage may vary!
#14
04/04/2005 (1:09 pm)
I don't know if it is going to crawl until I can get it to start schedulign itself. I tried makign an AIController class in the source but I got tonnes of Console errors when I compiled.
#15
04/04/2005 (1:10 pm)
Do you have a better suggestion on how to do it? This seems like the only way to me... Everything still has to think. This way less things think at a time.
#16
And you can still do it object based, just make your objects the groups you are talking about instead of each of the bots.
TAP applications (T2D, TGE, TSE, etc) already have a lot of processing loops in place, and in general you shouldn't ever have to mimic that type of functionality. schedule is designed to tap in to the simulation time advancement system in a streamlined way, and unless you are talking about having a $AI_CONTROLLER_THINK_TIME of <100 milliseconds or so, you aren't going to be causing much of a performance headache. In any case, I assume you are using this to handle bot gameplay decisions..and those would probably be on the order of magnitude of a second or so between think() events...and that's nothing at all in the big scheme of things.
04/04/2005 (1:12 pm)
200 schedules isn't an issue at all. Schedule is a -very- lightweight functionality, and in fact you are going to be adding a ton more overhead with your own monolithic ai handler implemented in script.And you can still do it object based, just make your objects the groups you are talking about instead of each of the bots.
TAP applications (T2D, TGE, TSE, etc) already have a lot of processing loops in place, and in general you shouldn't ever have to mimic that type of functionality. schedule is designed to tap in to the simulation time advancement system in a streamlined way, and unless you are talking about having a $AI_CONTROLLER_THINK_TIME of <100 milliseconds or so, you aren't going to be causing much of a performance headache. In any case, I assume you are using this to handle bot gameplay decisions..and those would probably be on the order of magnitude of a second or so between think() events...and that's nothing at all in the big scheme of things.
#17
04/04/2005 (1:15 pm)
Do you have a better suggestion on how to do it? This seems like the only way to me... Everything still has to think. This way less things think at a time.
#18
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6773
Also this got it thinking properly:
function AIControllerThink()
{
schedule($AI_CONTROLLER_THINK_TIME,0,"AIControllerThink");
}
04/04/2005 (1:18 pm)
OK... Well does it make a difference that I am not using the AIManager? I am working from Mark's AIGuard resource:http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6773
Also this got it thinking properly:
function AIControllerThink()
{
schedule($AI_CONTROLLER_THINK_TIME,0,"AIControllerThink");
}
#19
04/04/2005 (1:22 pm)
Another reason I am using the aiController is because I want to group my bots to form a larger bot controlled by centralized ai...
#20
Different techniques is all, but it does appear that the root reason you went with a monolithic manager was the concern about 200 schedules--and that probably won't be a big issue for you.
04/04/2005 (1:29 pm)
There are different implementations of group (flock, herd, etc.) based AI, and it's a relatively complex topic. Where you are going with this looks as if it will work, don't get me wrong, but nothing says that you cannot make your "objects" contain a SimSet of the bots they directly control, and then schedule the think() on those objects.Different techniques is all, but it does appear that the root reason you went with a monolithic manager was the concern about 200 schedules--and that probably won't be a big issue for you.
Torque 3D Owner Stephen Zepp
When you call schedule as a global function it allows you the option of providing an object ID that it is "dependent" on, and you do this with the syntax:
schedule(
or, if you use the object form of the function:
%objectID.schedule(
You are mixing the two here.
If "%this" isn't the actual object you are scheduling the object on, but you did it because that's how it's done elsewhere, use the first form (no %this.schedule).
EDIT: Moved