Script Errors
by Alexander Loren · in Torque Game Engine · 07/15/2006 (1:28 am) · 3 replies
Please forgive me if this is a very simple fix and I am overlooking something; but I am not much of a programmer.
So basicly my problem is this, I have completed the little PDF tutorial that comes with the Torque Game Engine and now I am trying to expand on it by creating the TorqueLogoItem in a random spot based on SpawnSpheres (Later to add in a For loop to create them all randomly, but lets not have me getting ahead of myself). As a base for this I was looking through the server/game.cs file and then modded the player creation function to what I thought would work and suit my needs for the time being. But after I had them programmed in and tried to call the spawnLogoItems function through the console I get the errors as follows.
If someone with a bit of spare time on their hands, please look this over and explain to me what I may be doing wrong and offer some insight on how to fix it; I would be extreamly greatful. I am not looking for someone to fix it for me, but explain more so on how to fix it myself, as this needs to be a learning experiance for me and not just a handout that I learn nothing from. Thank you again and in advance for any thoughts given on this.
So basicly my problem is this, I have completed the little PDF tutorial that comes with the Torque Game Engine and now I am trying to expand on it by creating the TorqueLogoItem in a random spot based on SpawnSpheres (Later to add in a For loop to create them all randomly, but lets not have me getting ahead of myself). As a base for this I was looking through the server/game.cs file and then modded the player creation function to what I thought would work and suit my needs for the time being. But after I had them programmed in and tried to call the spawnLogoItems function through the console I get the errors as follows.
If someone with a bit of spare time on their hands, please look this over and explain to me what I may be doing wrong and offer some insight on how to fix it; I would be extreamly greatful. I am not looking for someone to fix it for me, but explain more so on how to fix it myself, as this needs to be a learning experiance for me and not just a handout that I learn nothing from. Thank you again and in advance for any thoughts given on this.
// My Errors: // ==>spawnLogoItems(); // game/server/logoitem.cs (54): Unable to instantiate non-conobject class TorqueLogoItem. // Set::add: Object "0" doesn't exist // game/server/logoitem.cs (60): Unable to find object: '0' attempting to call function 'setTransform'
// logoItem.cs
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
datablock StaticShapeData(TorqueLogoItem)
{
// Set item category within the world creator.
category = "Items";
// Then set our shape file so we have something to see.
shapeFile = "~/data/shapes/3dtorquelogo/torque_logo.dts";
};
function TorqueLogoItem::onCollision(%this,%obj,%col)
{
if(%col.getClassName() $= "Player")
{
// Let us set our client variable.
%client = %col.client;
// Increase their score, no need to cheat them out of a point.
%client.score++;
// Send them the update with their score.
commandToClient(%client,'SetScoreCount',%client.score);
// Delete the object they have found.
%obj.delete();
// Now check if there are any items left to be found.
%logoCount = LogoItems.getCount();
if(%logoCount > 0)
return;
// If not, they win, send a command to the client letting them know this.
commandToClient(%client,'ShowVictory',%client.score);
}
}
//-----------------------------------------------------------------------------
function spawnLogoItems(%this)
{
%spawnPoint = pickLogoSpawnPoint();
%this = createLogoItem(%spawnPoint);
}
function createLogoItem(%this, %spawnPoint)
{
// Lets create ourselves a new TorqueLogoItem.
%logoItem = new TorqueLogoItem() {
datablock = TorqueLogoItem;
client = %this;
};
// An' add it to our mission.
MissionCleanup.add(%logoItem);
// Now lets set it's position within our world.
%logoItem.setTransform(%spawnPoint);
}
function pickLogoSpawnPoint()
{
// Pick a random spawn point from the group.
%group = nameToID("MissionGroup/LogoSpawnPoints");
if (%group != -1 && %group.getCount() != 0)
// And return to us the spawn points position.
return %group.getObject(getRandom(%group.getCount())).getTransform();
// If no spawn points are found, we have a problem; but create one anyways.
error("Missing spawn point object and/or mission group " @ %groupName);
return "0 0 300 1 0 0 0";
}About the author
#2
Though, now when I am calling spawnLogoItems from the console, I no longer get any script errors and all continues running as intended. But at the same time, no logoItems are spawned anywhere. I hate to ask this, butmight I inconveniance someone once more to possibly point out why I am not having anything spawn? The console does not display any errors, or drops any hints as to why or where this problem is comming from.
Again, I must offer my thanks to anyone who assists me with this.
07/15/2006 (7:12 am)
Thank you muchly Stefan for pointing that out, just sorry that my problem here had to be something so simple. Though, now when I am calling spawnLogoItems from the console, I no longer get any script errors and all continues running as intended. But at the same time, no logoItems are spawned anywhere. I hate to ask this, butmight I inconveniance someone once more to possibly point out why I am not having anything spawn? The console does not display any errors, or drops any hints as to why or where this problem is comming from.
Again, I must offer my thanks to anyone who assists me with this.
#3
08/16/2006 (7:07 pm)
It's been abouts a month now, and I have yet to figure this little problem out. Is anyone able to possilby help out as to why after calling the function, that no logo items are spawned as they should be? Thanks to anyone that can offer any light to this subject.
Torque Owner Stefan Lundmark
TorqueLogoItem is not a class. In your datablock defination you set it as a staticShape, so you need to do that here as well.
Try that.