Author Topic: static map spawn??  (Read 4198 times)

That'll give you an error. Try using getrandom like I did

Also ! Is the not operand in torquescript. So !a is not a.
If you wanted to do 'if player is not in minigame' you'd do if(!isobject(%client.minigame)) as opposed to if(isobject(%client.minigame))
Ohh, okay. So if I do

Code: [Select]
%array[1] = "-29.6914 6.556 9.68498";
%array[2] = "-19.6014 7.51866 3.68498";
$spawnVec = %array[getrandom(1,2)];

package YourPackage

if(!isobject(%client.minigame))
then
      {
function GameConnection::spawnPlayer(%this) {
Parent::spawnPlayer(%this);
%this.player.setTransform($spawnVec);
}
}

activatePackage(YourPackage);

Would that be it?

Yes on the array.

The if statement must be within the function. Also there's no then statement in torquescript

Yes on the array.

The if statement must be within the function. Also there's no then statement in torquescript
Ahh, okay.. Let me adjust give me a sec
« Last Edit: February 28, 2018, 10:57:21 PM by datiel12 »

Also make sure the parent part stays outside of the if statement. Parent ensures that all game code attached to the function is called. If you put it inside an if statement, you'll never spawn if the condition is false

Also make sure the parent part stays outside of the if statement. Parent ensures that all game code attached to the function is called. If you put it inside an if statement, you'll never spawn if the condition is false
Maybe like this?

Code: [Select]
%array[1] = "-29.6914 6.556 9.68498";
%array[2] = "-19.6014 7.51866 3.68498";
$spawnVec = %array[getrandom(1,2)];

package YourPackage

      {
       if(!isobject(%client.minigame));
function GameConnection::spawnPlayer(%this) {
Parent::spawnPlayer(%this);
%this.player.setTransform($spawnVec);
}
}

activatePackage(YourPackage);

Put the if statement Inside the function. If statements need { } open close brackets too. Everything inside the brackets will be called if the condition is true

Here I'll just

Code: [Select]
%array[1] = "-29.6914 6.556 9.68498";
%array[2] = "-19.6014 7.51866 3.68498";
$spawnVec = %array[getrandom(1,2)];

package YourPackage
{
function GameConnection::spawnPlayer(%this) {
Parent::spawnPlayer(%this);
                If(!isobject(%this.minigame))
       %this.player.setTransform($spawnVec);
}
};

activatePackage(YourPackage);

Here I'll just

Code: [Select]
%array[1] = "-29.6914 6.556 9.68498";
%array[2] = "-19.6014 7.51866 3.68498";
$spawnVec = %array[getrandom(1,2)];

package YourPackage
{
function GameConnection::spawnPlayer(%this) {
Parent::spawnPlayer(%this);
                If(!isobject(%this.minigame))
      %this.player.setTransform($spawnVec);
}
};

activatePackage(YourPackage);
thats how mine looks like lol, gonna testeeeeee

thats how mine looks like lol, gonna testeeeeee
it's a bit different. In the future you should read up a bit on torquescript syntax if you plan on doing stuff like this

You learn a lot when you learn

it's a bit different. In the future you should read up a bit on torquescript syntax if you plan on doing stuff like this

You learn a lot when you learn
Just like when my dad was teaching me javascript, thanks PhantOS!

Make sure you change the package name from your package to something specific, like uh... mapSpawnPackage

Someone else's add-on might conflict if they use the same name

Make sure you change the package name from your package to something specific, like uh... mapSpawnPackage

Someone else's add-on might conflict if they use the same name
Yeah, I knew that. I read that on another topic before.

Make sure you change the package name from your package to something specific, like uh... mapSpawnPackage

Someone else's add-on might conflict if they use the same name
As a token of appreciation heres a pic what I was working on!


%array[1] = 5;
%array[2] = 88;
announce(%array[getrandom(1,2)]);
I know you probably did it this way for simplicity's sake. But I feel I should mention that arrays usually start at "0" by convention. So it "should" start at %array[0] instead of %array[1]. That also means %array[getrandom(1,2)] would instead be %array[getrandom(0,1)].

As a token of appreciation heres a pic what I was working on!
https://imgur.com/pSqTdcH.png
It good to see people making maps again! What's the theme, by the way?
« Last Edit: March 01, 2018, 04:38:17 AM by Platypi »

I know you probably did it this way for simplicity's sake. But I feel I should mention that arrays usually start at "0" by convention. So it "should" start at %array[0] instead of %array[1]. That also means %array[getrandom(1,2)] would instead be %array[getrandom(0,1)].
It good to see people making maps again! What's the theme, by the way?
it's good practice to do it that way, but it has no bearing whatsoever. There are no outofbounds exceptions in torquescript so there's no real pressure to abide by the whole starting from 0 stuff

It's entirely up to preference