Jump to content

Photo

Help Activating Message on Secrets


  • Please log in to reply
6 replies to this topic

#1 klop422

klop422

    Guess I'm full of monsters and treasure

  • Members
  • Real Name:Not George
  • Location:Planet Earth

Posted 12 August 2018 - 05:32 PM

ffc script SecretMessage {
	void run (int message) {
		Waitframe();
			If(Screen->State[ST_SECRET]) {
				Screen->Message(message);
				}
			}
		}
	}
}

I'm sure it's clear, but I'm trying to make a message play when the screen secret is activated in the room.

I know I asked for a similiar thing here, but I've worked around needing that, and I feel like I probably don't need something as complicated as that (I hope).

 

Anyway, my point is, how do I actually make this work? I'm assuming the issue is the fourth line.



#2 Jamian

Jamian

    ZC enthusiast

  • Members

Posted 12 August 2018 - 06:05 PM

You have too many closing brackets. They don't match the opening brackets you have.

 

Apart from that, there's no loop in there, so the script would only check if Screen->State[ST_SECRET] is true when you enter the room, and then never again. You need a while loop to keep checking the secret state.


  • Binx likes this

#3 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 12 August 2018 - 06:45 PM

Just a note (and a lot of scripters don't do this, at all, but I think it looks messy, otherwise), if you put all of your opening brackets in their own line like so:
 

ffc script example
{
void run(x,y)
     {
     while (true)
          {
          //code here
          }
     } 
}     

it makes it a lot easier to keep track of your closing brackets and to make sure your brackets are always in pairs.



#4 klop422

klop422

    Guess I'm full of monsters and treasure

  • Members
  • Real Name:Not George
  • Location:Planet Earth

Posted 13 August 2018 - 12:39 PM

Alright, I got it to compile. Also didn't realise ZScript was case sensitive.

ffc script SecretMessage {
	void run (int message) {
		while(true) {
			Waitframe();
				if(Screen->State[ST_SECRET]) {
					Screen->Message(message);
				}
		}
	}
}

Not sure it's worth creating another topic for it, so I'll ask - is there a screen-shake function?



#5 ywkls

ywkls

    Master

  • Members

Posted 13 August 2018 - 12:46 PM

Not sure it's worth creating another topic for it, so I'll ask - is there a screen-shake function?

 

That would be Screen->Quake.

While that is set to anything other than zero, the screen will shake.

I should note that the intensity of the shaking is supposed to increase for larger numbers.



#6 klop422

klop422

    Guess I'm full of monsters and treasure

  • Members
  • Real Name:Not George
  • Location:Planet Earth

Posted 15 August 2018 - 11:42 AM

ffc script SecretMessage {
	void run (int string, int shake) {
		while(!Screen->State[ST_SECRET]) {
			Waitframe();
		}
		Screen->Message(string);
		Screen->Quake = shake;
	}
}

This is my script, currently. My brother helped me simplify it somewhat.
In case it's not clear, what it should do is loop doing nothing until it notices the screen secret has been activated, then play the string and shake the screen. For some reason, the screen shakes when I enter the room, but the message only plays when secrets activate.

Help?

EDIT: just realised I forgot to actually import the script to my file. I'll check if it works when I next can (in about an hour).

EDIT 2: Checked, and it works. Might upload the simplified one (without the screenshake) to the database, just for those who can't be bothered to write it (it took me surprisingly long, as someone who doesn't really script).


Edited by klop422, 15 August 2018 - 12:57 PM.


#7 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 17 August 2018 - 05:36 PM

Just a note (and a lot of scripters don't do this, at all, but I think it looks messy, otherwise), if you put all of your opening brackets in their own line like so:
 

ffc script example
{
        void run(x,y)
        {
                while (true)
                {
                        //code here
                }
        } 
}     
it makes it a lot easier to keep track of your closing brackets and to make sure your brackets are always in pairs.

 
 
While aye, this is good, you don't have your braces aligned with statements and other tokens...
ffc script example
{
    void run(x,y)
    {
        while (true) //the 'w' in 'while' should aligh with the opening brace under it!
        {
            //code here
        } // The closing brace aligns with the opening brace!
          // This means that you can use the visual **alignment** to determine what scope ou are inside!
          // Any code editor with its salt (I use SciTE), will highlight the braces so that 
          // you can see, with visible indication, which scoope a closing brace exits, ans similar. 
    ] // This closing brace, **aligns with** the opening brace for run() !
} // This closing brace, **aligns with** the opening brace for tha 'script' token!
 
I strongly advise using tabs, to space out your indents. 
 
Whether you put opening braces on a new line, or on the same line as a statement/function identifier/other, be sure to align everything so that you can easily keep tabs on it. Pun intended.
 
If you aren't using some kind of code-editing text editor, please throw away whatever you use, and use a code editor. That'll sort quite a lot of this for you by default.
 
Edit: Apparently, Edge refuses to submit that code block with appropriate tabbing, and manually spacing also fails. Fawk Microsoft and Edge,
I had to correct it with Firefix. Now that works, flawlessly.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users