Classic Forums

Please login or register.

Login with username, password and session length
Advanced search  

News:

Graal the Adventure 2004 is now on Graal Reborn! | Introducing Project GrailWay

Pages: 1 2 [3] 4 5 ... 10
 21 
 on: October 30, 2017, 09:52:55 PM 
Started by maximus_asinus - Last post by Teerawut
It is an event that is very good. I'm waiting for this activity as well.

 22 
 on: October 30, 2017, 09:49:23 PM 
Started by maximus_asinus - Last post by Teerawut
Expand on Morgan It's the right thing to do.

 23 
 on: October 21, 2017, 04:39:10 AM 
Started by maximus_asinus - Last post by Inevitable
rip

 24 
 on: September 05, 2017, 12:34:56 PM 
Started by maximus_asinus - Last post by Thor
Following 2 months and 1 week Unixmad is proving once again that he is a disgrace and cannot be trusted.

 25 
 on: August 20, 2017, 06:59:17 PM 
Started by maximus_asinus - Last post by maximus_asinus
Is there a reason why you prefer one over the other? They appear to function the same if you're using it in that manner.

 26 
 on: August 20, 2017, 03:27:36 PM 
Started by maximus_asinus - Last post by maximus_asinus
Most "can i b admin"s aren't a big deal. But occasionally you get someone who spends hours/days/weeks/months begging for it non stop.
The worst I've had is someone ask about 3 times, and when I didn't respond he kindly told me to fellate him.

But I've only been at this a few weeks. ;)

 27 
 on: August 20, 2017, 01:23:16 PM 
Started by maximus_asinus - Last post by Racil
Don't remember, did that guy who was following me and my friends for over a year also beg to be admin for that long, or just ask you to make a server for him?
Or maybe he never actually asked to be admin, just for you to make him a server?

 28 
 on: August 20, 2017, 06:19:28 AM 
Started by maximus_asinus - Last post by Thor
Code: [Select]
function onPlayerEnters() {
  if (client.waterfilled = true) {

Using a single = will always treat the conditional as TRUE, it should be ==. Better yet if you're storing boolean values (true/false or 1/0) you can just do:

Code: [Select]
function onPlayerEnters() {
  if (client.waterfilled) {

or

Code: [Select]
function onPlayerEnters() {
  if (!client.waterfilled) {

--------

Rather than use a timeout I use scheduleEvent(), which can be cancelled with cancelEvents("action").

Code: [Select]

function onFillWater() {
  //blah blah
  this.scheduleEvent(0.2, "FillWater");
}

function onDrainWater() {
  //blah blah
  this.scheduleEvent(0.2, "DrainWater");
}

function stopFill() {
  //blah blah
  this.cancelEvents("FillWater");
}

function stopDrain() {
  //blah blah
  this.cancelEvents("DrainWater");
}


 29 
 on: August 20, 2017, 02:59:27 AM 
Started by maximus_asinus - Last post by Thor
Most "can i b admin"s aren't a big deal. But occasionally you get someone who spends hours/days/weeks/months begging for it non stop.

 30 
 on: August 20, 2017, 01:21:42 AM 
Started by maximus_asinus - Last post by maximus_asinus
Sorry to bring this back up. I'm not sure if this is appropriate to talk about here or if I should ask these questions on the other forum.

I've been reviewing the water script and I finally got to a point where I somewhat understand what is happening. I tried to add on draining functionality (which works) but it is definitely hacked together. Do you have any advice on how to clean this up?

Code: [Select]
// setting variables and giving the object a name

function onCreated() {
  this.waterWidth = 24;
  this.waterHeight = 8;
  this.boundaryWidth = 2;
  this.boundaryHeight = 2;
  this.level.foobar = this;
}

// designed to show proper water level if the player were to log off.
// using client variable to save status

function onPlayerEnters() {
  if (client.waterfilled = true) {
    this.showpoly(200, {this.x, this.y, this.x + this.waterWidth, this.y, this.x + this.waterWidth, this.y + this.waterHeight, this.x, this.y + this.waterHeight});
    this.changeimgcolors(200,0,0,1,0.75);
    this.changeimgvis(200,1);
  }
  else this.hideimg(200);
}

// triggering public function from a switch in the level.
// using it this way so I can break a nested timeout.

public function watercheck() {
  if (client.waterfilled == true) {
    this.filledHeight = 0;
    this.filledWidth = 0;
  }
  else {
    this.filledHeight = this.waterHeight;
    this.filledWidth = this.waterWidth;
  }
  setTimer(0.05);
}

function onTimeout() {
  waterAction();
  setTimer(0.1);
}

function waterAction() {

// the truly hacked part
// enabling and disabling the movement and breaking the timeout once the water is finished it's thing

  if (client.waterfilled == true) {
    if (this.waterWidth == this.filledWidth && this.waterHeight == this.filledHeight) {
      disablescriptmovement = false;
      return;
    }
    else  disablescriptmovement = true;
  }
  if (client.waterfilled ==  false) {
    if (this.filledWidth <= 0 && this.filledHeight <= 0) {
      disablescriptmovement = false;
      return;
    }
    else  disablescriptmovement = true;
  }
  temp.w = this.waterWidth - (this.boundaryWidth * 2);
  temp.h = this.waterHeight - (this.boundaryHeight * 2);
  this.xIncrease = 50;
  this.yIncrease = 50;
  if (this.boundaryWidth > 0) {
    if (this.waterWidth - this.filledWidth <= this.boundaryWidth * 2) {
      temp.w = this.boundaryWidth;
      this.xIncrease /= 2;
    }
    if (this.waterHeight - this.filledHeight <= this.boundaryHeight * 2) {
      temp.h = this.boundaryHeight;
      this.yIncrease /= 2;
    }
  }
  this.xIncrease = (temp.w / this.xIncrease);
  this.yIncrease = (temp.h / this.yIncrease);

// checking whether to flood or empty the room

  if (client.waterfilled = true) {
    this.filledWidth = min(this.waterWidth, this.filledWidth + this.xIncrease);
    this.filledHeight = min(this.waterHeight, this.filledHeight + this.yIncrease);
  }
  else {
    this.filledWidth = min(this.waterWidth, this.filledWidth - this.xIncrease);
    this.filledHeight = min(this.waterHeight, this.filledHeight - this.yIncrease);
  }
  updatePoly();
}

// drawing the polygon

function updatePoly() {
  temp.x = this.x + this.getWaterX();
  temp.y = this.y + this.getWaterY();
  this.showpoly(200, {temp.x, temp.y, temp.x + this.filledWidth, temp.y, temp.x + this.filledWidth, temp.y + this.filledHeight, temp.x, temp.y + this.filledHeight});
  this.changeimgcolors(200,0,0,1,0.75);
  this.changeimgvis(200,1);
}

function getWaterX() {
  return (this.waterWidth - this.filledWidth) / 2;
}

function getWaterY() {
  return (this.waterHeight - this.filledHeight) / 2;
}

Pages: 1 2 [3] 4 5 ... 10