Trouble with script object creation and function calling
by Michael Bacon · in Torque Game Engine · 09/23/2007 (12:55 am) · 2 replies
Okay, so to me the following two snippets are identical but in practice they are not.
and...
AIManager.think() is the stock version.
Using the second script when AIManager.think() calls %this.schedule I get:
server/scripts/aiManager.cs (104): Unknown command schedule.
Object AIManager(1513) AIManager -> ScriptObject -> SimObject
I'm not even sure where to begin with this. Is it related to the known 'new object' bugs (cannot create new objects within a new block)? Or is it a scoping issue (since AIManager is being created within a static method of AIManager instead of inside the GameConnection)?
This even works:
It has to be a scoping issue right?
function GameConnection::onClientEnterGame(%this)
{
[b]...[/b]
// Start the AIManager
new ScriptObject(AIManager) {
totalAIPlayers = 0;
firstThought = true;
};
MissionCleanup.add(AIManager);
AIManager.think();
}and...
function GameConnection::onClientEnterGame(%this)
{
[b]...[/b]
// Start the AIManager
AIManager::create();
AIManager.think();
}
function AIManager::create()
{
new ScriptObject(AIManager) {
totalAIPlayers = 0;
firstThought = true;
};
MissionCleanup.add(AIManager);
}AIManager.think() is the stock version.
Using the second script when AIManager.think() calls %this.schedule I get:
server/scripts/aiManager.cs (104): Unknown command schedule.
Object AIManager(1513) AIManager -> ScriptObject -> SimObject
I'm not even sure where to begin with this. Is it related to the known 'new object' bugs (cannot create new objects within a new block)? Or is it a scoping issue (since AIManager is being created within a static method of AIManager instead of inside the GameConnection)?
This even works:
function GameConnection::onClientEnterGame(%this)
{
[b]...[/b]
// Start the AIManager
AIManager_create();
AIManager.think();
}
function AIManager_create()
{
new ScriptObject(AIManager) {
totalAIPlayers = 0;
firstThought = true;
};
MissionCleanup.add(AIManager);
}It has to be a scoping issue right?
#2
The object is happily created however when a subsequent call is made on the object the error occurs.
09/24/2007 (5:53 am)
That is not the part that dies though.The object is happily created however when a subsequent call is made on the object the error occurs.
Torque Owner Caleb
Default Studio Name
It's trying to call a function on an object that does not yet exist, were as:
Is a normal ol function with no ties to AIManager even though it has that name. It sees "_" as just another character in the function name. I don't think it would matter if it were:
or
In that case, you could just name it: "createManager()"