Jump to content

Photo

2 small scripts I made


  • Please log in to reply
15 replies to this topic

#1 Bayta

Bayta

    Follower of Destiny

  • Members
  • Real Name:Robin Evans
  • Location:Suffolk County, NY

Posted 17 March 2008 - 08:23 PM

Heh, finally, something in here that isn't a request! icon_razz.gif In my attempt to learn ZScript, I have created 2 scripts. Both are very similar though, but whatever. icon_shrug.gif



Anyway, the first just puts a message up on the screen.

CODE
ffc script message{
  void run(int m){
    Screen->Message(m);
                 }
                  }


This is good if you want to show a message, but don't want a "guy" in the room, and are sick of the "poof" noise. Now, my next script is much more useful.



CODE
ffc script bossspeech{
  void run(int m){
    if (Screen->NumNPCs() > 0);
      Screen->Message(m);
                 }
                     }


Do you remember in some older Zelda games, (Link's Awakening in particular) when the boss of every dungeon would say something before the battle begins? Well that's what this does. What it actually does though, is it displays a message if there are any enemies on the screen. If you're using a custom boss (and it was made the "old-fashioned way") and there aren't actually any enemies on the screen, then you just have to use the first script. icon_smile.gif



Now, I know for a fact that the first one compiles and works, and that the second one compiles. I just haven't tested it yet. But I'm sure it works fine. Oh, by the way, the D0 variable for both scripts is the string number. Have fun icon_razz.gif



#2 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 17 March 2008 - 08:31 PM

Umm...Good job on making these! You left out a" {", and a "}" and have an extra ";" on the second script though.



Just making sure, umm...., But you do know that I posted these exact scripts in this thread already, right?

http://www.purezc.co...showtopic=35035

#3 Bayta

Bayta

    Follower of Destiny

  • Members
  • Real Name:Robin Evans
  • Location:Suffolk County, NY

Posted 17 March 2008 - 08:36 PM

Sorry, I didn't notice you posted them. icon_razz.gif And the compiler seems happy with the second script, so what's the big deal? icon_shrug.gif Unless, of course, it prevents the script from working correctly. icon_confused.gif

#4 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 17 March 2008 - 08:39 PM

Hm, that second one seems very useful. Nice work!

#5 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 17 March 2008 - 08:39 PM

That compiles...could be a bug in the compiler, are you using something beyond beta 16? What it might end up doing is playing a string regardless of Screen->NumNPCs.

#6 Joe123

Joe123

    Retired

  • Members

Posted 18 March 2008 - 02:56 AM

Your scope is...
Interesting, to say the least.
Why does the script close further out than void run icon_confused2.gif

I think you're getting a bit confused.
http://www.shardstor...ble_declaration
Have a look at the scope bit there and see if it helps.

#7 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 18 March 2008 - 04:37 AM

Actually just remove the ';' after NumNPCs() and it will work. ....well actually no. See there's a trick to reading screen enemies with scripts. Enemies in ZC are loaded onto the screen after screen init.

In other words you need a Waitframes(4); after void run(int m){

#8 Bayta

Bayta

    Follower of Destiny

  • Members
  • Real Name:Robin Evans
  • Location:Suffolk County, NY

Posted 19 March 2008 - 07:51 PM

Yeah, I was afraid of something like that. icon_frown.gif Alright, I sort of fixed it (at least I think)

CODE
ffc script bossspeech{
  void run(int m){
  Waitframes(4);
    if (Screen->NumNPCs() > 1)
      Screen->Message(m);
      }
    }


There, how's that?

Edited by Beta Link, 19 March 2008 - 09:09 PM.


#9 Joe123

Joe123

    Retired

  • Members

Posted 19 March 2008 - 08:02 PM

CODE
ffc script bossspeech{
    void run(int m){
    Waitframes(4);
        while(Screen->NumNPCs() > 1){Waitframe();}
    Screen->Message(m);
    }
}


#10 Bayta

Bayta

    Follower of Destiny

  • Members
  • Real Name:Robin Evans
  • Location:Suffolk County, NY

Posted 19 March 2008 - 09:14 PM

Why does Waitframe(); need to be in the middle of the script?

#11 Joe123

Joe123

    Retired

  • Members

Posted 20 March 2008 - 05:08 AM

Well.

What your script says is:

CODE
ffc script bossspeech{
    void run(int m){
    Waitframes(4);
        if(Screen->NumNPCs() > 0) Screen->Message(m);
    }
}



CODE
declare the script{
    use void run(declare integer m){
    Wait for 4 frames;
        if(the number of enemies on the screen is greater than zero) Play message m;
    }end void run
}end script


Which might look fine to you (but it isn't), however if you check what mine says:

CODE
ffc script bossspeech{
    void run(int m){
    Waitframes(4);
        while(Screen->NumNPCs() > 0){Waitframe();}
    Screen->Message(m);
    }
}


CODE
declare the script{
    use void run(declare integer m){
    Wait for 4 frames;
        while(the number of enemies on the screen is greater than zero) Idle the script, so that it keeps running;
    Play message m;
    }end void run
}end script



Can you see the difference?
Your script will check once to see how many enemies there are on the screen, 4 frames after it loads, then if there are less than 1 it plays the message, if not nothing happens. Either way, at this point, the script terminates.

My script checks every frame after the 4th frame of the screen loading to see how many enemies there are, then if at any point, there is less than one enemy, it plays the message and terminates.

EDIT:


CODE
ffc script bossspeech{
    void run(int m){
    Waitframes(4);
        while(true){
            if(Screen->NumNPCs() == 0){
                Screen->Message(m);
                Quit();
            }
        Waitframe();
        }
    }
}

That script does exactly the same as the one I posted just, and you might find it a bit easier to look at perhaps?
The first one was just less typing is all.

Edited by Joe123, 21 March 2008 - 06:33 PM.


#12 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 21 March 2008 - 06:27 PM

Now you'all just have to change all those to: if(Screen->NumNPCs()>0) icon_razz.gif

Edited by Gleeok, 21 March 2008 - 06:27 PM.


#13 Bayta

Bayta

    Follower of Destiny

  • Members
  • Real Name:Robin Evans
  • Location:Suffolk County, NY

Posted 21 March 2008 - 08:24 PM

Ah, now see, Joe, that's not what I want it to do. What I want it to do, is to play a message when you walk in, and only when you walk in if there are any enemies on the screen. icon_wink.gif

#14 Joe123

Joe123

    Retired

  • Members

Posted 22 March 2008 - 06:03 AM

Oh!

Well sorry then =P
I thought you'd got it actually on the screen with the boss.


By all means then, your script is perfect icon_thumbsup.gif


EDIT:
Oh!

Your script plays a message before you attack the boss, and mine plays one after you kill it!
Ahhh! =P

Edited by Joe123, 22 March 2008 - 06:03 AM.


#15 Bayta

Bayta

    Follower of Destiny

  • Members
  • Real Name:Robin Evans
  • Location:Suffolk County, NY

Posted 22 March 2008 - 06:04 PM

That's alright, just a misunderstanding. icon_smile.gif


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users