Have triggers been changed? Can't get t3D to recognise trigger
by Mike Rowley · in Torque 3D Professional · 06/18/2011 (6:34 pm) · 2 replies
I have a check point trigger in t3d.
In "scripts/server/race/" I have checkpoint.cs.
It is inited in scriptExec.cs in "scripts/server/" like this:
I originally had it at the bottom of the page, but moved it to see if it would work here. I'm getting the following in the console:
Mapping string: toggleVehicleMap to index: 17
scripts/server/race/checkpoint.cs (18): Unknown command onEnterTrigger.
This script works in both tge and tgea without problems. This onEnterTrigger is the default used in triggers.cs.
In "scripts/server/race/" I have checkpoint.cs.
It is inited in scriptExec.cs in "scripts/server/" like this:
// Load up all scripts. This function is called when
// a server is constructed.
exec("./camera.cs");
exec("./triggers.cs");
exec("./inventory.cs");
exec("./shapeBase.cs");
exec("./item.cs");
exec("./health.cs");
exec("./projectile.cs");
exec("./radiusDamage.cs");
// Load our racing scripts
exec("./race/checkpoint.cs"); // <--- My scriptI originally had it at the bottom of the page, but moved it to see if it would work here. I'm getting the following in the console:
Mapping string: toggleVehicleMap to index: 17
scripts/server/race/checkpoint.cs (18): Unknown command onEnterTrigger.
This script works in both tge and tgea without problems. This onEnterTrigger is the default used in triggers.cs.
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
datablock TriggerData(CheckPointTrigger)
{
// The period is value is used to control how often the console
// onTriggerTick callback is called while there are any objects
// in the trigger. The default value is 100 MS.
tickPeriodMS = 100;
};
//-----------------------------------------------------------------------------
function CheckPointTrigger::onEnterTrigger(%this,%trigger,%obj) // //<-- Error Here
{
Parent::onEnterTrigger(%this,%trigger,%obj);
if(%obj.client.nextCheck == %trigger.checkpoint)
{
if(%trigger.isLast)
{
// Player has completed a lap.
%obj.client.lap++;
if(%obj.client.lap >= $Game::Laps)
{
// Increase his score by 1.
%obj.client.incScore(1);
// End the game
cycleGame();
}
else {
%obj.client.nextCheck = 0; //changed from 1 to test and it works
commandToClient(%obj.client, 'IncreaseLapCounter');
}
}
else {
// Continue to the next one.
%obj.client.nextCheck++;
}
}
else
centerPrint(%obj.client, "Wrong Checkpoint!", 1, 1);
}That's the entire script. Does anyone have any idea why this won't work?
Torque 3D Owner John "Mythic" Henry
EveronWorlds
Takes only two arguments as well as the parent call
It should be:
function CheckPointTrigger::onEnterTrigger(%this,%obj) // //<-- Error Here { Parent::onEnterTrigger(%this,%obj); if(%obj.client.nextCheck == %trigger.checkpoint) { ... ... ..%this and %trigger were duplicates of each other
So change any reference to %trigger -> %this OR
[code] function CheckPointTrigger::onEnterTrigger(%trigger,%obj) // //<-- Error Here { Parent::onEnterTrigger(%trigger,%obj); if(%obj.client.nextCheck == %trigger.checkpoint) { ... ..And dont use %this instead :)