Jump to content

Photo
* * * * * 3 votes

[Scripting / 2.50] Setting up your ZScripts


  • Please log in to reply
20 replies to this topic

#1 Plissken

Plissken

    What's with these homies dissing our girls?

  • Members

Posted 28 September 2008 - 09:53 AM

Setting up your ZScripts



A script setup tutorial by Plissken.

Table of Contents


  • Intro
  • How to put the scripts properly in your file
  • What file type you're going to "Save As" from Notepad
  • How to Import
  • FFC Explanations
  • Error Messages

Intro
This will only deal with ZScript and not touch upon loading in ZASM scripts. I had trouble on this when starting out with scripting and I feel like it's not covered publicly enough so I'm making a tutorial for any person new to the subject.

How to put the scripts properly in your file
So, you've found a script you want to use and now you want to apply it. If this is the first script you're going to be entering open up a new Notepad file. Don't copy and paste anything yet, first thing you must do is at the very top of the file write in this: import "std.zh"
Without this, the file won't compile. Make sure it's only in there once and make sure it's at the very top, above anything else. So, now we have this:
VO5zSjU.png

Now, you have to copy in the script you want to use. I'll be using some fairly simple ones to start off with, first I'll use Joe123's sign post script found here. I learned the setup of all of this with that script, if you read the topic you can see that.

So, I've copied the script into my notepad file underneath my "//Being signpost script" line with a double space in between. As a note, the messages preceded with "//" are called comments, which are not read by ZQuest. They simply exist to insert comments with information to help you and others understand what your code does.
Q3zVVWf.png

Well, if you've only wanted one script then you're pretty much done right now. Skip the rest of this section and go to the next one, if you want more than one script keep reading.

Many people when they're starting off make the mistake of making a new file for each script (myself included). But what you need to do is just put any script you want into one file. So, let's take the file I put the sign post script in and put a second script into there. I'll use my Bird script found here. Now, putting in another script into your file is very easy, just go down to the last line of your first script, and just copy & paste your new script in after the old one.  The comments are there to help visualize where the new script goes.

dxMgpyG.png

Whenever you want a new script in your game you've got to put it underneath your last one.

What file type you're going to create and how
The file type needed to import a ZScript script into Zelda Quest is a .z file. Making this file type is very easy. When you're done setting up your script file in Notepad, you must Save As, and after you enter a name put ".z" at the end. This will make it a .z file type and can still be opened in Notepad and be imported into Zelda Quest.

How to Import
I'll be using the latest build's method of doing this. They recently changed the GUI around, I forgot what build they made the switch but it's in the newer ones.

Go to Quest -> Scripts -> Compile ZScript... -> Import -> and then find and open the .z file you put all of your scripts in. Now hit compile, if there are no errors you should get this.


CODE
PASS 1: PARSING
PASS 2: PREPROCESSING
PASS 3: BUILDING SYMBOL TABLES
PASS 4: TYPE-CHECKING/COMPLETING FUNCTION SYMBOL TABLES/CONSTANT/FOLDING
PASS 5: GENERATING OBJECT CODE
PASS 6: ASSEMBLING
SUCCESS!

-- PRESS A KEY --


So, do what it says and press a key. Since I used two FFC scripts I have two scripts in the right box on the FFC slot. Zelda Classic allows for a whopping 511 FFC script slots, 3 global scripts, and 255 item scripts. So, to put my scripts into Zelda Quest I highlight the script I want to put in a slot and click the little arrow button. You should now see it in the first slot available. Once you've put all the scripts you want in slots hit OK and you should see a dialog box pop up telling you they've been successfully loaded in.

FFC Explanations
In your FFC edit box you can select the script it'll be using in the first tab using the drop down menu labeled Script:

Each script has it's own instructions to follow, but most use Arguments. Like in pkmnfrks sign post script thread he says, "To use this, give the FFC the number of the string as the first argument." This means enter the string number in D0. All arguments are handled with the D0-D7. Every script is different and instruction for setup should be provided by the author in the thread most of time.

