Author Topic: Player function.  (Read 2334 times)

How do you create a function like %player.blah();, Is it GameConnection::Blah(){} like it is for clients or what?
« Last Edit: October 01, 2007, 11:50:07 AM by MrPickle »

Code: [Select]
function Player::Blah(%this, %othercrapyouwant){
   ...

Oh, It's that simple :S.

Thanks.

I tried this but it's jsut Crashing.

Code: [Select]
function Grow(%this, %max){
if(%this.getScale < %max){
%this.setScale(vectorAdd(%this.getScale,"1 1 1"));
grow(%this, %max);
}

Quote
function Player::Grow(%this, %max){
if(%this.getScale < %max){
%this.setScale(vectorAdd(%this.getScale(),"1 1 1"));
schedule(200,0,grow,%this, %max);
}

Player:: for %player.grow("2 2 2"); or something.
If you changed just the brackets then it would instantly scale them to the max.
The schedule only would cause lag, as it schedules while looking for a nonexistant variable (%this.getScale).

I corrected most of that stuff after I posted the topic.

It just changes their scale to max.
« Last Edit: October 01, 2007, 12:30:27 PM by MrPickle »

Code: [Select]
function Player::Grow(%this, %max){
if(%this.getScale < %max){
%this.setScale(vectorAdd(%this.getScale(),"0.25 0.25 0.25"));
%this.schedule(200,0,grow, %max);
}

Made a mistake in the schedule, but I can't see how that would affect Instant Grow. I made the increase in scale smaller, that may help.


Code: [Select]
function Player::Grow(%this, %max){
for(%i=0;%i<3;%i++){
if(getWord(%this.getScale(), %i) >= %max)
return;
}
%this.setScale(vectorAdd(%this.getScale(), "0.25 0.25 0.25"));
%this.schedule(200, 0, Grow, %max);
}

Care to explain why it's needed?

Oh and it only adds .25 to their size.
« Last Edit: October 01, 2007, 01:49:50 PM by MrPickle »

%player.getScale() returns a vector, and you cannot compare vectors, so you need to loop through the vector and compare each value with %max. Also there was some parenthesis and braces missing.

Also there was some parenthesis and braces missing.

In english =D

Parenthesis = ( )
Braces = { }

Where are they missing?

function Grow(%this, %max){
if(%this.getScale < %max){
%this.setScale(vectorAdd(%this.getScale,"1 1 1"));
grow(%this, %max);
}


There are two starting braces and one ending one.