Author Topic: Explain Usage of a few things for me  (Read 421 times)

Just wanted to get a few scripting questions cleared up.

What exactly is an aiplayer and what is the correct usage / syntaxing of it?

What are scriptobjects and what is the correct syntaxing?

Is there any way to see what a function does?
ex.
Code: [Select]
function example(%a)
{
   if(%a)
      echo("hi");
   else
      return;
}

Is there any way to find out what the example function does beforehand, assuming you know the function name, but not what it does?

How do you find out vanilla functions, for packaging and such?
(Like NMHType::Send)
Is there a list somewhere on the forums?

What are the different types of datablocks?
(ItemData, ShapeBaseImageData, etc...)


What are all the arguments of the schedule function?
schedule(delay,???,command);



Code: [Select]
registerOutputEvent(fxDTSbrick,"name","inputtype",1);
In the above code, what are all the possible input types, and what does the 1 mean?

Thanks in advance to anybody that helps.
« Last Edit: August 18, 2012, 04:07:32 AM by Evar678 »

What exactly is an aiplayer and what is the correct usage / syntaxing of it?
An aiPlayer is an object type used for non player characters (bots). There's a number of functions you can use to manipulate it. To initialize (create) one, you must specify a datablock and probably a position unless you're fine with it spawning at "0 0 0".
new aiPlayer(bot) { dataBlock = playerStandardArmor; position = "16 16 0"; };
You may then call bot.dump(); to get a list of functions for that bot, but the usual are:
  • setMoveDestination( position )
  • setAimLocation( position )
  • setMoveObject( object )
  • setAimObject( object )
I think they're pretty self explanatory.

What are scriptobjects and what is the correct syntaxing?
Script objects are a type of object (just like aiPlayer, player, bricks, etc) that are kind of a "blank". They don't have any physical properties and thus are not rendered in game. They're more an object you can use to store data or run functions on. To initialize one:
new scriptObject(mySO); OR new scriptObject(mySO) { someVariable = "some value"; };

A use I find extremely useful for them is to set their class to your own kind of class and write a function for it. Like this:
Code: [Select]
$SO = new scriptObject() { class = mySO; };

function mySO::addNumbers(%this, %numOne, %numTwo)
{
%sum = %numOne + %numTwo;
return %sum;
}

Is there any way to see what a function does?
If the function was introduced in an add-on, you can go to that particular add-on and read the code to see what it does. If it is a default feature of the game, you can not see what it does.

Is there any way to find out what the example function does beforehand, assuming you know the function name, but not what it does?
I don't quite understand what you mean.

How do you find out vanilla functions, for packaging and such?
(Like NMHType::Send)
Is there a list somewhere on the forums?
When performing particular tasks you can use the function trace(); to see every function that's being called. trace(1); will turn on console trace, trace(0); will turn it off. If the purpose is to discover default functions, I recommend you disable all add-ons to reduce the clutter you have to read through.

What are the different types of datablocks?
(ItemData, ShapeBaseImageData, etc...)
There are a lot so I'm not going to compile a whole list for you. However, some more include: player, aiplayer, scriptobject, simgroup, simset and fxDTSBrick.

What are all the arguments of the schedule function?
schedule(delay,???,command);
schedule( delay , object , command , arguments , arguments , arguments )

delay: how long in milliseconds to wait  before executing command
object: what object to call the command on, for example if you fill in a brick for this field and killBrick as the command, it will kill this brick. Use 0 otherwise.
command: function to execute
arguments: arguments to said function

example: schedule(1000, clientGroup, deleteAll); or schedule(1000, 0, echo, "hello!");

Code: [Select]
registerOutputEvent(fxDTSbrick,"name","inputtype",1);
In the above code, what are all the possible input types, and what does the 1 mean?
http://forum.blockland.us/index.php?topic=40631.0

example: schedule(1000, clientGroup, deleteAll); or schedule(1000, 0, echo, "hello!");

You can also use clientGroup.schedule(1000, "deleteAll");

That pretty much answers all my questions. Much appreciated TripNick!

Locking Now

Guess not
« Last Edit: August 18, 2012, 04:52:40 PM by Evar678 »