onWorldLimit Question.
by rennie moffat · in Torque Game Builder · 10/23/2009 (6:24 pm) · 5 replies
I have run this thru my compiler, it is working now, thanks mom, but on the rizeal, I need to now what is wring here. I do not know what it is but it ran thru my copiler saying there was an error at line 10 (%this.left).
function Spacer3000Controls::onWorldLimit(%this, %limitMode, %limit)
{
%playerPosition = %this.getPosition();
switch$(limit)
{
case "left":
if (%playerPosition + %cameraPosition <= -50)
{
%this.left;
%this.owner.setLinearVelocityX(2);
}About the author
My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.
#2
10/23/2009 (7:15 pm)
Moderated. Do not post harassing or inflamatory comments.
#3
(BTW, it's sad to see that Ehrlichmann is gone. He provided a lot of good help to all programmers.)
10/24/2009 (3:31 am)
Yeah, I think the "%this.left;" is completely superfluous. I actually think the whole if-condition isn't needed, is it? I mean, doesn't the documentation state that a call to "onWorldLimit" means that the object has already hit the world limit?(BTW, it's sad to see that Ehrlichmann is gone. He provided a lot of good help to all programmers.)
#4
10/24/2009 (9:47 am)
k , so perhaps this is what I need to understand. In "Tron" terms ( the movie aka how programs work ) does a onWorldLimit function essentially sit there until the "owner.object" hits it? At that point the function, on its own, recognises that? In other words does the onWorldLimit have "sentinels"(Matrix) if you will that retrieve information for it?
#5
When you define a function (let's call it "foo"), all you're doing is assigning a name to a block of code. When some other code executes a statement like foo(%bar), it's calling the function - i.e. it causes the code inside the function to run.
In this case, the "other code" is the engine itself, not your code, and it calls the onWorldLimit() function when an object hits its world limit. It doesn't happen because of "sentinels," or self-aware functions, or any other hollywood nonsense, it's just the engine checking for a particular condition and calling the function if the condition is true.
10/24/2009 (11:29 am)
"Tron" is a great movie, but don't kid yourself - it's just a movie. It doesn't have a thing to do with how software actually works. Digressing into flights of hollywood fancy won't help you understand what we're discussing here, so please try to stay focused on the topic at hand.When you define a function (let's call it "foo"), all you're doing is assigning a name to a block of code. When some other code executes a statement like foo(%bar), it's calling the function - i.e. it causes the code inside the function to run.
In this case, the "other code" is the engine itself, not your code, and it calls the onWorldLimit() function when an object hits its world limit. It doesn't happen because of "sentinels," or self-aware functions, or any other hollywood nonsense, it's just the engine checking for a particular condition and calling the function if the condition is true.
Torque 3D Owner Sherman Pendley
So, you want to do something with %this.left - that much is obvious from the fact that you've written its name. But what do you want to do with it?