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<0) setstring temp.output,#s(temp.output)-;
else if(temp.o<10) setstring 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>64) temp.roomwidth=64-temp.startx;
if(temp.starty+temp.roomheight>64) temp.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!