Graal Pastebin

New Paste
Pasted on November 6, 2011.
View the raw file

 
function onActionserverside() {
  switch (params[0]) {
    case "placetiles":
      this.conv_swidth = params[1];
      this.conv_placex = params[2];
      this.conv_placey = params[3];
      this.conv_stiles = params[4];
      for (this.conv_i = 0; this.conv_i < this.conv_stiles.size(); this.conv_i++)
        tiles[this.conv_placex + this.conv_i % this.conv_swidth, this.conv_placey + int(this.conv_i / this.conv_swidth)] = this.conv_stiles[this.conv_i];
      updateterrain(); 
      updateboard2(this.conv_placex, this.conv_placey, this.conv_swidth, this.conv_stiles.size() / this.conv_swidth);
 
    break;
  }
}
 
//#CLIENTSIDE
function onCreated() {  
  resetVariables();
  updateterrain();
}
 
function resetVariables()
{
  enum key
  {
    F4 = 115
  };
}  
 
function onKeyPressed( code, key )
{
  switch ( temp.code )
  {
    case key.F4: 
    if (this.conv_on == nil) {
      updateterrain();
      client.editinglevel = nil;
      this.conv_on = 1;
      this.conv_hidden = 0;
      this.conv_tcx = screenwidth - 300;
      this.conv_tcy = screenheight - 300;
      this.conv_alocs = {this.conv_tcx, this.conv_tcy + 16, this.conv_tcx + 16, this.conv_tcy, this.conv_tcx, this.conv_tcy + 256, this.conv_tcx + 256, this.conv_tcy};
      setstring this.conv_tiles, ;
      showtiles();
      showarrows();
   }else{
    player.chat = "";
    this.conv_on = 0;
    hideimgs 200, 211;
    setstring this.conv_tiles, ; 
   }    
   break;
  }
}
 
function onPlayerChats() {
  if (player.chat == "/hide") {
    if (this.conv_on == true) {
      player.chat = "";
      hideimgs(200, 210);
      this.conv_hidden = 1;
    }
  }
  elseif (player.chat == "update level") {
    updateterrain();
  }
  elseif (player.chat == "/show") {
    if (this.conv_on == true) {
      player.chat = "";
      showtiles();
      showarrows();
      this.conv_hidden = 0;
    }
  }
  elseif (player.chat == "/reset") {
    if (this.conv_on == true) {
      if (this.conv_hidden == 0) {
        player.chat = "";
        this.conv_tcx = screenwidth - 272;
        this.conv_tcy = screenheight - 272;
        this.conv_alocs = {this.conv_tcx, this.conv_tcy + 16, this.conv_tcx + 16, this.conv_tcy, this.conv_tcx, this.conv_tcy + 256, this.conv_tcx + 256, this.conv_tcy};
        showtiles();
        showarrows();
      }
    }
  }
}
 
