It may be a little bit silly to ask:
If I what to simplify statements using subroutine, for example:
(only MainLoop is shown for convenience)
@MainLoop {
SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 16);
if(frame%10==0&&frame>0) {
CreateShot01(GetX, GetY, 3, GetAngleToPlayer - 30, RED02, 0);
CreateShot01(GetX, GetY, 3, GetAngleToPlayer - 20, RED02, 0);
CreateShot01(GetX, GetY, 3, GetAngleToPlayer - 10, RED02, 0);
CreateShot01(GetX, GetY, 3, GetAngleToPlayer, RED02, 0);
CreateShot01(GetX, GetY, 3, GetAngleToPlayer + 10, RED02, 0);
CreateShot01(GetX, GetY, 3, GetAngleToPlayer + 20, RED02, 0);
CreateShot01(GetX, GetY, 3, GetAngleToPlayer + 30, RED02, 0);
}
frame++;
}
then I attempted to use the following statements:
#TouhouDanmakufu
#Title[... "..."]
#Text[Test script for subroutine]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
let ImgBoss = "script\img\ExRumia.png";
let frame = -120;
@Initialize {
SetLife(3000);
SetTimer(120);
SetScore(1000000);
SetDurableSpellCard();
SetDamageRate(50,0);
SetMovePosition02(GetCenterX, GetClipMinY+120, 120);
SetInvincibility(120);
Concentration01(120);
PlaySE(GetCurrentScriptDirectory~"SFX\Charge.wav");
CutIn(YOUMU, "... "\""..."\", "", 0, 0, 0, 0);
LoadGraphic(ImgBoss);
SetTexture(ImgBoss);
SetGraphicRect(0, 0, 64, 64);
}
@MainLoop {
SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 16);
if(frame%10==0&&frame>0) {
firebullets;
}
frame++;
}
@DrawLoop {
DrawGraphic(GetX, GetY);
}
@Finalize {
DeleteGraphic(ImgBoss);
}
}
sub firebullets{
CreateShot01(GetX, GetY, 3, GetAngleToPlayer - 30, RED02, 0);
CreateShot01(GetX, GetY, 3, GetAngleToPlayer - 20, RED02, 0);
CreateShot01(GetX, GetY, 3, GetAngleToPlayer - 10, RED02, 0);
CreateShot01(GetX, GetY, 3, GetAngleToPlayer, RED02, 0);
CreateShot01(GetX, GetY, 3, GetAngleToPlayer + 10, RED02, 0);
CreateShot01(GetX, GetY, 3, GetAngleToPlayer + 20, RED02, 0);
CreateShot01(GetX, GetY, 3, GetAngleToPlayer + 30, RED02, 0);
}
However, this is unsuccessful. I would like to ask that if we want to use subroutine/function/task, where should I put the sub{}/function(){}/task() block?
Also, when is the statement "yield;" used?
P.S. If I have some statements (such as background setting in a stage) to use, can I put the statements in a function in a new file, then I call them in the files I would like to apply to?