2015-06-19 20:22:42

I am working on a piece of code, and this script has worked fine before. Now I added a new section with clases and such, and I get this really fucking weird error.
This is an include.
On line: 277 (2)
Line: }
Error: Expected data type

On line: 277 (2)
Line: }
Error: Instead found '<end of file>'

I have removed the path to the file, so don't be confused why file: isn't there.
Does anybody know what this error means? Expected data type?

----------
An anomaly in the matrix. An error in existence. A being who cannot get inside the goddamn box! A.K.A. Me.

2015-06-19 20:28:06

It would be better if you could paste the relevant piece of code, like the function or something because it's sort of hard to tell you if you just give the error.

2015-06-19 20:38:53

Okay, I'll do that, this is, however, a private piece of code, which will soon be part of private shareware.
And don't laugh at me for making all this shit classes.

Um? What the hell? I get this error when trying to post that.
was opened within itself, this is not allowed. And now I have to put a to make it let me post.

----------
An anomaly in the matrix. An error in existence. A being who cannot get inside the goddamn box! A.K.A. Me.

2015-06-19 20:40:16

What the! okay, it's stupid bb code interfearing with my typing.

----------
An anomaly in the matrix. An error in existence. A being who cannot get inside the goddamn box! A.K.A. Me.

2015-06-19 20:48:58 (edited by Lucas1 2015-06-19 20:49:50)

There's a tag which allows you to post code.
Put brackets in the place of underlines:
_code_
all your code
_/code_

2015-06-19 23:41:29

okay.