Error Messages
Unfortunately, not all scripts work. Sometimes it's a simple "oh duh" error, and sometimes it was simply a bad script. If the script fails to compile, a short error message will appear that means... most likely absolutely nothing to you. However, there is a brief list of common error message in DarkDragon's Scripting FAQ at AGN. Unfortunately, there are too many to fit neatly into this guide, but on the off-chance that you do experience any kind of compiling error, this resource is invaluable.

This ends what I'm gonna be talking about in this tutorial. I might include ASM later on, but the truth is that I never really used it. I only know of one person who likes to script with it, and there's only a few scripts that use it.


  • Twilight Hero likes this

#2 Aquamentus (Facing Right)

Aquamentus (Facing Right)

    Recipient of Ways

  • Members
  • Real Name:Adam
  • Location:Left side of the room

Posted 12 August 2014 - 04:35 PM

Thank you.


Edited by Aquamentus (Facing Right), 07 October 2018 - 03:11 AM.


#3 Naru

Naru

    Magus

  • Members

Posted 26 March 2016 - 11:29 AM

I cannot see the pictures, only "IPB-Image". Are they not working anymore or have I to change my browser-settings?



#4 David

David

    Fallen leaves... adorn my night.

  • Administrators
  • Real Name:David
  • Pronouns:He / Him

Posted 26 March 2016 - 12:32 PM

I cannot see them either, most certainly because the images don't exist anymore; this, unfortunately, happens to a lot of older posts. In any case, this tutorial probably needs to be remade.


  • Naru likes this

#5 Naru

Naru

    Magus

  • Members

Posted 26 March 2016 - 02:44 PM

Can you recommend me another tutorial that is more up to date? I am completly new to scripting and want to start with how to add them to my quest.



#6 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 26 March 2016 - 02:54 PM

This tutorial is still up to date, besides the missing screenshots. You can use this tutorial though, the screenshots aren't really needed.


Edited by Avataro, 26 March 2016 - 02:54 PM.

  • David likes this

#7 David

David

    Fallen leaves... adorn my night.

  • Administrators
  • Real Name:David
  • Pronouns:He / Him

Posted 26 March 2016 - 02:58 PM

Once you are done learning how to add scripts to your quest, I suggest starting here to learn how to script in ZScript. And of course, if you are confused about anything, feel free to make a topic in the Scripting Discussion subforum to ask questions. :)


#8 Naru

Naru

    Magus

  • Members

Posted 26 March 2016 - 05:18 PM

Zelda Classic allows for a whopping 511 FFC script slots, 3 global scripts, and 255 item scripts.
 
How do I know what kind of script I have? In the database are multiple tags and some scripts are tagged multiple times. Also are there scripts I should better not touch at first (like global scripts, since they are limited to three and I might have to remove one afterwards)?
 
Also, can I just add/remove another script to the .z-notepad and bring it to work through compling or are there other things to follow?
 
[edit] Most of the scripts i want to implent say they require std.zh?

Edited by Naru, 26 March 2016 - 05:57 PM.


#9 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 26 March 2016 - 06:58 PM

 

 
How do I know what kind of script I have? In the database are multiple tags and some scripts are tagged multiple times. Also are there scripts I should better not touch at first (like global scripts, since they are limited to three and I might have to remove one afterwards)?

 

 

About global scripts, every global script will be combined into 1 single global script. If you want to use more than 1 global script, you need to combine your global scripts manually. If you only need one global script you can just copy and paste it into your .z file. For a beginner it might be a bit complicated to use multiple global scripts at first.

 

 

Also, can I just add/remove another script to the .z-notepad and bring it to work through compling or are there other things to follow?

 

Yes you can add or remove scripts however you like. After you compile them you put the scripts into the script slots and you are good to go.

 

 

[edit] Most of the scripts i want to implent say they require std.zh?

 

