Game Development Community

Script function parameters

by Luis Anton · in Torque Game Engine · 05/07/2004 (12:23 am) · 4 replies

Hi!

I'm a little confused with script function parameters. I am trying to pass a certain value to the AIPlayer::spawnPlayer function, but it totally ignores me. Well, I guess it's because of the AIPlayer constructor in c++... is it? There are no parameters there.

I need something like %bot = AIPlayer::spawnPlayer(%id). Doing just that (adding %id in the script function) doesn't work, %id is "" inside the spawnPlayer function. How could I do that? Should I create another function to 'encapsulate' the spawnPlayer function? That's the straightest way I have found, something like:

function createPlayer(%id)
{
   %bot = AIPlayer::spawnPlayer();
   %bot.id = %id;

   return %bot;
}

Any other ideas?

#1
05/07/2004 (2:43 am)
I'm not sure what version of the system you're running but if you get the latest HEAD here's how you can create a bot:

function createBot()
{
  %bot = AIPlayer::spawn("Name", pickSpawnPoint());
  return %bot;
}

The id is automatically assigned. You can do this in the console window as well.
#2
05/07/2004 (11:50 am)
Uh, sorry, but the thing is not how to create a bot, I already have many of them, but how to create a bot sending it some parameters. The ID was just an example... :)
#3
05/07/2004 (6:30 pm)
Your encapsulation lookks like it will work fine.
#4
05/09/2004 (12:55 pm)
Ok, thanks :)