~Hakurei Shrine~ > Rika and Nitori's Garage Experiments

Some noobish questions

Pages: << < (4/6) > >>

Cyclone722:


--- Code: ---loop(20){
         CreateShot01(x, y, 3, angle, BLUE50, 0);
wait(5);
         CreateShot01(x, y, 3, angle, BLUE50, 0);
wait(5);
         CreateShot01(x, y, 3, angle, BLUE50, 0);
                 wait(100);

--- End code ---
Should it look something like this...? I get an error.
(this isn't the complete attack, just the part I need to wait on)

Iryan:

Ummm... did you put this exact code in your main loop..?
Then it would be no surprise that it didn't work.

"wait(5);" is not a real command. The proper way to type it out is "loop(5){ yield; }", and it only works correctly if you use it inside a task.

If you want to handle this three-ring-burst in your main loop, your best bet would be to create a timer variable called frame or something, then put this in your main loop:


--- Code: ---frame++;
if(frame==60||frame==65||frame==70){
    ---Code-That-Makes-A-Ring---
}
if(frame==120) { frame=0; }
--- End code ---

The timer variable is increased every frame. If the value of it is 60, 65 or 70, a ring of your desired kind will be shot. If the timer reaches 120, it will reset to zero.

Naut:

Drake is getting lazier and lazier nowadays....

Anywho, what he means is make a task and have it loop yield; a few times to wait frames before doing something else. "Wait(x);" isn't actually a command that you can use, rather a function that most people create when throwing together stage scripts. Helps others know what's going on.

The code he means would look something like this:


--- Code: ---script_enemy_main{

 task ShotBurst(let x, let y, let angle){
   CreateShot01(x, y, 3, angle, BLUE50, 0);
   loop(10){yield;}  //This pauses the task for ten frames. Will only work if you also have "yield;" in @MainLoop.
   CreateShot01(x, y, 3, angle, BLUE50, 0);
   loop(10){yield;}
   CreateShot01(x, y, 3, angle, BLUE50, 0);
   //etc.
 }

 let frame = 0;

 @Initialize{
   //blah blah...
 }

 @MainLoop{
   frame++;
   
   if(frame==120){
      ShotBurst(GetX, GetY, GetAngleToPlayer);
      frame = 0;
   }

   yield;
 }

//etc.
--- End code ---


This would start the task "ShotBurst" every two seconds, meaning that every two seconds three bursts of shots will be fired, one ten frames after the other, and so on. Make sure to include "yield;" at the end of your @MainLoop, so that all other yield; commands work correctly within tasks.

Edit: Damnit Iryan


Cyclone722:


--- Code: ---if(frame2==60||65||70){
let x=rand(100,300);
let y=rand(50,224);
loop(20){
         CreateShot01(x, y, 3, angle, BLUE50, 0);
CreateShot01(x, y, 3, angle, BLUE50, 0);
CreateShot01(x, y, 3, angle, BLUE50, 0);

         angle += 360/20;
   }
frame2=0;
  }
frame2++;
--- End code ---
I know what I did wrong, but this was cool anyways!
kinda like rippling water.

Iryan:

Is that the code you use inside your script? And it fires three-ring-bursts?

That'd puzzle me.

|| is a conditional OR. The code inside the if brackets will be executed if at least one of the conditions is met. As you put the frame reset inside this bracket, the reset will take place directly after the first ring is fired.

Pages: << < (4/6) > >>

Go to full version