bool copsarehere=false,landerishere=false;
class heli
{
int x;
int loop;
timer releasetimer,movetimer;
heli()
{
releasetimer.pause();releasetimer.force(0);
movetimer.pause();movetimer.force(0);
}
int position()
{
return pool.play_2d("sounds/cop/helicopter_loop.ogg",playerx,0,this.x,30,true);
}
timer flyintimer;
int y=30;
bool coming=false;
void start()
{
this.x=random(0,boundary);
this.facing=random(1,2);
this.loop=this.position();
this.coming=true;
}
void fly_in()
{
if(this.y>10&&flyintimer.elapsed>=50)
{
y--;
pool.update_sound_2d(this.loop,this.x,y);
this.flyintimer.restart();
}
else this.coming=false;
}
int facing;
void move()
{
if(copsarehere==false) this.can_release=true;
if(this.facing==1)
{
if(this.x<0) this.facing++;
else
{
if(this.movetimer.elapsed>=60)
{
this.x--;
this.movetimer.restart();
}
}
}
else
{
if(this.x>boundary) this.facing--;
else
{
if(this.movetimer.elapsed>=60)
{
this.x++;
this.movetimer.restart();
}
}
}
pool.update_sound_2d(this.loop,this.x,this.y);
}
bool releasing=false,can_release=true;
int release()
{
releasing=true;
releasetimer.restart();
int tmp=pool.play_1d("sounds/cop/helicopter_release.ogg",playerx,this.x,false);
return pool.items[tmp].handle.length;
}
void dropit()
{
releasing=false;
can_release=false;
releasetimer.pause();releasetimer.force(0);
droplander(this.x);
}
}
class lander
{
int x,y=10, loop;
bool justreleased=true,landed=false;
timer falltimer;
lander(int x)
{
landerishere=true;
this.x=x;
}
void fall()
{
if(justreleased) {this.loop=pool.play_2d("sounds/cop/lander_loop.ogg",playerx,0,this.x,this.y,false);this.justreleased=false;}
if(this.y>0)
{
if(this.falltimer.elapsed>=100)
{
this.y--;
this.falltimer.restart();
pool.update_sound_2d(this.loop,this.x,this.y);
}
else
{
pool.destroy_sound(this.loop);
pool.play_1d("sounds/cop/lander_land.ogg",playerx,this.x,false);
this.landed=true;
landerishere=false;
this.spawn_cops();
}
}
}
void spawn_cops()
{
for(int i=1; i<5; i++)
{
cop tmp(random(this.x-10,this.x+10),i);
cops.insert_last(tmp);
}
copsarehere=true;
}
}
lander@[] lander_aray(1);
class cop
{
int hp,x,num,walkspeed,shootspeed;
timer walktimer,shoottimer;
cop(int x, int num)
{
this.num=num;
this.x=x;
this.hp=100;
this.walkspeed=random(230,400);
this.shootspeed=random(800,1600);
this.facing=random(1,2);
}
bool dead=false;
void hit(int damage)
{
if(this.jumping==jumping)
{
this.hp=this.hp-damage;
pool.play_1d("sounds/misc/bullet"+random(1,4)+".ogg",playerx,this.x);
if(this.hp<=0) this.die();
else pool.play_1d("sounds/cop/enemy/hit"+num+".ogg",playerx,this.x,false);
}
else return;
}
void die()
{
pool.play_1d("sounds/cop/enemy/die"+num+".ogg",playerx,this.x,false);
this.dead=true;
}
void shoot()
{
this.shoottime=random(800,1600);
pool.play_1d("sounds/cop/enemy/shoot"+num+".ogg",playerx,this.x,false);
if(this.inrange()==true)
{
pool.play_stationary("sounds/misc/bullet"+random(1,4)+".ogg",false);
playerhp=playerhp-random(5,15);
}
}
bool inrange()
{
if(this.facing==1&&playerx>=(this.x-5)&&playerx<=this.x) return true;
else if(this.facing==2&&playerx<=(this.x+5)&&playerx>=this.x) return true;
else return false;
}
timer jumptimer;
bool jumping=false;
int facing;
void jump()
{
this.jumping=true;
pool.play_1d("sounds/steps/jump.ogg",playerx,this.x,false);
this.airmovetimer.restart();
}
timer airmovetimer;
void check()
{
if(this.jumping==false)
{
if(this.shoottimer.elapsed>=this.shoottime) this.shoot();
if(this.x>playerx&&this.walktimer.elapsed>=this.walkspeed)
{
this.walktimer.restart();
this.x--;
this.facing=1;
pool.play_1d("sounds/steps/step"+random(1,20)+".ogg",playerx,this.x,false);
}
else if(this.x<playerx&&this.walktimer.elapsed>=this.walkspeed)
{
this.x++;
this.facing=2;
this.walktimer.restart();
pool.play_1d("sounds/steps/step"+random(1,20)+".ogg",playerx,this.x,false);
}
else if(this.x==playerx)
{
this.jumptimer.restart();
this.jump();
}
}
if(this.jumping==true)
{
if(this.jumptimer.elapsed>=1000)
{
this.jumping=false;
pool.play_1d("sounds/steps/land"+random(1,5)+".ogg",playerx,this.x,false);
}
else
{
if(this.x<playerx&&this.airmovetimer.elapsed>=random(60,100))
{
this.airmovetimer.restart();
this.x--;
this.facing=2;
}
else if(this.x>playerx&&this.airmovetimer.elapsed>=random(60,100))
{
this.x++;
this.facing=1;
this.airmovetimer.restart();
}
}
}
}
}
cop@[] cops;
void droplander((int x)
{
lander l(x);
lander_aray.insert_last(l);
return;
}
void landercheck()
{
if(lander_aray.is_empty==false)
{
if(lander[0].landed==true)
{
lander_aray.remove_at(0);
landerishere=false;
}
else
{
lander[0].fall();
}
}
}
void copcheck()
{
if(cops.length==0)
{
copsarehere=false;
return;
}
for(int i=0; i<cops.length; i++)
{
if(cops[i].dead==true)
{
cops.remove_at(i);
continue;
}
cops[i].check();
}
}
heli copter;
void helistuff()
[
copter.move();
if(copter.releasetimer.elapsed>=5068)
{
copter.dropit();
}
}
----------
An anomaly in the matrix. An error in existence. A being who cannot get inside the goddamn box! A.K.A. Me.

2015-06-19 23:54:54

The opening brace of the helistuff function is actually a bracket. Taht's probably why.

2015-06-20 01:36:14

Yes coltonhill01, that error has something to do with your braces being missmatched. This happens often to all coders if your not extreamily carefull. It is the most annoying error one can get, well aside from non termonated string literal. Usually it says unexpected end of file or unexpected, but sence your dealing with classes that text just changes.

I am a web designer, and a game developer. If you wish see me at http://www.samtupy.com

2015-06-20 02:45:43

I hate how my shift key will type a bracket or an apostrophe instead of a brace or quote.

----------
An anomaly in the matrix. An error in existence. A being who cannot get inside the goddamn box! A.K.A. Me.

2015-06-20 09:38:25

Lol, I used to have that stupid issue quite a while ago with an old junky keyboard I had, and it was annoying because i'd get dash instead of underline, bracket instead of brase, tick instead of quote, etc. It was very annoying, lol.

I am a web designer, and a game developer. If you wish see me at http://www.samtupy.com

2015-06-29 09:04:01

turns out that wasn't the error, I think I forgot my right parenthesis in an array insert function or some shit! I just know the thing really wanted a data type, so it gobbled up the stuff and looked for a data type, or in my case, a right parenthesis. But, answer me this. Why doesn't it say, expected right parenthesis? I mean, there's a semicolon there! Just goes to shoe you how crappy the error generator is once you get into complex code. Non terminated string litteral! Gaah!

----------
An anomaly in the matrix. An error in existence. A being who cannot get inside the goddamn box! A.K.A. Me.

2015-06-30 06:29:12

What I do when I have errors like these:
- Copy my code into another file, usually just debug.txt
- Run a script to check for mismatched parentheses, brackets and braces. It also counts quotes:
https://www.sendspace.com/file/m51ygr
- Cut chunks of code from debug.txt, and run the matcher again, until it points me to the right section. This is sorta like Binary Search, except faster, because you can usually guess which parts you changed or where you might have gotten confused.
- If the problem is an odd number of quotes, things get a little more annoying. Generally, I isolate it as much as I can, then use notepad's find feature (f3 or ctrl+f) to find quotes. I Basically have it search twice, check to be sure that the quote it landed on ends a string, then repeat. This sounds a lot slower than it is; once you realize that most of your closing quotes will be followed by plus, comma, semicolons, parentheses or braces, it gets pretty easy to spot *most* unclosed strings.
- Copy the error to the clipboard, go find it in the main code, fix.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.