Triggers faulty?
by Ted Lilljegren · in Technical Issues · 03/10/2008 (2:40 pm) · 9 replies
I have set up a trigger, and on the triggerTicks, i want to perform some actions with the objects inside the trigger(kinda senseless otherwise =) )
Anyways, the documentation states that i can use getNumObjects and getObject to browse through the objects inside the trigger.
The thing is that the console log tells me that there is no such functions.
Here is what my script looks like:
function Trigger::onTickTrigger(%this,%trigger)
{
%nObjects = %this.getNumObjects();
%this.getObject(0);
}
Easy right(i know that Parent::onTickTrigger(%this,%trigger); is missing, but that is not relevant is it? I have tried both with and without)?
Have i missed something here or what?
Edit: I have modified my engine, but not extensively, and almost all of the modifications involved adding stuff instead of changing stuff.
Anyways, the documentation states that i can use getNumObjects and getObject to browse through the objects inside the trigger.
The thing is that the console log tells me that there is no such functions.
Here is what my script looks like:
function Trigger::onTickTrigger(%this,%trigger)
{
%nObjects = %this.getNumObjects();
%this.getObject(0);
}
Easy right(i know that Parent::onTickTrigger(%this,%trigger); is missing, but that is not relevant is it? I have tried both with and without)?
Have i missed something here or what?
Edit: I have modified my engine, but not extensively, and almost all of the modifications involved adding stuff instead of changing stuff.
About the author
#2
I believe its part of the TGE documentation, but i could be wrong.
If it happens to be so that i read documentation regarding TGB or something, what would your approach be to making stuff happen repeatedly after a set interval, with the objects inside the trigger?
http://www.4colorrebellion.net/media/pics/06/02/secret_of_mana.jpg
Totally off topic, but its a pretty cool picture right? I like the way the characters are facing so that you see their backs only. I miss the 90ies =/
03/10/2008 (4:48 pm)
Http://tdn.garagegames.com/wiki/WorldBuilding/MissionEditor/Creating_TriggersI believe its part of the TGE documentation, but i could be wrong.
If it happens to be so that i read documentation regarding TGB or something, what would your approach be to making stuff happen repeatedly after a set interval, with the objects inside the trigger?
http://www.4colorrebellion.net/media/pics/06/02/secret_of_mana.jpg
Totally off topic, but its a pretty cool picture right? I like the way the characters are facing so that you see their backs only. I miss the 90ies =/
#3
function mytrigger::onEnterTrigger(%this,%trigger,%obj)
{
MyFunction(%obj);
}
function MyFunction(%obj)
{
// your code here
schedule(time in miliseconds here, 0, "MyFunction", %obj);
}
03/10/2008 (7:48 pm)
Interesting! Well unless you are spawning the trigger with the players / objects already inside of it, and I'm going to assume you aren't, you can just use the OnEnterTrigger function to grab the id of each object entering. When the OnEnterTrigger function is called, call another function that you can schedule, something like this -function mytrigger::onEnterTrigger(%this,%trigger,%obj)
{
MyFunction(%obj);
}
function MyFunction(%obj)
{
// your code here
schedule(time in miliseconds here, 0, "MyFunction", %obj);
}
#4
function myTrigger::onEnterTrigger(%this,%trigger,%obj)
{
$schedule = schedule(100, 0, "MyFunction", %obj);
}
function myTrigger::onLeaveTrigger(%this,%trigger,%obj)
{
Cancel($schedule);
}
Since the trigger is called on server side(as it is suposed to be?) and that means that every user would have to have said schedule asociated with them as following:
schedule(100, %userHandle, "MyFunction", %obj);
Problem is, i cant make something like this:
function myTrigger::onLeaveTrigger(%this,%trigger,%obj)
{
Cancel(%obj.schdule);
}
Since %obj.schdule is not a valid schedule. I dont know why you would want the schdule to be asociated with a "name", since you cant use it to cancel the schedule(right?), and if you want for example to know to which user the schedule is asociated with, you could just pass the users handle as an extra argument.
I could make something like this:
function mytrigger::onEnterTrigger(%this,%trigger,%obj)
{
MyFunction(%obj);
}
function MyFunction(%obj)
{
// your code here
%obj.schedule(100, 0, "MyFunction", %obj);
}
function mytrigger::onLaveTrigger(%this,%trigger,%obj)
{
Cancel(%obj.schedule);
}
But that looks so bad, also, i belive it is not possible
03/11/2008 (4:07 am)
Yes that is what i tought too, the problem is though, that when the "onLeaveTrigger" i called, i am going to have to call the Cancel() function, problem is, the schduele in particular lacks a "eventId"(right?) and i cant make something like this:function myTrigger::onEnterTrigger(%this,%trigger,%obj)
{
$schedule = schedule(100, 0, "MyFunction", %obj);
}
function myTrigger::onLeaveTrigger(%this,%trigger,%obj)
{
Cancel($schedule);
}
Since the trigger is called on server side(as it is suposed to be?) and that means that every user would have to have said schedule asociated with them as following:
schedule(100, %userHandle, "MyFunction", %obj);
Problem is, i cant make something like this:
function myTrigger::onLeaveTrigger(%this,%trigger,%obj)
{
Cancel(%obj.schdule);
}
Since %obj.schdule is not a valid schedule. I dont know why you would want the schdule to be asociated with a "name", since you cant use it to cancel the schedule(right?), and if you want for example to know to which user the schedule is asociated with, you could just pass the users handle as an extra argument.
I could make something like this:
function mytrigger::onEnterTrigger(%this,%trigger,%obj)
{
MyFunction(%obj);
}
function MyFunction(%obj)
{
// your code here
%obj.schedule(100, 0, "MyFunction", %obj);
}
function mytrigger::onLaveTrigger(%this,%trigger,%obj)
{
Cancel(%obj.schedule);
}
But that looks so bad, also, i belive it is not possible
#5
function myTrigger::onEnterTrigger(%this,%trigger,%obj)
{
$schedule[%obj] = schedule(100, 0, "MyFunction", %obj);
}
function myTrigger::onLeaveTrigger(%this,%trigger,%obj)
{
Cancel($schedule[%obj]);
}
OR - but like I said I'm not sure if this will work over a network
function myTrigger::onEnterTrigger(%this,%trigger,%obj)
{
%obj.schedule = schedule(100, 0, "MyFunction", %obj);
}
function myTrigger::onLeaveTrigger(%this,%trigger,%obj)
{
Cancel(%obj.schedule);
}
03/11/2008 (9:28 am)
You might want to drop the schedule id and object id into a global array instead of a single variable or you can try to assign the schedule id the object itself but I'm not sure if that would work over multiplay.function myTrigger::onEnterTrigger(%this,%trigger,%obj)
{
$schedule[%obj] = schedule(100, 0, "MyFunction", %obj);
}
function myTrigger::onLeaveTrigger(%this,%trigger,%obj)
{
Cancel($schedule[%obj]);
}
OR - but like I said I'm not sure if this will work over a network
function myTrigger::onEnterTrigger(%this,%trigger,%obj)
{
%obj.schedule = schedule(100, 0, "MyFunction", %obj);
}
function myTrigger::onLeaveTrigger(%this,%trigger,%obj)
{
Cancel(%obj.schedule);
}
#6
Anyways pretty strange that getObject() and getNumObjects() was not found, is there someone who has managed to duplicate these results?
03/11/2008 (2:35 pm)
Thats clever. Btw the second solution you made is identical to one of those i wrote down =)Anyways pretty strange that getObject() and getNumObjects() was not found, is there someone who has managed to duplicate these results?
#7
03/11/2008 (5:30 pm)
I could be wrong but I don't think my second solution was identical to yours because I am returning the scheduling ID to a custom field attached to that object.
#8
03/12/2008 (3:04 pm)
Yeah i see the difference now. Ill have to go for the global variable arraylist, will only have about 8 players per server so might as well...
#9
EDIT: documentation meaning TDN
03/15/2008 (11:23 am)
Follow up: the documentation was faulty, the right handle for the mentioned functions was supposed to be %trigger, and not %this, i will try and change the documentation so it shows the correct answerEDIT: documentation meaning TDN
Torque Owner Steve D