Odd var changes between functions?
by Darkfire Games · in Torque Game Builder · 05/21/2008 (4:29 pm) · 5 replies
function SpawnZoneClass::Spawn( %this, %scenegraph )
{
%spawnTime = 4000;
%spawnVariance = 1000;
%xPos = getRandom(getWord(%this.getAreaMin(), 0), getWord(%this.getAreaMax(), 0));
%yPos = getRandom(getWord(%this.getAreaMin(), 1), getWord(%this.getAreaMax(), 1));
echo( %xPos SPC %yPos SPC " X Y" );
%this.CreateEnemy( %xPos, %yPos );
%minTime = %spawnTime - %spawnVariance;
%maxTime = %spawnTime + %spawnVariance;
%spawnTime = getRandom(%minTime, %maxTime);
%this.schedule(%spawnTime, "Spawn");
}function SpawnZoneClass::CreateEnemy( %xPos, %yPos )
{
echo( %xPos SPC " X");
echo( %yPos SPC " Y");
}Both via echo statements and watching the vars through debugging, when i call "CreateEnemy" the %xPos and %yPos vars change.. and i cannot figure out why.
Results of echo:
48 -55 X Y
1537 X
48 Y
so it would seem the id of the obj replaces the %xPos and %yPos gets the previous %xPos value... wth have i borked up here, i cant see it. :)
About the author
#2
05/21/2008 (4:54 pm)
Doesnt change the result
#3
05/21/2008 (4:56 pm)
Double posts
#4
05/21/2008 (4:57 pm)
What James meant was to change your function to this:function SpawnZoneClass::CreateEnemy( %this, %xPos, %yPos )
{
echo( %xPos SPC " X");
echo( %yPos SPC " Y");
}
#5
Edit: ahh, i put %this as first argument in calling the function as well as the function itself and that is what threw it off.
Thanks guys.
05/21/2008 (5:04 pm)
I did =\Edit: ahh, i put %this as first argument in calling the function as well as the function itself and that is what threw it off.
Thanks guys.
Associate James Ford
Sickhead Games