Jump to content

Photo

LockBlockShake


  • Please log in to reply
20 replies to this topic

#1 Christian

Christian

    Summoner

  • Members
  • Real Name:Chris
  • Location:New Jersey

Posted 30 November 2008 - 12:09 AM

CODE

int FreezeID;
const int SFX_UNLOCK=0;
const int SFX_RUMBLE =0;
const int S_BLOCKMESSAGE = 0;


ffc script lockedBlockShake{
    void run(int frames, int x, int y){
    Waitframes(2);
      int block = ComboAt(x,y);
      int lock  =  Screen->ComboD[block];
    while(lock == lock)
   Waitframe();
  if(Link->Dir == 0 && Link->InputUp){
   Game->PlaySound(SFX_UNLOCK);
Screen->Quake=frames;
GamePlaySound(SFX_RUMBLE);
FreezeID = Screen->ComboT[0];
Screen->ComboT[0] = CT_SCREENFREEZE;
    Waitframe(frames);
Screen->ComboT[0] = FreezeID;
Game->PlaySound(SFX_SECRET);
if(S_BLOCKMESSAGE != 0){
     Waitframe(20);
      Screen->Message(S_BLOCKMESSAGE);
    }
   }
   }
}


I wrote this script for the database but when i tested it it doesn't work! can someone help me what's going on? it compiles flawlessly but I just can't get it to work icon_frown.gif what am I missing? did I write something wrong? I mean it all makes sense to me..each line I wrote gives specific instructions on how it would run. I need a coder
more experienced than me to help me.

Edited by drzchulo973, 30 November 2008 - 12:15 AM.


#2 Elmensajero

Elmensajero

    Doyen(ne)

  • Members
  • Real Name:John
  • Location:Raleigh, North Carolina

Posted 30 November 2008 - 12:43 AM

CODE
while(lock == lock)
Waitframe();


Main issues: This loop is an infinite loop. Nothing below this will run because the contents of variable lock will always be equal to the contents of variable lock. Also, make sure you use "Waitframes(number);" instead of "Waitframe();" when you want the system to wait multiple frames. (You used it incorrectly twice.)

Now, to fix it, what exactly are you trying to do? If you want it to keep checking until the lockblock is removed, then your while loop should check the current combo to the contents of the variable lock. You also wouldn't need to check what direction Link is facing since if you modify the while loop, you will know that he has just used the key on the lockblock. I have no idea if the combofreeze thing will work since I have never messed with that before.

Edited by Elmensajero, 30 November 2008 - 12:44 AM.


#3 Christian

Christian

    Summoner

  • Members
  • Real Name:Chris
  • Location:New Jersey

Posted 30 November 2008 - 12:57 AM

Well, what i'm trying to work out is when link unlocks the block it will play a sound,wait 2o frames , shake the screen for a certain amount of frames while it plays a sound, freezes the screen , then play the secret sfx permanently. So i just need to take out the
CODE
Waitframe();
off the while loop??

#4 Elmensajero

Elmensajero

    Doyen(ne)

  • Members
  • Real Name:John
  • Location:Raleigh, North Carolina

Posted 30 November 2008 - 01:12 AM

No, that would result in ZClassic crashing, because the frame would never end after entering the loop. You need to modify the loop so that it keeps checking for when the block is unlocked. I think the following should work, although I haven't tested it. You won't need the "Game->PlaySound(SFX_SECRET);" line unless you modified the normal sound or something, but I left it in the script just in case.

CODE
int FreezeID;
const int SFX_UNLOCK=0;
const int SFX_RUMBLE =0;
const int S_BLOCKMESSAGE = 0;

ffc script lockedBlockShake{
    void run(int frames, int x, int y){
        Waitframes(2);
        int block = ComboAt(x,y);
        int lock  =  Screen->ComboD[block];
        
        //Wait until the combo at (x,y) changes.
        while(lock == Screen->ComboD[block]) Waitframe();
        
        //Play unlock sfx, shake screen, play secret sfx, and display string
        Game->PlaySound(SFX_UNLOCK);
        Screen->Quake=frames;
        GamePlaySound(SFX_RUMBLE);
        FreezeID = Screen->ComboT[0];
        Screen->ComboT[0] = CT_SCREENFREEZE;
        Waitframes(frames);
        Screen->ComboT[0] = FreezeID;
        Game->PlaySound(SFX_SECRET);
        if(S_BLOCKMESSAGE != 0){
            Waitframes(20);
            Screen->Message(S_BLOCKMESSAGE);
        }
    }
}


