Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Bug Report (https://forums.graalonline.com/forums/forumdisplay.php?f=193)
-   -   Impossible Scripting Bug (https://forums.graalonline.com/forums/showthread.php?t=83867)

Tyhm 01-25-2009 04:41 AM

Impossible Scripting Bug
 
If I remove the testing code (drawmap in if(created)), I get a Floating Point error and it crashes the gorram editor.

How? Why? WTF?

UNFORTUNATELY MY SCRIPT IS TOO LONG FOR THIS FORUM, SO YOU CAN'T SEE IT. ALSO IT CONTAINS PERCENT SIGNS. SILLY ME.

PHP Code:

// NPC made by Tyhm
if (created) {
  
setarray this.board[],4096;//a 64 by 64 array
  
setarray this.doorlisting[],400;//Better too big...
  
this.failures=0;
  
drawmap(); //remove this line and it all collapses
}
if (
playerenters) {
  
placerooms();
  
placetunnels();
  
sleep 0.1;
  
drawmap();
}

function 
drawmap(){
  for(
temp.j=0;temp.j<64;temp.j++){
    
setstring temp.output,;
    for(
temp.n=0;temp.n<64;temp.n++){
      
temp.o=this.board[(temp.n*64)+temp.j];
      if(
temp.o<0setstring temp.output,#s(temp.output)-;
      
else if(temp.o<10setstring temp.output,#s(temp.output)#v(temp.o);
      
else if(temp.o in |75,99|) setstring temp.output,#s(temp.output)#K((99-temp.o)+97);
      
else setstring temp.output,#s(temp.output)#K(temp.o+55);
    
}
    
showtext temp.j,64,(temp.j*0.8)+5,Fixedsys,Normal,#s(temp.output);
    
changeimgvis temp.j,0;
  }
}

function 
placerooms(){
  
temp.startx=int(random(0,60));
  
temp.starty=int(random(0,60));
  
temp.roomheight=int(random(3,10));
  
temp.roomwidth=int(random(3,12));
  if(
temp.startx+temp.roomwidth>64temp.roomwidth=64-temp.startx;
  if(
temp.starty+temp.roomheight>64temp.roomheight=64-temp.starty;
  
this.failed=0;
  for(
temp.i=temp.startx-1;temp.i<temp.startx+temp.roomwidth+1&&this.failed<1;temp.i++){
    for(
temp.n=temp.starty-1;temp.n<temp.starty+temp.roomheight+1&&this.failed<1;temp.n++){
      if(
temp.i in |0,63| && temp.n in |0,63| && this.board[(temp.i*64)+temp.n]>0){
        
this.failures++;
        
this.failed=1;
      }
    }
  }
  if(
this.failed<1){
    
this.rooms++;
    
this.roomtype=99-(this.rooms-1);
    
//7;//change this if it's a LIT room
    //0-6: walls, 7-8: rooms, 9:passages...
    
for(temp.i=temp.startx;temp.i<temp.startx+temp.roomwidth;temp.i++){
      for(
temp.n=temp.starty;temp.n<temp.starty+temp.roomheight;temp.n++){
        
this.board[(temp.i*64)+temp.n]=this.roomtype;
      }
    }
    
this.doors=int(random(2,4));
    
this.perimeter=(temp.roomwidth*2)+(temp.roomheight*2);
    for(
temp.d=0;temp.d<this.doors;temp.d++){
      
temp.dpos=int(random(0,this.perimeter));
      if(
temp.dpos<temp.roomwidth*2){
        if(
temp.dpos<temp.roomwidth){
          
temp.doorpos=((temp.startx+temp.dpos)*64)+(temp.starty-1);
          
temp.dir=0;
        }else{
          
temp.doorpos=((temp.startx+(temp.dpos-temp.roomwidth))*64)+(temp.starty+temp.roomheight);
          
temp.dir=2;
        }
      } else {
        if(
temp.dpos<(temp.roomwidth*2)+temp.roomheight){
          
temp.doorpos=((temp.startx-1)*64)+(temp.starty+(temp.dpos-(temp.roomwidth*2)));
          
temp.dir=1;
        }else{
          
temp.doorpos=((temp.startx+temp.roomwidth)*64)+(temp.starty+temp.dpos-((temp.roomwidth*2)+temp.roomheight));
          
temp.dir=3;
        }
      }
      
//check for adjacent doors
      //and eliminate;
      //if under 2 doors for that room, decrement temp.d
      //also, eliminate doors facing Out
      
if(temp.doorpos<64||temp.doorpos>4031||temp.doorpos 

AND GODDAMN IT WOULD SOMEONE FIX THE PERCENT ERROR ALREADY!

Deas_Voice 01-25-2009 04:58 AM

you could use PHP tags, then you can scroll down if the script is too long, or u make it a textfile.

Tyhm 01-25-2009 05:04 AM

Too long in the sense that there's a 10000 character limit on posts for some retarded reason.

Tigairius 01-25-2009 05:22 AM

Although I'm not sure this will solve your problem, I believe arrays are declared like this in GS1:
PHP Code:

  setarray this.board,4096;//a 64 by 64 array
  
setarray this.doorlisting,400;//Better too big... 


maximus_asinus 01-25-2009 07:15 AM

I have no other reply for you other than: Firefly fan? NICE.

Tyhm 01-26-2009 01:40 AM

1 Attachment(s)
Loathe though I am to share my work, here's the dungeonator I've been building over the past month. Note that if you comment out the fourth line, it's a Floating Point Overflow. If you replace the subroutine call with the exact cut-and-pasted subroutine, it's a Floating Point Overflow...and if you replace the setarray etc[],etc; with setarray etc,etc; it only delays the Floating Point Overflow until you return to the editor. -_-
Not only that! If you copy drawmap() to drawmap2() in anticipation of a bait-and-switch, THAT causes a Floating Point Overflow too!


All times are GMT +2. The time now is 08:53 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.