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 6 ... 10
 31 
 on: August 19, 2017, 04:40:11 PM 
Started by maximus_asinus - Last post by maximus_asinus
I get asked about 3 times a day. I now understand your struggle, Thor.

 32 
 on: August 18, 2017, 01:30:31 PM 
Started by maximus_asinus - Last post by Thor
Seems awkward to post about this here unless it's specific to Classic.

I posted a reply at http://forums.graalonline.com/forums/showthread.php?p=1741824#post1741824

 33 
 on: August 17, 2017, 10:36:43 PM 
Started by maximus_asinus - Last post by maximus_asinus
Quick update:

I went back and tried public function again after reading a post by fp4 and got something that ALMOST works.

CLASS A
Code: [Select]
//#CLIENTSIDE
function onActionAHPhit() { // custom sword hit detection
  temp.foobar = this.level.foobar;
  temp.foobar.baz();
}
 
CLASS B
Code: [Select]
//#CLIENTSIDE
function onCreated() {
  this.setimg("block.png");
  this.level.foobar = this;
}
public function baz() {
  this.chat = "debug";
}

The problem is only the last NPC to join Class B will receive the update. If I could get around that I would be all set.

 34 
 on: August 17, 2017, 06:28:46 PM 
Started by maximus_asinus - Last post by maximus_asinus
Maybe you can answer me. This my post from the other forums:

Quote
is it possible for two classes to communicate?

My example:

In the first class I have a switch that the player interacts with by swinging the sword. This class is supposed to tell the second class that it was hit. In the second class I have blocks that raise or lower depending on the status of the switch.

I can do a hack solution like a check in a looping timeout but I feel like this can be done with a trigger, and I don't want to use triggeraction if I have 20 different blocks. Want to make something that will allow me to just drag-and-drop these for the most part.

 35 
 on: August 15, 2017, 11:20:16 PM 
Started by maximus_asinus - Last post by maximus_asinus
Also can you explain how attachplayertoobj works online?

Offline if I use attachplayertoobj it acts as if the player is on a layer above the tileset and ignores blocking tiles. In combination with setshape2 I can make blocking tiles swimmable.

Code: [Select]
if (created) {
  setshape2 2,2,{11,11,11,11};
}
if (playertouchsme) {
  attachplayertoobj 0,id;
}

With the same script (updated to GS2 obviously) the tiles are still swimmable but it doesn't put me on that separate layer.

Code: [Select]
//#CLIENTSIDE
function onCreated() {
setshape2(2,2,{11,11,11,11});
}
function onPlayerTouchsMe() {
attachplayertoob(0, id);
}

And again, thanks for your patience. I am learning a lot from what you've shown me so far. I appreciate the help.

 36 
 on: August 15, 2017, 10:01:42 PM 
Started by maximus_asinus - Last post by maximus_asinus
Okay I've run what you gave me and it works, though it looks a bit odd when you're flooding in long skinny sections. Also how would you handle two intersecting flows of water? I am demoing in an L shaped room and want to flood both sections. Here is a demo of what I am talking about.

https://www.youtube.com/watch?v=cj6dqNfGnMw

I'm assuming it was luck that they came together at the same time.

Could this be done with one source of water instead of adding multiple?





 37 
 on: August 15, 2017, 06:12:23 PM 
Started by maximus_asinus - Last post by Thor
After testing your script visually it only works for square shapes. How would I go about doing other shapes? Like a rectangle? Maybe I am not understanding this script, but it seems very limited.

All this code does is handle the drawing of the polygon based on the water-filled area compared with the total flood-able area, but it can and does work for rectangular areas too, rectangles just require specific math to increment the filled area as the filled width and height would not increment evenly.

When raising the water I increment the areas like so:

Code: [Select]
  temp.w = this.waterWidth - (this.boundaryWidth * 2);
  temp.h = this.waterHeight - (this.boundaryWidth * 2);
  temp.xIncrease = 50;
  temp.yIncrease = 50;

  if (this.boundaryWidth > 0) {

    if (this.waterWidth - this.filledWidth <= this.boundaryWidth * 2) {
      temp.w = this.boundaryWidth;
      temp.xIncrease /= 2;
    }

    if (this.waterHeight - this.filledHeight <= this.boundaryWidth * 2) {
      temp.h = this.boundaryWidth;
      temp.yIncrease /= 2;
    }

  }
  temp.xIncrease = (temp.w / temp.xIncrease);
  temp.yIncrease = (temp.h / temp.yIncrease);
  this.filledWidth = min(this.waterWidth, this.filledWidth + temp.xIncrease);
  this.filledHeight = min(this.waterHeight, this.filledHeight + temp.yIncrease);
  this.updatePoly();

(Boundary width would be the walled area on the outermost tiles of a fill area, where I have the water raise more slowly)

 38 
 on: August 15, 2017, 05:01:11 PM 
Started by maximus_asinus - Last post by maximus_asinus
After testing your script visually it only works for square shapes. How would I go about doing other shapes? Like a rectangle? Maybe I am not understanding this script, but it seems very limited.

 39 
 on: August 13, 2017, 08:10:57 PM 
Started by maximus_asinus - Last post by maximus_asinus
Also thanks for replying. I have no scripting experience outside GS1, and it is very frustrating coming against hurdles when there is nobody else willing to help out. It isn't likely I will solve this on my own.

 40 
 on: August 13, 2017, 07:36:06 PM 
Started by maximus_asinus - Last post by maximus_asinus
I should have been clear that what I posted was the formula I based the water movement on. This is my original script.

Code: [Select]
//#CLIENTSIDE
function onCreated() {
this.setimg("block.png");
}
function onActionPulled() {
    if (this.waterlevel == 0) {
  this.final = {9,39,47,39,47,27,55,27,55,47,9,47}; // x, y values of where the water starts filling
    this.current = {11,41,49,41,49,29,53,29,53,45,11,45}; // x, y values where the water is finished filling
    }
    else if (this.waterlevel == 1) {
  this.final = {11,41,49,41,49,29,53,29,53,45,11,45};
    this.current ={9,39,47,39,47,27,55,27,55,47,9,47}; 

    }
    this.time = 0;
    this.waterlevel = !this.waterlevel;
    setTimer(0.05);
}
function onTimeout() {
    for (this.a=0;this.a<=this.final.size();this.a++;) {
      this.distx = this.final[0+this.a] - this.current[0+this.a]; // finds the difference between the coordinates in both arrays
      this.disty = this.final[1+this.a] - this.current[1+this.a];
      this.movelength = (this.distx * this.distx + this.disty * this.disty) ^ 0.5; // finds out how many tiles away
      this.distx = this.distx / this.movelength;
      this.disty = this.disty / this.movelength;
      this.current[0+this.a] = this.current[0+this.a] + this.distx * 0.05; // move a step towards the final target
      this.current[1+this.a] = this.current[1+this.a] + this.disty * 0.05;
      showpoly(200,this.current);
      changeimgcolors 200,0,0,1,0.75;
      this.a++;
    }
    setTimer(0.05);
  }
}

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