~Hakurei Shrine~ > Rika and Nitori's Garage Experiments
Stage Creation Question(s)
(1/2) > >>
Naut:
I'll be posting here when I have questions regarding stage creation scripts in Danmakufu. Feel free to post your own, so we don't clutter the board with questions regarding the same topic.

Here's a relatively easy question to start us off. I'm making a stage, and none of the damn enemies will spawn. I have no idea what I've done wrong, but I know it's gonna be something simple like "lol you left out ; here".

Here's the Stage Script:


--- Code: ---#?????e????[Stage]
#Title[Lala Stage]
#Text[Lalalala.]
#Image[]
#BackGround[User(.\PIC\black.png, 1, 1)]
#Player[FREE]
#ScriptVersion[2]

script_stage_main
{
        let BlueEnemy = GetCurrentScriptDirectory~"PIC\BlueEnemy.txt";
        let imgEnemy = GetCurrentScriptDirectory~"PIC\Fairy.png";
       
task StageTask{

                function Wait(let frames){
loop(frames){yield;}
}
                function WaitForZeroEnemy{
while(GetEnemyNum() != 0){yield;}
}

                Wait(30);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"PIC\BlueEnemy.txt", 30, 120, 0, 0, 0);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"PIC\BlueEnemy.txt", 20, 120, 0, 0, 0);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"PIC\BlueEnemy.txt", 10, 120, 0, 0, 0);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"PIC\BlueEnemy.txt", 418, 120, 0, 0, 0);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"PIC\BlueEnemy.txt", 428, 120, 0, 0, 0);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"PIC\BlueEnemy.txt", 438, 120, 0, 0, 0);
                WaitForZeroEnemy;
                Wait(60);
                Clear;
}

@Initialize()
{
                LoadGraphic(imgEnemy);
                StageTask;
}

@MainLoop()
{
                yield;
}

@Finalize()
{
                DeleteGraphic(imgEnemy);
}

}

--- End code ---

And the enemy I'm trying to spawn, "BlueEnemy.txt", located in the PIC directory:

--- Code: ---script_enemy_main
{

let imgEnemy = GetCurrentScriptDirectory~"Fairy.png";
let destroy = 1;
let drawcounter = 0;
let frame = 0;
let v = 0;
let angle = 0;

@Initialize{
Concentration01(10);
SetLife(14);
}

@Mainloop{
    SetCollisionA(GetX, GetY, 16);
    SetCollisionB(GetX, GetY, 8);
frame++;

if(frame%12==0){
loop(5){
loop(7){
CreateShot01(GetX, GetY, v, GetAngleToPlayer + angle, BLUE21, 0);
v+=0.7;
}
v = 1;
angle += 360/5;
}
angle = 0;
}

}

@Drawloop{
drawcounter++;
SetTexture(imgEnemy);
SetRenderState(ALPHA);
SetAlpha(255);
//Blue Fairy drawing information.
if(drawcounter%9==1 || drawcounter%9==2 || drawcounter%9==3){
if(GetSpeedX()==0){SetGraphicRect(0, 0, 31, 31);}
else if(GetSpeedX()>0){SetGraphicRect(160, 32, 191, 63);}
else if(GetSpeedX()<0){SetGraphicRect(0, 32, 31, 63);}
}
if(drawcounter%9==4 || drawcounter%9==5 || drawcounter%9==6){
if(GetSpeedX()==0){SetGraphicRect(32, 0, 63, 31);}
else if(GetSpeedX()>0){SetGraphicRect(192, 32, 223, 63);}
else if(GetSpeedX()<0){SetGraphicRect(32, 32, 63, 63);}
}
if(drawcounter%9==7 || drawcounter%9==8 || drawcounter%9==0){
if(GetSpeedX()==0){SetGraphicRect(64, 0, 95, 31);}
else if(GetSpeedX()>0){SetGraphicRect(224, 32, 255, 63);}
else if(GetSpeedX()<0){SetGraphicRect(64, 32, 63, 95);}
}
DrawGraphic(GetX, GetY);
}

@Finalize{
if(destroy==1){
loop(2){
CreateItem(ITEM_SCORE, GetX + rand(-20, 20), GetY + rand(-20, 20));
}
}
}
}

--- End code ---

Doesn't spawn the enemy, Reimu_A won't even lock in on anything. I know the enemy doesn't move, I just want it to spawn at this point.
Stuffman:
I'm stumped! I tried putting debug strings in there and adding a drawloop to show what part of the script it's in but nothing shows up!
Naut:
Well fuck.

Here's a .rar in case I copied something incorrectly.
Nuclear Cheese:

--- Quote from: Naut on April 29, 2009, 01:37:01 AM ---Well fuck.

Here's a .rar in case I copied something incorrectly.

--- End quote ---

The enemies are dissapearing immediately.  Hang on, I'm investigating.


EDIT: Figured it out.

Please try to remain calm and not hate yourself for this. ;)



In your enemy script (BlueEnemy.txt), you have @MainLoop and @DrawLoop improperly capitalized.

Danmakufu, like C, is case-sensitive.
Unfortunately, Danmakufu also will silently fail if you're missing one of the main functions, since it just assumes that you didn't want it.

So your script should work fine if you correct the capitalization.


As a programmer, I know how frustrating these little typos can be, since you'll look over them hundreds of times without noticing.  Then when you do notice, you want to smack yourself. :P
Happens to me all the time.
Naut:
Figures. I knew it was something so small... I would've never noticed that, thanks a billion. Wish Danmakufu would've flagged it in an error message. However cryptic they may be, it's always more helpful than the nothing this yielded.
Navigation
Message Index
Next page

Go to full version