Jump to content

Photo

Screen shake


  • Please log in to reply
15 replies to this topic

#1 Tree

Tree

    Everything must go away

  • Members
  • Real Name:Mundy Fumple McStroodlestein
  • Location:The Milky Way Galaxy

Posted 29 December 2012 - 08:42 PM

Is it possible for the screen to shake upon entry and about a second after, a string plays, but only on the first entry?

#2 ShadowTiger

ShadowTiger

    The Doctor Is In

  • Members

Posted 29 December 2012 - 08:49 PM

Yes yes absolutely, though it will of course require a (fairly simple) script.

I'm probably going to get this wrong but let's see if this works.

CODE


import "std.zh"

ffc script onEntryScreenShakeThenMessage
{
void run(int m, int shake1, int shake2, int quakelength)
{
  Waitframe(shake1);
  Screen->Quake(quakelength);
  Waitframe(shake2);
  Game->Message(m);
  }
}


Really hope that works. Didn't test it or anything.

Oh, uh, Import as usual, assign to FFC script slot, assign script to FFC, place FFC in room with invisible combo.

D0 = The screen message to play.
D1 = Frames to wait before the quake.
D2 = Frames to wait after the quake begins.
D3 = The length in frames that the quake will last.

The last two D#s aren't directly related. According to the Screen Shake entry on the Wiki, the quake lasts for a decreasing number of frames.

#3 Tree

Tree

    Everything must go away

  • Members
  • Real Name:Mundy Fumple McStroodlestein
  • Location:The Milky Way Galaxy

Posted 29 December 2012 - 08:59 PM

Thanks man! I'll try it out right now and tell you if it works!

EDIT: There was a compile problem.

QUOTE
ERROR T21: Could not match signature waitframe (float)


CODE

ffc script onEntryScreenShakeThenMessage
{
void run(int m, int shake1, int shake2, int quakelength)
{
  Waitframe(shake1);
  Screen->Quake(quakelength);
  Waitframe(shake2);
  Game->Message(m);
  }
}


I believe it's referring to line 5. I tried fixing it my self because it sounded simple, but I know nothing of scripts icon_razz.gif

Edited by Keiichi123, 29 December 2012 - 09:20 PM.


#4 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 29 December 2012 - 09:22 PM

