Jump to content

Photo

How do I make different strings appear if Link has a certain item?


  • Please log in to reply
13 replies to this topic

#1 MrSnowBro

MrSnowBro

    Newbie

  • Members

Posted 28 May 2017 - 12:10 PM

So, you know how when Link obtains a Piece of Heart then there is a different message displayed when he has 1 or 2 Pieces of Heart collected at the time telling him how many he needs to create a new Heart Container, I'm wondering if I can create this for my quest that I'm working on, but I don't exactly know how, can anyone help me please? :)



#2 judasrising

judasrising

    I play guitar

  • Members
  • Location:Sweden but born in Finland

Posted 28 May 2017 - 01:33 PM

So, you know how when Link obtains a Piece of Heart then there is a different message displayed when he has 1 or 2 Pieces of Heart collected at the time telling him how many he needs to create a new Heart Container, I'm wondering if I can create this for my quest that I'm working on, but I don't exactly know how, can anyone help me please? :)

You can use this script for that http://www.purezc.ne...e=scripts&id=65



#3 MrSnowBro

MrSnowBro

    Newbie

  • Members

Posted 28 May 2017 - 03:04 PM

Okay, so I just copy it into a document with .z as the extension then compile it, correct? Or what do I have to do to make it compile correctly?


Edited by MrSnowBro, 28 May 2017 - 03:05 PM.


#4 Architect Abdiel

Architect Abdiel

    Kingdom Builder

  • Members
  • Real Name:Michael
  • Location:Florida

Posted 28 May 2017 - 11:13 PM

Click "View Script".

Copy entire code.


If you already have a document with scripts, you can just put it at the bottom.

If not, yeah, you have to have a .z file.


And at the top of the file, you have to put..

import "std.zh".

#5 MrSnowBro

MrSnowBro

    Newbie

  • Members

Posted 28 May 2017 - 11:36 PM

I clicked on "View Script" and copied all the text from there and compiled it since it already had import "std.zh" at the top of it, yet, the script wouldn't compile. Is there something I'm doing wrong?



#6 Lüt

Lüt

    Germanize

  • Members
  • Real Name:Steve
  • Location:Chicago

Posted 28 May 2017 - 11:39 PM

Click "View Script".

Copy entire code.

Generally you do this, but in this particular case he has two versions.

 

At the top: "//Old version: supports only 4-piece heart containers"

 

And at the bottom: "//New version: supports any number of heart containers"

 

I believe you only choose the one you need. If you're sticking with traditional 4-heart-piece containers, use the top, and if you've changed the number to something other than 4 heart pieces per container, use the bottom.

 

I don't know coding, but I do know that lines beginning with // are author comments and are not used as part of the script, so they have nothing to do with how it compiles. You could leave them out of your .z file entirely, but the point is to have a reference for how to use the script, so I leave them in.

 

As an example, the first line is "//import "std.zh"", so if you actually do need to import that, simply remove the // and it'll turn into functional code.

 

(And you'll need to do that if you don't already have another script that imports std.zh.)



#7 MrSnowBro

MrSnowBro

    Newbie

  • Members

Posted 29 May 2017 - 12:08 AM

So I took out the newer version of the script that supports any number of Heart Pieces and removed the // from the import "std.zh" part of the script however it still does not compile properly. What I'm I still doing wrong?



#8 Lüt

Lüt

    Germanize

  • Members
  • Real Name:Steve
  • Location:Chicago

Posted 29 May 2017 - 12:49 AM

OK, I just tried it and it worked.

 

Here's exactly the code I put in the .z file:

import "std.zh"
//Old version: supports only 4-piece heart containers
//Messages can be set automatically or manually
//D0 = First message
//D1-3 = Second-fourth messages; default to strings after D0

item script heartPieceMessageOld{
    void run (int m1, int m2, int m3, int m4){
        //Set m2-4 to follow m1 if not set explicitly
        if ( m2 == 0 ) m2 = m1+1;
        if ( m3 == 0 ) m3 = m1+2;
        if ( m4 == 0 ) m4 = m1+3;

        //Play the appropriate message
        if ( Game->Generic[GEN_HEARTPIECES] == 0 )
            Screen->Message(m1);
        if ( Game->Generic[GEN_HEARTPIECES] == 1 )
            Screen->Message(m2);
        if ( Game->Generic[GEN_HEARTPIECES] == 2 )
            Screen->Message(m3);
        if ( Game->Generic[GEN_HEARTPIECES] == 3 )
            Screen->Message(m4);
    }
}

If that fails, all I can think of is this: you don't have std.zh in your directory.

 

It's been so long since I've installed ZC that I don't remember if std.zh came with the package or if I added it later, but if you don't have it, download this ZC 2.50.2 Studio (July 2016 release) and extract the file to your 2.50.2 folder (or wherever you're importing your scripts from).

 

There's also a number of other useful resources in there, some of which you will need if you want to further expand your script collection, but for now, only extracting std.zh should suit your needs. (This is a complete package, so if you extract the entire thing to your 2.50.2 folder, then yes, it will overwrite other files from your current install.)

 

For future reference, it can help people if you post the specific compile error message.



#9 MrSnowBro

MrSnowBro

    Newbie

  • Members

Posted 29 May 2017 - 02:35 PM

I extracted std.zh to my directory and tried to compile the script again yet it wouldn't compile. When I try to compile it, it cannot get past the parsing stage and it says that it can't open or parse the input file.



#10 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 29 May 2017 - 03:29 PM

Std.zh always comes with ZC so you shouldn't need to download it.

 

Can you post the specific error message?



#11 MrSnowBro

MrSnowBro

    Newbie

  • Members

Posted 29 May 2017 - 04:59 PM

Pass 1: Parsing

Line 1 : Syntax Error, Unexpected Identifier, Expecting $end, on token pk

Fatal Error P00 : Can't open or parse input file!

 

That is what I get when it tries to go through the compile progress. I have no idea what I'm doing wrong. :/


Edited by MrSnowBro, 30 May 2017 - 03:36 PM.


#12 MrSnowBro

MrSnowBro

    Newbie

  • Members

Posted 02 June 2017 - 07:43 PM

So, I found a text file that comes with Zelda Classic and and ZScript and on it, it lists specific errors that can happen and it lists my error on there, it says that either my file with the script either contains illegal characters or is not ASCII text, or that the compiler can't write to the disk, or the file may be bad. If I may ask, what is ASCII text, I think that might be my error.



#13 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 03 June 2017 - 05:59 AM

You should be clicking the marked option here and then import and parse the script from there.

 

ca798250715b4354b2b44cef8caa2c63.png

 

I hope that helps? The script that Lüt posted compiles just fine for me.


Edited by Avataro, 03 June 2017 - 06:01 AM.


#14 MrSnowBro

MrSnowBro

    Newbie

  • Members

Posted 05 June 2017 - 12:05 AM

That's exactly what I've been doing, yet it doesn't compile. It's really odd. Especially since now a script that used to compile fine for me now doesn't want to compile. It gets really odd how downloaded script files (like the script files from the Panoply of Calatia Support Pack) work perfectly fine.


Edited by MrSnowBro, 05 June 2017 - 12:07 AM.



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users