Game Development Community

Why Would...(solved)

by rennie moffat · in iTorque 2D · 08/31/2011 (8:22 am) · 17 replies

...these schedules, at the bottom of the chunk not call a function? The function name and class are correct. But they are simply not calling the said function. No eco returns nothing.


function EnemyMcGeeBehavior::startOF(%this)
{
	if(%eReaction == 1)
	{
		echo("eMcG %eReaction == 1 so enemy do.");
		//this means enemy succesfully defends
		$EnemyChangeState = true;
		$EnemyDo = true;
		$EnemyDont= false;
		///will also have to something here.
		/*%this.thing.moveTo();*/
		%this.schedule(500, eRecover);
		%this.schedule(1000, reREreRE);
	}
}
function EnemyMcGeeBehavior::eRecover(%this)
{
	echo("eMcG eRecover");
}
function EnemyMcGeeBehavior::reREreRE(%this)
{
	echo("eMcG reREreRE");
}

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.


#1
08/31/2011 (8:34 am)
What is %eReaction? Do you see that echo in the console?
#2
08/31/2011 (9:05 am)
yes,
tho I did not post, my echos lead me into this method. However, they do not call the scheduled functions. Really a huge hair puller. I am wondering if there is a small syntax, but there are no errors and the loops are completing etc.



Here is a pastebin link.
Not sure if it helps (as I posted the full code *note i edited some names here).
pastebin.com/We316ibj
#3
08/31/2011 (12:10 pm)
try this:
%this.schedule(500, "erecover");  
%this.schedule(1000, "rererere");
Also, I'm pretty sure that torquescript is not case sensitive so eRecover is the same as erecover and reREreRE is the same as this rererere. Assuming case sensitivity where none exist can lead to difficult bugs to track down.
#4
08/31/2011 (12:15 pm)
yah, I know it is something so obscure I am sure million men would be waisting their time trying to find it, just driving me crazy this morning. no worries, have since moved on.

rrrRr. hate stuf like that.


#5
08/31/2011 (1:41 pm)
@rennie - Is the code linked to pastebin EXACTLY what you are working with? Provide exactly what you are using, do not edit names out.
#6
08/31/2011 (2:12 pm)
um, there may be a few extra functions. this is the exact behavior. There is quite a bit, but the basic idea is, onCollision, with ChipClass, ChipSwipeAccount. From there, I determine %eReaction (getRandom, 1 or 2). This causes a few variables to be switched, and on schedule, I want to reset the settings, thus eRecover (the other ererer is just there because I was fed up).


pastebin.com/GwPupm5D
If you find anything I would be surprised, pleasantly.


#7
08/31/2011 (3:28 pm)
Do any of your schedules work? What about the one in the onBehaviorAdd function?
#8
08/31/2011 (4:15 pm)
I have seen odd things like this before, but never stopped to really pay attention to what could be the cause.

Try echoing the schedule ID to check if the function is working at all.
%schID = %this.schedule(500, erecover); 
echo("Schedule ID:" SPC $schID);
Also try another approach to the schedule, just for the sake of checking if it works, like:
%schID = schedule(500, %this, erecover);
echo("Schedule ID:" SPC %schID);
#9
08/31/2011 (5:26 pm)
No. nothing is happening. I just added in a direct call to the function in onCollision. It at least turned up something... the console spit out that..
game/scripts/behaviors/EnemyMcGeeBehavior.cs (72): Unknown command erecover

I DONT GET ITTTT.
It makes not sense.


I get a return in the "Schedule ID" too tho. It returns 42 (not sure what that means). I even added the schedule into itself as well, so once called it would continually call itself, but no returns are showing.


???


I may as well just scrap it and start fresh.
#10
09/01/2011 (8:45 am)
@Rennie -

Without seeing all of the code, I have to go by what I see.

That being said, my impression of the scenario is that you are passing one of your ChipClass objects into your EnemyMcGeeBehavior behavior class methods.

So, when you make a call to %this.schedule(blah, blah), your %this is not an object within the same namespace, and thus, the call simply will not be allowed (i.e. It's not in scope).

Make sure that you are indeed calling the scheduled methods listed as behaviors from a SimObject within the EnemyMcGeeBehavior namespace.

So, in a nutshell:
ChipClass_object.schedule(500, erecover); // Will NOT work
EnemyMcGeeBehavior.schedule(500, erecover); // Will work


Also, you are getting a valid ID returned from your call to schedule() because it is working. If your call was not from a valid object (just a SimObject mind you, not necessarily the correct type), it would have returned 0 (zero). The '42' (which is ALWAYS the answer, right? ;) ) is just the sequence number of your posted event. That becomes your event ID.

So, the schedule is indeed working but the call itself is illegal. Does that make sense?

Good luck!
#11
09/01/2011 (9:15 am)
I dont know man.
I have a collision register in McGee Class. On that, I pass a new function. In that function, I call a schedule.


MMMM me no like.
#12
09/01/2011 (10:04 am)
I understand what you are saying, but your onCollision() method has a %srcObject passed in whose origin is unknown to us. That object makes the call to ChipSwipeAccount(), which in turn schedules the call to eRecover().

If your %srcObject is not of the correct namespace, the call will fail. You won't see any error messages (unless you feel like editing all of the simBase code and adding more verbose error checking yourself)...it just won't take place.

I suggest simply (just before the call to schedule eRecover()) echoing out %this. If it is null (or blank) in the console, it is not recognized as a valid object at all. Otherwise, you'll get the object ID.

You could also run something like:

echo("Is a member of EnemyMcGeeBehavior?: " @ %this.isMemberOfClass("EnemyMcGeeBehavior"));

If you get a non-zero response, then the object is within the namespace. Otherwise...


Also, look at your code (from pastebin) on lines 90-93. You have a typo that would certainly cause issues.

function EnemyMcGeeBehavior::ChipSwipeAccount(%this)
{
        if(EnemySwiping == true) // <-- Should be $EnemySwiping
        return;



Hope this helps!
#13
09/02/2011 (8:49 am)
@Brian. You are the man.
That missing global on line 92 was it!!! a simple dollar sign. CHEERS!!!!



#14
09/02/2011 (1:10 pm)
Glad I could help. :)
#15
09/02/2011 (5:06 pm)
You have the eye of a champion.


:::::::||||||::::::|||:::||::|:||
#16
09/02/2011 (9:10 pm)
Im not sure, but maybe on line 278 need $ too

if(EnemyOutOfChips == false)
#17
09/04/2011 (5:17 pm)
Right.
Thanks.