function onMousedown(button) {
  if (this.conv_on == true) {
    if (button == "left") {
      updateterrain();
      if (this.conv_hidden == 0) {
        if (mousescreenx in | this.conv_tcx, this.conv_tcx + 271 | && mousescreeny in | this.conv_tcy, this.conv_tcy + 271 | ) {
          for (this.conv_i = 0;this.conv_i < 4;this.conv_i++) {
            if (mousescreenx in | this.conv_alocs[this.conv_i*2], this.conv_alocs[this.conv_i*2] + 15 | && mousescreeny in | this.conv_alocs[this.conv_i*2 + 1], this.conv_alocs[this.conv_i*2 + 1] + 15 | ) {
              if (this.conv_tx + vecx(this.conv_i) in | 0, 112 | ) {
                this.conv_tx += vecx(this.conv_i);
              }
              if (this.conv_ty + vecy(this.conv_i) in | 0, 16 | ) {
                this.conv_ty += vecy(this.conv_i);
              }
              showtiles();
              showarrows();
            }
          }
          if (mousescreenx in | this.conv_tcx + 16, this.conv_tcx + 271 | && mousescreeny in | this.conv_tcy + 16, this.conv_tcy + 271 | ) {
            this.conv_mx1 = int((mousescreenx - this.conv_tcx - 16) / 16);
            this.conv_my1 = int((mousescreeny - this.conv_tcy - 16) / 16);
            this.conv_mousedown = 1;
            setTimer(0.05);
          }
          elseif (mousescreenx in | this.conv_tcx, this.conv_tcx + 15 | && mousescreeny in | this.conv_tcy, this.conv_tcy + 15 | ) {
            this.conv_cornerclickx = this.conv_tcx - mousescreenx;
            this.conv_cornerclicky = this.conv_tcy - mousescreeny;
            this.conv_mousedown = 3;
            setTimer(0.05);
          }
          elseif (mousescreenx in | this.conv_tcx + 32, this.conv_tcx + 255 | && mousescreeny in | this.conv_tcy, this.conv_tcy + 15 | ) {
            if (int((1 - ((this.conv_tcx + 255) - mousescreenx)) / 2) + 112 in | 0, 112 | ) {
              this.conv_tx = int((1 - ((this.conv_tcx + 255) - mousescreenx)) / 2) + 112;
              showtiles();
              showarrows();
            }
          }
          elseif (mousescreenx in | this.conv_tcx, this.conv_tcx + 15 | && mousescreeny in | this.conv_tcy + 32, this.conv_tcy + 255 | ) {
            if (int((16 - ((this.conv_tcy + 255) - mousescreeny)) / 13) + 16 in | 0, 16 | ) {
              this.conv_ty = int((16 - ((this.conv_tcy + 255) - mousescreeny)) / 13) + 16;
              showtiles();
              showarrows();
            }
          }
        } else {
          this.conv_mx1 = int(mousex);
          this.conv_my1 = int(mousey);
          this.conv_mousedown = 2;
          setstring this.conv_tiles, ;
          setTimer(0.05);
        }
      } else {
        this.conv_mx1 = int(mousex);
        this.conv_my1 = int(mousey);
        this.conv_mousedown = 2;
        setstring this.conv_tiles, ;
        setTimer(0.05);
      }
    }
    if (button == "right") {
      if (this.conv_tiles.size() > 0) {
        updateterrain();
        client.editinglevel = player.level.name;
        triggerserver("gui", this.name, "placetiles", this.conv_twidth, int(mousex), int(mousey), this.conv_tiles);
      }
    }
  }
}
 
 
 
