Jump to content

Photo

Script Help


  • Please log in to reply
18 replies to this topic

#1 BitZero

BitZero

    Junior

  • Members
  • Real Name:William
  • Location:The End of the World

Posted 03 August 2008 - 12:26 PM

-2.5 Build 842-
Alright, bare with my lack of ZScripting knowledge.
Here's the script...
CODE
import "std.zh"

ffc script cutscenescript
{
    void run(int m)
    {
        while (Link->X = 120; Link->Y = 120)
        {
            Screen->Message(m)    
    }
}

What I'm trying to do is get so that when Link is at a certain position, it shows a string...but, it messes up on line 6. And I don't even know if I'm using the correct variables and such.

#2 LinktheMaster

LinktheMaster

    Hey Listen, Kid

  • Members
  • Real Name:Matt
  • Location:United States

Posted 03 August 2008 - 12:52 PM

CODE
import "std.zh"

ffc script cutscenescript
{
    void run(int m)
    {
        while (Link->X == 120 && Link->Y == 120)
        {
            Screen->Message(m);
        }
    }
}


That should do the trick. :]

Just note three things:

1. Whenever you have a opening brace ({), you must have a closing brace (}).

2. All commands must have a semi-colon (icon_wink.gif unless they are activating a loop, if statement, import, or function. In true C++ there are a few other exceptions, but those are the main ones in ZC.

3. The equal condition is ==. So when you're asking if two things are equal in an if statement or a loop, you must use two equal signs.

Hope that helps. icon_smile.gif

Edit: Actually, I wasn't paying attention. I was just trying to get the code to compile. Unfortunately that code I just gave won't actually do what you want.

CODE

bool exit = false
while(!exit)
{
if(Link->X >= 112 && Link->X <= 128 && Link->Y >= 112 && Link->Y <= 128)
{
Screen->Message(m);
exit = true;
}
Waitframe();
}


That'll work better. It'll loop until Link goes into that area and gets the message. Also I made it so that the condition isn't quite as picky since that could easily cause some frustration.

Edited by LinktheMaster, 03 August 2008 - 01:00 PM.


#3 BitZero

BitZero

    Junior

  • Members
  • Real Name:William
  • Location:The End of the World

Posted 03 August 2008 - 01:01 PM

Almost correct...
Anyway, it works, and I'll try to remember your advice.
But I have one question. What is the && for?
Thanks for the help.

Edit: Should I put the header above the bool exit = false?

Edited by SerpitaX, 03 August 2008 - 01:05 PM.


#4 LinktheMaster

LinktheMaster

    Hey Listen, Kid

  • Members
  • Real Name:Matt
  • Location:United States

Posted 03 August 2008 - 01:05 PM

&& is and. It combines two elements in a condition.

if(x > 0 && x < 10)

... is saying "If x is greater than 0 and x is less than 10". Both have to be true for it the whole statement to be true.

There's also || (or).

if(x > 0 || x < 10)

... is saying "If x is greater than 0 or x is less than 10". Only one of them have to be true.

QUOTE
Should I put the header above the bool exit = false?

Assuming you have this in a script, all of the code I provided would be in the braces for void run().

So...

CODE
ffc script test
{
void run()
{
(Code I gave you.)
}
}

Edited by LinktheMaster, 03 August 2008 - 01:07 PM.


#5 BitZero

BitZero

    Junior

  • Members
  • Real Name:William
  • Location:The End of the World

Posted 03 August 2008 - 01:11 PM

QUOTE
Assuming you have this in a script, all of the code I provided would be in the braces for void run().

So...


CODE

ffc script test
{
void run()
{
(Code I gave you.)
}
}


Okay, thanks! And, one more question. Do I still add what I put in the void run(int m), or do I just put the string number in the code itself?

#6 LinktheMaster

LinktheMaster

    Hey Listen, Kid

  • Members
  • Real Name:Matt
  • Location:United States

Posted 03 August 2008 - 01:14 PM

That depends on how you want it. If you put it in as void run(int m), then you'll have the put the number of the string for d0 when you create the FFC. If you're only going to be using this script once, then I would suggest just putting the number in Screen->Message().

#7 BitZero

BitZero

    Junior

  • Members
  • Real Name:William
  • Location:The End of the World

Posted 03 August 2008 - 01:24 PM

QUOTE
That depends on how you want it. If you put it in as void run(int m), then you'll have the put the number of the string for d0 when you create the FFC. If you're only going to be using this script once, then I would suggest just putting the number in Screen->Message().


Alright, I'll go with the latter then.
Uh...I think I messed it up...
Here's the code:
CODE
ffc script cutscenescript
{
    void run()
    {
        bool exit = false
        while(!exit)
        {
            if(Link->X >= 112 && Link->X <= 128 && Link->Y >= 112 && Link->Y <= 128)
            {
                Screen->Message(37);
                exit = true;
            }
            Waitframe();
        }
    }
}

However, it is saying that there is a syntax error on line 8. Unexpected while, expecting semicolon, on token while.

Edited by SerpitaX, 03 August 2008 - 01:25 PM.


#8 LinktheMaster

LinktheMaster

    Hey Listen, Kid

  • Members
  • Real Name:Matt
  • Location:United States

Posted 03 August 2008 - 01:28 PM

Oops. icon_heh.gif There needs to be a semi-colon after false. Sorry about that.

#9 BitZero

BitZero

    Junior

  • Members
  • Real Name:William
  • Location:The End of the World

Posted 03 August 2008 - 01:31 PM

QUOTE
Oops. There needs to be a semi-colon after false. Sorry about that.

Well, everybody makes mistakes. But it now works!
And my string appears correctly. That, and I'll place you on my credits when my quest is finally finished.

#10 LinktheMaster

LinktheMaster

    Hey Listen, Kid

  • Members
  • Real Name:Matt
  • Location:United States

Posted 03 August 2008 - 01:44 PM

No need. I'm glad to help. :]

#11 BitZero

BitZero

    Junior

  • Members
  • Real Name:William
  • Location:The End of the World

Posted 03 August 2008 - 01:53 PM

I was wondering, since I'll need to use the code (somewhat) later again, what would I put, instead of Link, as the ffc? So that when the 1st ffc reaches the designated spot a string plays.

Edited by SerpitaX, 03 August 2008 - 02:05 PM.


#12 LinktheMaster

LinktheMaster

    Hey Listen, Kid

  • Members
  • Real Name:Matt
  • Location:United States

Posted 03 August 2008 - 02:13 PM

You'll need to create and load the FFC before.

ffc test = Screen->LoadFFC(1);

1 is the FFC number you want to load.

The use test->X and test->Y.

#13 Elmensajero

Elmensajero

    Doyen(ne)

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

Posted 03 August 2008 - 02:18 PM

Well, you can check the position of an FFC in two ways. If you want to check the FFC that you attached the scripts to, just use the "this" object. It is used the same way as "Link", for example, this->X, this->Y, etc. Or, if it is another FFC, you would load the ffc into a variable like this:
CODE
ffc myffc=Screen->LoadFFC(#);

where # is whatever FFC you want to check. So with the code above, here is how you could do it with loading FFC 1...

CODE
ffc script cutscenescript
{
    void run()
    {
        bool exit = false;
        ffc myffc=Screen->LoadFFC(1);
        while(!exit)
        {
            if(myffc->X >= 112 && myffc->X <= 128 && myffc->Y >= 112 && myffc->Y <= 128)
            {
                Screen->Message(37);
                exit = true;
            }
            Waitframe();
        }
    }
}


Edit: Lol, LTM beat me to it icon_biggrin.gif

Edited by Elmensajero, 03 August 2008 - 02:20 PM.


#14 BitZero

BitZero

    Junior

  • Members
  • Real Name:William
  • Location:The End of the World

Posted 03 August 2008 - 02:23 PM

Yeah...I can't really test that out, as I have just gotten a major issue with my quest file...I'm guessing this is a big bug...
Luckily, I recently backed-up my quest.

#15 LinktheMaster

LinktheMaster

    Hey Listen, Kid

  • Members
  • Real Name:Matt
  • Location:United States

Posted 03 August 2008 - 02:51 PM

Ah... yeah... the latest two builds of ZC have very severe bugs in them that can mess your quest up, unfortunately. icon_unsettled.gif


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users