Put import "std.zh" at the top of your .z file above your scripts.


  • coolgamer012345 and Naru like this

#10 Naru

Naru

    Magus

  • Members

Posted 26 March 2016 - 07:40 PM

I just copied the scripts from the database into my file and got at Pass 4 multiple Error s10. Have I to throw out certain things (It looks to me like Moosh's NPC Script could be the problem in that case)? Have I to put import "std.zh" only once at the start or above each script?

 

[edit] is it OK to ask these things here? Since this is rather specific to my quest and goes off-topic regarding a general tutorial.


Edited by Naru, 26 March 2016 - 07:49 PM.


#11 C-Dawg

C-Dawg

    Magus

  • Members

Posted 26 March 2016 - 09:26 PM

This manual is a bit out of date and has some incorrect information. For example, Zelda Classic will load a script file no matter what the file suffix is, but it can't see it (i.e. it does not show up in the window to select) if it doesn't end in that.  This is useful if you want to use a different suffix for some other purpose.  I use .c because, if Visual Studio sees that, it sets up the file like C code.  That means you get color coding, automatic brackets and indenting, all sorts of good stuff.  Since Zelda Classic can't "see" a file ending in .c, you have to manually type the filename in, but that's no biggie.

 

If you want to see one way to organize a more complicated script -- like a custom engine -- go download Demons of Scheherzade demo and check out the script files.  I tried to comment the code with an eye towards explaining to the reader exactly what and why I'm doing it, and it should be really helpful to people who want to organize bigger projects.



#12 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 27 March 2016 - 01:12 AM

whopping 511 FFC script slots, 3 global scripts, and 255 item scripts.


Four global script slots:
 
Init (Slot 0) : This runs once, when a quest is first loaded by the user. It never runs again. Use it to initialise environmental values; and to wipe clean any bitmaps in memory. Bitmaps carry over between quests if ZC is not closed, and reopened.
 
OnContinue (Slot 1) : This runs every time a quest is resumed. Likewise, it is used to set up environmental values, or to reset global values set by other scripts that are saved with the quest file; and to clean up bitmaps carried over from other quests.
 
Active (Slot 2) : Runs continually as long as the quest is running. Most resources that claim to run via a global script, use this slot.
 
OnExit (Slot 3) : Runs when the quest is exited, including by F6, by player death, or by calling Game->End().
 


Error Messages
Unfortunately, not all scripts work. Sometimes it's a simple "oh duh" error, and sometimes it was simply a bad script. If the script fails to compile, a short error message will appear that means... most likely absolutely nothing to you.


ZScript_Basic_Docs_0.6.6.txt

 

Compiler errors start at line 663. If your text viewer doesn't show line numbers, search for:

 

## COMPILER ERROR DEFINITIONS ##

 

That will anchor you to the correct section. Some of these may be verbatim to the old AGN error list that DD posted, but most have been modernised, expanded, and corrected, as needed.

 

User/script errors aren't yet done, but start at line 1156 in this version. The anchor for them, is:

## OPERATIONAL ERRORS ##

 

Note that this file is a WIP intended to be a user-guide to ZScript, as well as a technical reference. it is part of a multi-file documents set that I've been making for the past six to seven months.


  • ShadowTiger likes this

#13 TheLink

TheLink

    An octorok under a duck?!?!

  • Members
  • Location:UK

Posted 23 April 2016 - 12:16 PM

For the scripts i am trying to use, it says to change D0 to the string and D1 for the button (i am using a sign script for FFC's) but i dont know what it means by D0, ect

 

Anyone else know?



#14 Nightmeres

Nightmeres

    Defender

  • Members

Posted 23 April 2016 - 12:20 PM

It's one of the tabs in the ffc editor. The last one I believe.

#15 TheLink

TheLink

    An octorok under a duck?!?!

  • Members
  • Location:UK

Posted 24 April 2016 - 02:02 AM

thx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users