#5 Christian

Christian

    Summoner

  • Members
  • Real Name:Chris
  • Location:New Jersey

Posted 30 November 2008 - 01:33 AM

Oh that was the problem i had unnessesary codes in it
CODE
if(link dir == 0 && link->InputUp){
and
CODE
While(lock == lock) Waitframe();
was written totally wrong icon_smile.gif now i know to never ever write a waitframe under a while loop since its infinite. If i keep
CODE
(lock == lock)
will it matter?

EDIT: wait we do need a waitframe(); on a while loop, I'm not crazy icon_smile.gif and it was what you pointed out elmensajero..I figured out the problem and will quite say that I'll be embarrassed if I said it =p
Just tested it and works great how I re-wrote it. Wow I never imagine scripting would be quite easy. Learning by reading other people's scripts is by far easier than reading tutorials that confuse you.

Edited by drzchulo973, 30 November 2008 - 03:52 AM.


#6 Christian

Christian

    Summoner

  • Members
  • Real Name:Chris
  • Location:New Jersey

Posted 30 November 2008 - 04:38 AM

Topics merged at this point ~Joe123


CODE

//Global integers
Int FreezeID;

const int SFX_UNLOCK = 0;//set here the sfx to use when you unlock the block
const int  S_BLOCKMESSAGE = 0;//set here the string I.d of the message you want played when you unlock the block
const int SFX_RUMBLE = 0;//set here the sfx you want played when the screen shakes

//this script triggers the screen to shake for a certain amount of frames then plays a string and an sfx when you unlock it

ffc script LockedBlockShake{
            void run(int frames, int x, int y){
                   Waitframes(4);
                int block = ComboAt(x,y);
                int lock   = Screen->ComboD[block];
                while(Screen->ComboD[block] == lock)
                Waitframe();
             Game->PlaySound(SFX_UNLOCK);
              FreezeID = Screen->ComboT[0];//freezes the screen
              Screen->ComboT[0] = CT_SCREENFREEZE;//freezes the screen
                 Waitframes(120);//set here the exact frames you set on D0
              Screen->ComboT[0] = FreezeID;//freeze the screen
              Screen->Quake=frames;//shakes the screen for D0 frames
              Game->PlaySound(SFX_RUMBLE);//plays sfx
              Game->PlaySound(SFX_SECRET);//plays sfx
               if(S_BLOCKMESSAGE != 0){//if the message is not equal to 0
                     Waitframes(60);//set here the time in frames you want the message to appear when the screen stops shaking
                     Screen->Message(S_BLOCKMESSAGE);//plays message
                   }//end of void run
          }//end of code
}//end of script


Set the x and y coordinates on the x and y tabs in ffc setup screen and the x and y coordinates on the correct arguments tab. Set D0 to the time in frames you want the screen to shake, set D1 to the x coordinate, set D2 to the y coordinate. Must be used with a transparent combo.

Note: again you must set the x and y coordinates of the lock block on the screen in the ffc combo setup also for it to work properly. Bug free and tested.

Credits to joe for helping me understand comboAt,ComboT, and ComboD, and waitframes. And elmensajero for helping me find those bugs.

#7 Joe123

Joe123

    Retired

  • Members

Posted 30 November 2008 - 05:16 AM

Well, again I can see that this script won't work just by looking at it.
Have you tried compiling it?

Again though, I'm gonna have to stress that you organise it more clearly as I did in your other topic. I won't write it all out again.

It also looks near identical to a script I wrote ¬_¬

#8 Christian

Christian

    Summoner

  • Members
  • Real Name:Chris
  • Location:New Jersey

Posted 30 November 2008 - 05:29 AM

It should work? Or not. I just tested it. It works good and it compiles flawlessly. If you want you can test it yourself..since I wrote it on a windows based mobile phone...don't have internet at the moment ...if you can do me the favor and align it like you would do it will be good. And is somewat similar because I'm learning by looking at other peoples and yours as practice and learning how everything is done with the knowledge I have on the intermediate tutorials*shot* if you want I can re-write using other variables and expressions. I just though it would be easier.

#9 Joe123

Joe123

    Retired

  • Members

Posted 30 November 2008 - 05:58 AM

On the second line you have 'Int FreezeID'.
That won't compile, because of the capital letter.

I can align it properly, yes.
I don't mind you learning by editing my scripts at all; I learnt by editing other people's scripts to start with.

I don't think you should really try and submit them to a database when they're not really your own work though.
I don't mind processing this one, but if you're going to submit anything else, can you try and make them a bit more original, and a bit less of just an edit of other people's scripts?

#10 Christian

Christian

    Summoner

  • Members
  • Real Name:Chris
  • Location:New Jersey

Posted 30 November 2008 - 06:10 AM

I don't really think the screen freeze is nessesary at all..if you take out the lines that freezes the screen when you slot in the key and instead just make it play the message, 60 frames from when the screen stops shaking , it will work fine. but only if you have the messages freeze all actions rule checked on.
And yeah I'm learning by looking at scripts and its beggining to be quite simple..don't think its hard anymore. The next one ill be more original and yeah do you also mind if I use your "ComboD", ComboAt" methods? And set integers after "void run"? shoot me you have to, now I know how to work in that method =p

Edited by drzchulo973, 30 November 2008 - 06:13 AM.


#11 Joe123

Joe123

    Retired

  • Members

Posted 30 November 2008 - 06:14 AM

Well, ComboD and ComboAt aren't my methods =P
I'd assume DarkDragon made them, as it was him that added ZScript to the engine.

But you can use them in the way that I do, yes.
I'm going to suggest that what we do with this submission is...

I'll post a new thread in the database that looks a bit like this:

QUOTE
CODE
const int SFX_UNLOCK        = 0;    //set here the sfx to use when you unlock the block
const int SFX_RUMBLE        = 0;    //set here the sfx you want played when the screen shakes

//This script triggers the screen to shake for a certain amount of frames then plays a string and an sfx when you unlock a lockblock
ffc script LockedBlockShake{
    void run(int shakeframes,int m,int frames){
        Waitframes(4);
        int block = ComboAt(this->X,this->Y);
        int lock = Screen->ComboD[block];
        while(Screen->ComboD[block] == lock) Waitframe();
        
        Game->PlaySound(SFX_UNLOCK);
        int freeze = Screen->ComboT[0];        //store the combotype
        Screen->ComboT[0] = CT_SCREENFREEZE;//freeze the screen
        Screen->Quake = shakeframes;        //shakes the screen for D1 frames
        Waitframes(shakeframes);            //wait for D1 frames
        Screen->ComboT[0] = freeze;            //unfreeze the screen
        
        Game->PlaySound(SFX_RUMBLE);        //plays sfx
        Game->PlaySound(SFX_SECRET);        //plays sfx
        if(m != 0){                            //if the message is not equal to 0
            Waitframes(frames);                //wait for D2 frames
            Screen->Message(m);                //plays message D0
        }
    }//end of void run
}//end of script
  1. Place the ffc on top of the lock block.
  2. Set D0 to the time in frames you want the screen to shake
  3. Set D1 to the message string to play (leave as 0 if you don't want one)
  4. Set D2 to the number of frames to wait before playing the string and after shaking
  5. It's advised that you use a transparent combo
Credits to elmensajero for helping drzchulo973 find those bugs.


And put down the writer as 'drzchulo973 and Joe123'.
Does that sound ok?

Edited by Joe123, 30 November 2008 - 06:15 AM.


#12 Christian

Christian

    Summoner

  • Members
  • Real Name:Chris
  • Location:New Jersey

Posted 30 November 2008 - 06:36 AM

Well, you are my tutor joe ;-)
Sounds good ol' rielly to me icon_smile.gif
but one question if
CODE
Waitframes(screenshakes);
         Screen->ComboT[0] = freeze;
         Game-PlaySound(SFX_RUMBLE);


Wouldn't that line make the sfx play after the screen shakes while it freezes? I mean i thought it would play the rumble sfx while the screen shakes,freezes,blah blah blah.


#13 Joe123

Joe123

    Retired

  • Members

Posted 30 November 2008 - 06:39 AM

Ok, I'll move that line.

#14 Christian

Christian

    Summoner

  • Members
  • Real Name:Chris
  • Location:New Jersey

Posted 30 November 2008 - 06:54 AM

Thanks :-)

So I know what "ComboT" stands for,and "ComboAt", but what does "ComboD" stands for? And how are they used? Just for future reference?

#15 Joe123

Joe123

    Retired

  • Members

Posted 30 November 2008 - 07:08 AM

'ComboT' is 'ComboType'
'ComboD' is 'Combo ID Number'.

Saffith has a pretty good explanation of why we need ComboAt in his Beginner Tutorial, but I'll go over it again if you like.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users