function onTimeout() {
 
  if (this.conv_on == 1) {
    setTimer(0.05);
    if (this.conv_mousedown == true) {
      if (mousescreenx in | this.conv_tcx + 16, this.conv_tcx + 271 | && mousescreeny in | this.conv_tcy + 16, this.conv_tcy + 271 | ) {
        this.conv_mx2 = int((mousescreenx - this.conv_tcx - 16) / 16);
        this.conv_my2 = int((mousescreeny - this.conv_tcy - 16) / 16);
      }
      if (this.conv_mx1 <= this.conv_mx2) {
        this.conv_xoff1 = 0;
        this.conv_xoff2 = 1;
      } else {
        this.conv_xoff1 = 1;
        this.conv_xoff2 = 0;
      }
      if (this.conv_my1 <= this.conv_my2) {
        this.conv_yoff1 = 0;
        this.conv_yoff2 = 1;
      } else {
        this.conv_yoff1 = 1;
        this.conv_yoff2 = 0;
      }
      showpoly(210, {
                 this.conv_tcx + 16 + (this.conv_mx1 + this.conv_xoff1)*16, this.conv_tcy + 16 + (this.conv_my1 + this.conv_yoff1)*16,
                 this.conv_tcx + 16 + (this.conv_mx1 + this.conv_xoff1)*16, this.conv_tcy + 16 + (this.conv_my2 + this.conv_yoff2)*16,
                 this.conv_tcx + 16 + (this.conv_mx2 + this.conv_xoff2)*16, this.conv_tcy + 16 + (this.conv_my2 + this.conv_yoff2)*16,
                 this.conv_tcx + 16 + (this.conv_mx2 + this.conv_xoff2)*16, this.conv_tcy + 16 + (this.conv_my1 + this.conv_yoff1)*16
               });
      changeimgvis(210, 7);
      changeimgcolors(210, .75, .75, .75, .25);
      if (!leftmousebutton) {
        this.conv_mousedown = 0;
        hideimg(210);
        if (this.conv_mx1 < this.conv_mx2) {
          this.conv_tlx = this.conv_mx1;
          this.conv_blx = this.conv_mx2;
        } else {
          this.conv_tlx = this.conv_mx2;
          this.conv_blx = this.conv_mx1;
        }
        if (this.conv_my1 < this.conv_my2) {
          this.conv_tly = this.conv_my1;
          this.conv_bly = this.conv_my2;
        } else {
          this.conv_tly = this.conv_my2;
          this.conv_bly = this.conv_my1;
        }
        this.conv_tiles = "";
        this.conv_twidth = this.conv_blx - (this.conv_tlx - 1);
        this.conv_selected = this.conv_twidth * (this.conv_bly - (this.conv_tly - 1));
        for (this.conv_i = 0;this.conv_i < this.conv_selected;this.conv_i++) {
          this.conv_tiles.add(((this.conv_tx + this.conv_tlx + (this.conv_i % this.conv_twidth)) % 16) + ((this.conv_ty + this.conv_tly + (int(this.conv_i / this.conv_twidth)))*16) + int((this.conv_tx + this.conv_tlx + (this.conv_i % this.conv_twidth)) / 16)*512);
        }
      }
    }
    elseif (this.conv_mousedown == 2) {
      this.conv_mx2 = int(mousex);
      this.conv_my2 = int(mousey);
      if (this.conv_mx1 <= this.conv_mx2) {
        this.conv_xoff1 = 0;
        this.conv_xoff2 = 1;
      } else {
        this.conv_xoff1 = 1;
        this.conv_xoff2 = 0;
      }
      if (this.conv_my1 <= this.conv_my2) {
        this.conv_yoff1 = 0;
        this.conv_yoff2 = 1;
      } else {
        this.conv_yoff1 = 1;
        this.conv_yoff2 = 0;
      }
      showpoly(210, {
                 this.conv_mx1 + this.conv_xoff1, this.conv_my1 + this.conv_yoff1,
                 this.conv_mx1 + this.conv_xoff1, this.conv_my2 + this.conv_yoff2,
                 this.conv_mx2 + this.conv_xoff2, this.conv_my2 + this.conv_yoff2,
                 this.conv_mx2 + this.conv_xoff2, this.conv_my1 + this.conv_yoff1,
               });
      changeimgvis(210, 3);
      changeimgcolors(210, .75, .75, .75, .25);
      if (!leftmousebutton) {
        this.conv_mousedown = 0;
        hideimg(210);
        if (this.conv_mx1 < this.conv_mx2) {
          this.conv_tlx = this.conv_mx1;
          this.conv_blx = this.conv_mx2;
        } else {
          this.conv_tlx = this.conv_mx2;
          this.conv_blx = this.conv_mx1;
        }
        if (this.conv_my1 < this.conv_my2) {
          this.conv_tly = this.conv_my1;
          this.conv_bly = this.conv_my2;
        } else {
          this.conv_tly = this.conv_my2;
          this.conv_bly = this.conv_my1;
        }
        this.conv_tiles = "";
        this.conv_twidth = this.conv_blx - (this.conv_tlx - 1);
        this.conv_selected = this.conv_twidth * (this.conv_bly - (this.conv_tly - 1));
        for (this.conv_i = 0;this.conv_i < this.conv_selected;this.conv_i++) {
          this.conv_tiles.add(tiles[this.conv_tlx + (this.conv_i % this.conv_twidth), this.conv_tly + (int(this.conv_i / this.conv_twidth))]);
        }
      }
    }
    elseif (this.conv_mousedown == 3) {
      this.conv_tcx = mousescreenx + this.conv_cornerclickx;
      this.conv_tcy = mousescreeny + this.conv_cornerclicky;
      this.conv_alocs = {this.conv_tcx, this.conv_tcy + 16, this.conv_tcx + 16, this.conv_tcy, this.conv_tcx, this.conv_tcy + 256, this.conv_tcx + 256, this.conv_tcy};
      showtiles();
      showarrows();
      if (!leftmousebutton) {
        this.conv_mousedown = 0;
      }
    }
    if (this.conv_tiles.size() > 0) {
      showpoly(211, {
                 int(mousex), int(mousey),
                 int(mousex) + this.conv_twidth, int(mousey),
                 int(mousex) + this.conv_twidth, int(mousey) + sarraylen(this.conv_tiles) / this.conv_twidth,
                 int(mousex), int(mousey) + sarraylen(this.conv_tiles) / this.conv_twidth
               });
      changeimgcolors(211, .75, .75, .75, .25);
    } else {
      hideimg(211);
    }
  } else {
    this.conv_mousedown = 0;
  }
}
function showtiles() {
  showpoly(200, {
             this.conv_tcx, this.conv_tcy,
             this.conv_tcx + 287, this.conv_tcy,
             this.conv_tcx + 287, this.conv_tcy + 287,
             this.conv_tcx, this.conv_tcy + 287
           });
  showpoly(201, {
             this.conv_tcx + 16, this.conv_tcy + 16,
             this.conv_tcx + 271, this.conv_tcy + 16,
             this.conv_tcx + 271, this.conv_tcy + 271,
             this.conv_tcx + 16, this.conv_tcy + 271
           });
  if (this.conv_tx < 48) {
    this.conv_moffset = 256;
  }
  if (this.conv_tx in | 48, 64 | ) {
    this.conv_moffset = (64 - this.conv_tx) * 16;
  }
  if (this.conv_tx > 64) {
    this.conv_moffset = 0;
  }
  if (this.conv_tx < 64) {
    showimg(202, gettileset(), this.conv_tcx + 16, this.conv_tcy + 16);
    changeimgpart(202, this.conv_tx*16, this.conv_ty*16, 256, 256);
  } else {
    hideimg(202);
  }
  if (this.conv_tx > 48) {
    showimg(203, gettileset(), this.conv_tcx + 16 + this.conv_moffset, this.conv_tcy + 16);
    changeimgpart(203, (this.conv_tx)*16 + this.conv_moffset, this.conv_ty*16, 256 - this.conv_moffset, 256);
    changeimgvis(203, 6);
  } else {
    hideimg(203);
  }
  changeimgcolors(200, 0, 0, 0, 1);
  changeimgvis(200, 4);
  changeimgvis(201, 5);
  changeimgvis(202, 6);
}
function showarrows() {
  showpoly(204, {
             this.conv_tcx + 15, this.conv_tcy + 31,
             this.conv_tcx, this.conv_tcy + 31,
             this.conv_tcx + 8, this.conv_tcy + 16
           });
  showpoly(205, {
             this.conv_tcx + 15, this.conv_tcy + 256,
             this.conv_tcx, this.conv_tcy + 256,
             this.conv_tcx + 8, this.conv_tcy + 271
           });
  showpoly(206, {
             this.conv_tcx + 31, this.conv_tcy + 15,
             this.conv_tcx + 31, this.conv_tcy,
             this.conv_tcx + 16, this.conv_tcy + 8
           });
  showpoly(207, {
             this.conv_tcx + 256, this.conv_tcy + 15,
             this.conv_tcx + 256, this.conv_tcy,
             this.conv_tcx + 271, this.conv_tcy + 8
           });
  showpoly(208, {
             this.conv_tcx + 31 + this.conv_tx*2, this.conv_tcy,
             this.conv_tcx + 31 + this.conv_tx*2, this.conv_tcy + 15,
             this.conv_tcx + 32 + this.conv_tx*2, this.conv_tcy + 15,
             this.conv_tcx + 32 + this.conv_tx*2, this.conv_tcy
           });
  showpoly(209, {
             this.conv_tcx, this.conv_tcy + 33 + this.conv_ty*13,
             this.conv_tcx + 15, this.conv_tcy + 33 + this.conv_ty*13,
             this.conv_tcx + 15, this.conv_tcy + 46 + this.conv_ty*13,
             this.conv_tcx, this.conv_tcy + 46 + this.conv_ty*13
           });
  for (this.conv_i = 0;this.conv_i < 6;this.conv_i++) {
    changeimgvis(204 + this.conv_i, 6);
  }
}
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • 334
  • 335
  • 336
  • 337
  • 338
  • 339
  • 340
  • 341
  • 342
  • 343
  • 344
  • 345
  • 346
  • 347
  • 348
  • 349
  • 350
  • 351
  • 352
  • 353
  • 354
  • 355
  • 356
  • 357
  • 358
  • 359
  • 360
  • 361
  • 362
  • 363
  • 364
  • 365
  • 366
  • 367
  • 368
  • 369
  • 370