Jump to content

Photo

[Zscript] Step->Secret


  • Please log in to reply
8 replies to this topic

#1 Christian

Christian

    Summoner

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

Posted 29 November 2008 - 09:18 PM

CODE

//This script will play the 'secret' SFX when you step on a trigger combo type
ffc script StepSecret{//name of the ffc script
   void run(int x, int y, int combo){//D0 equals the x co-ordinate and D1 equals the y co-ordinate of the ffc you want the combo to appear
    int secret = ComboAt(x,y);//set D2 to the number of the combo you want to make appear within the x and y co-ordinates
    z = 1;
      while(true){//if the statement is true, it passes on to the next line
    if(Screen->ComboD[secret] == combo){//checks if the combo appears on the screen when you step on  a trigger combo type
Game->PlaySound(SFX_SECRET);//plays the secret sfx when the combo appears
      z = 0;//sets z to 0 so the sfx won't play again
               }
    Waitframe();//quits the script
         }//end of void run
      }// end of code
}//end of script


works great with the secret combo flags 16 - 31.
Set D0 to the x co-ordinate , set D1 to the y co-ordinate, set D2 to the combo I.d of the combo you want to make appear. Also set the x and y co-ordinates in the tabs in the freeform combo set up. Choose a transparent combo and you are good to go.

Edited by drzchulo973, 30 November 2008 - 04:09 AM.


#2 Joe123

Joe123

    Retired

  • Members

Posted 30 November 2008 - 04:29 AM

Have you actually tried this script out drz?
Because just reading through, I can see that it won't currently work.

I think I'm also going to have to ask that you organise your coding a little better if you want to submit it, because it's actually very hard to read like it is now.

Try organising it a bit more like this:
CODE
ffc script StepSecret{
    void run(int x, int y, int combo){
        int secret = ComboAt(x,y);
        z = 1;
        while(true){
            if(Screen->ComboD[secret] == combo){
                Game->PlaySound(SFX_SECRET);
                z = 0;
            }
            Waitframe();
        }
    }
}


I've removed the comments to show the spacing better.
It's quite important that you space your scripts out properly, otherwise they become a nightmare to read.

There's quite a simple rule to show you how to space out your code properly with tabs.
Every time you write a left brace '{', move every line of code you write after that left brace out by one tab more than the line that the left brace is on.
Every time you write a right brace '}', move it in by one tab.

This lets you add structure to your code, so you can see which parts of loops and things relate to what.
If that's not enough to convince you, I suggest you download Notepad++, and write in that. You get a vertical line showing you how many tabs you've used on the current block of code. Set your langauge to C++ on it.

Anyway, if you fix up the code so it works properly, I'll add it to the database.

Edited by Joe123, 30 November 2008 - 04:29 AM.


#3 Christian

Christian

    Summoner

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

Posted 30 November 2008 - 10:54 AM

Well I pretty much followed your mini tutorial you gave me on ComboD , and ComboAt, combined with saffith's intermediate tutorial and got this, fresh written without looking.
CODE

//D0 is the combo I.d of a treasure chest
//or any combo you would like to have
//appeared
//D1 is the sfx you want played when you
  //step on a step->Next combotype

ffc script StepNext{
       void run(int chest, int sfx)
    int secret = ComboAt(this-X,this-Y);
    int trigger = Screen->ComboD[secret] == trigger && chest)
                Waitframe();
          Game->PlaySound(sfx);
        }
}

How to set up:
1.set the arguments as explained in the comments above.
2.place the x and y coordinates on the screen you want the combo to appear
3.must go along with a transparent combo
4.set the script on the ffc and that's pretty much it

Credits go for joe123 as i stole his "methods" =p

Just tested and it works and compiles flawlessly

Make sure to write the description as:
By drzchulo973 and joe123 since I used the way you use your comboD and comboAt

#4 Joe123

Joe123

    Retired

  • Members

Posted 02 December 2008 - 04:04 PM

I'm afraid there's still quite a lot wrong with this script.
I'm going to move it to Scripting Practise, and when I find the time I'll go over with you (or someone else can) what's wrong with it, and how to make it work.

#5 lucas92

lucas92

    Defender

  • Members

Posted 02 December 2008 - 04:08 PM

Maybe scripts should be moderated by staff before being submitted to the "database"?

It would assures that all scripts are top quality... Just a suggestion. icon_smile.gif

#6 Joe123

Joe123

    Retired

  • Members

Posted 02 December 2008 - 04:09 PM

They are, I'm moderating them...

That's why this one's not in the database.

#7 lucas92

lucas92

    Defender

  • Members

Posted 02 December 2008 - 04:23 PM

Yeah, but before they got post. Only staff may be able to post scripts in the "database". Members could PM their scripts with their post then the staff just post it in the database.

That would saves a lot of problems (I think).... icon_razz.gif



#8 Christian

Christian

    Summoner

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

Posted 02 December 2008 - 04:28 PM

Oh,no. Disregard this topic. I actually found my own way of doing this. Ill post it up when i get on a computer =p

#9 Joe123

Joe123

    Retired

  • Members

Posted 02 December 2008 - 05:30 PM

That's why we have the script submission forum.
If we did it via PM, it'd make a mess of my pm inbox, and it'd make impossible for anyone else to process the submissions if, say, me and Teilyr were both away for a while or something. Most people can't post in the script database forum itself.


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users