Here, I fixed the problem (It's Waitframes, not Waitframe), and also fixed another issue. That script would make it shake every time you enter the screen. Now it'll only do it the first time. I also added indents and stuff to make it look tidier.

CODE
import "std.zh"

ffc script onEntryScreenShakeThenMessage{
    void run(int m, int shake1, int shake2, int quakelength){
        if(Screen->D[0] != 1){
            Waitframes(shake1);
            Screen->Quake(quakelength);
            Waitframes(shake2);
            Game->Message(m);
            Screen->D[0]=1;
        }
      }
}


And lastly, since this is really more of a script request, I'm moving it to the appropriate forum.

#5 ShadowTiger

ShadowTiger

    The Doctor Is In

  • Members

Posted 29 December 2012 - 09:26 PM

Neat thanks.. yeah, I wondered if it was Waitframe(); or Waitframes();. The wiki has them both. O_o

So, just for the sake of information, "Screen->D[#]" does not relate to the items in void run(_____){ ? Because I'm sure you can see the similarity between "D0 is the string, D1 is the number of frames...." and "Screen->D[0]=1;"

#6 Tree

Tree

    Everything must go away

  • Members
  • Real Name:Mundy Fumple McStroodlestein
  • Location:The Milky Way Galaxy

Posted 29 December 2012 - 09:30 PM

I believe we are getting closer guys icon_heh.gif

QUOTE
ERROR T28: That pointer type does not have a function quake.


Again, on line 5. I really wish I knew how to script so I wouldn't have to keep asking for help icon_razz.gif

#7 ShadowTiger

ShadowTiger

    The Doctor Is In

  • Members

Posted 29 December 2012 - 09:38 PM

Perhaps we should be looking at this instead.

Hm. Good to have a lead.


#8 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 29 December 2012 - 09:43 PM

QUOTE(ShadowTiger @ Dec 29 2012, 09:26 PM) View Post

Neat thanks.. yeah, I wondered if it was Waitframe(); or Waitframes();. The wiki has them both. O_o


Both definitely work. Waitframe() is for a single frame where Waitframes(int frames) is the number you specify in the brackets.

Fixed code, by the way -

CODE
import "std.zh"

ffc script onEntryScreenShakeThenMessage{
    void run(int m, int shake1, int shake2, int quakelength){
        if(Screen->D[0] != 1){
            Waitframes(shake1);
            Screen->Quake = quakelength;
            Waitframes(shake2);
            Screen->Message(m);
            Screen->D[0]=1;
        }
      }
}


So the two problems were...

Screen->Quake is a variable, not a function. You'd set it like a variable as opposed to inputting a parameter for it. Game->Message is actually supposed to be Screen->Message.

Just for future reference. icon_smile.gif

#9 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 29 December 2012 - 09:43 PM

Derp. I figured it out now.


CODE
import "std.zh"

ffc script onEntryScreenShakeThenMessage{
    void run(int m, int shake1, int shake2, int quakelength){
        if(Screen->D[0] != 1){
            Waitframes(shake1);
            Screen->Quake = quakelength;
            Waitframes(shake2);
            Screen->Message(m);
            Screen->D[0]=1;
        }
      }
}


The format is Screen->Quake = time, not Screen->Quake(time).

QUOTE(ShadowTiger @ Dec 29 2012, 06:26 PM) View Post

Neat thanks.. yeah, I wondered if it was Waitframe(); or Waitframes();. The wiki has them both. O_o

Well yeah, there are both. Waitframe(); makes the game wait exactly one frame, whereas you use Waitframes(time); if you want it to wait longer.

QUOTE
So, just for the sake of information, "Screen->D[#]" does not relate to the items in void run(_____){ ? Because I'm sure you can see the similarity between "D0 is the string, D1 is the number of frames...." and "Screen->D[0]=1;"


No, it has nothing to do with void run();. Each screen has a certain amount of built in variables (I forget how many now though). You can set them with Screen->D[#] = x; Once they're set, they're saved for that screen forever, until you set them to something else. So the if loop I have checks to see if the first variable, D[0], is 1. Because it hasn't been set yet, it won't be. The script does its thing, then sets the variable to 1. That way, the next time you walk onto the screen, the script will check, see that the variable is set to 1, and won't run the rest of the script again.

Edit: Dangit Dan, I was first. ):<

#10 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 29 December 2012 - 09:47 PM

Your code's still busted though. icon_badrazz.gif You have it Game->Message and not Screen->Message. icon_deformed.gif

/mebeingasmartass

*Runs*

#11 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 29 December 2012 - 09:50 PM

GAH. Well, I would have noticed that the next time Keichii tried to compile it at least. icon_sigh.gif

#12 Tree

Tree

    Everything must go away

  • Members
  • Real Name:Mundy Fumple McStroodlestein
  • Location:The Milky Way Galaxy

Posted 29 December 2012 - 10:16 PM

Sooo, I should just use the earthquake script?

#13 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 29 December 2012 - 10:42 PM

The most recent one Dan and I both posted will do exactly what you want.

#14 Tree

Tree

    Everything must go away

  • Members
  • Real Name:Mundy Fumple McStroodlestein
  • Location:The Milky Way Galaxy

Posted 29 December 2012 - 10:57 PM

I compiled the wrong one at first, that's why I was asking icon_razz.gif

Thanks a lot guys!

#15 ShadowTiger

ShadowTiger

    The Doctor Is In

  • Members

Posted 30 December 2012 - 05:57 AM

That's awesome. This is how people learn. I definitely feel smertar from reading this thread. icon_deformed.gif

Totally aside, but is there any way to pass something from an FFC to a Global, so an FFC's D[#] on another screen can benefit from the setting of a D[#] on the current screen? Because what if this earthquake event changes parts of the world as well?


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users