Jump to content

Photo

Problem with Scripts

Scripts NPCs

  • Please log in to reply
15 replies to this topic

#1 Shmirko

Shmirko

    GOATED

  • Members
  • Real Name:Mirko Metsue Tombeur
  • Location:Kessel-Lo, Leuven

Posted 09 July 2020 - 01:45 AM

I have been using Zquest for a while, but have never used scripts for any of my quests. I really want to use a NPC's you can talk too, but I just don't know how to put them in Zquest. I copied the code in a .txt file and tried to import it, but it give an error when I do it that way.

There are just no good script tutorials, it seems like people just act like everyone knows how it works.

Hope someone can help me! Thx in advance!!
  • Lightwulf likes this

#2 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 09 July 2020 - 02:02 AM

What exact error is it giving you, and which version are you using? Is it possible your text file isn't actually plaintext but has some extra formatting in it? 



#3 Shmirko

Shmirko

    GOATED

  • Members
  • Real Name:Mirko Metsue Tombeur
  • Location:Kessel-Lo, Leuven

Posted 09 July 2020 - 03:29 AM

What exact error is it giving you, and which version are you using? Is it possible your text file isn't actually plaintext but has some extra formatting in it?


Heeey, u the guy that made the script I wanted to use! Wassup?!

I'm on my phone now, not home. I'll give a more detailed description ones I'm capable of doing so.
  • ShadowTiger, Moosh and Lightwulf like this

#4 Shmirko

Shmirko

    GOATED

  • Members
  • Real Name:Mirko Metsue Tombeur
  • Location:Kessel-Lo, Leuven

Posted 09 July 2020 - 05:37 AM

Ok, I'm here again!

 

So, to give an example, I will be trying to import to scripts in my quest made with the Dance of Remembrance tileset. The version I'm using is the 2.53 beta iirc.

 

 

The first script I import is the NPC Script found here: https://www.purezc.n...showtopic=46059

The other one is your own Permanent Tiered Secrets script: https://www.purezc.n...=scripts&id=119

 

So I copy both scripts and paste them in separate .txt files.

 

Let's start with the first one: I go to Scripts > Import ASM FFC Script and load up the .txt file I named 'Lemmy Koopa NPC' 

One I do, I get an error that says:

 

 

Unable to Parse instruction 1 from script Lemmy Koopa

The error was: Invalid Instruction!

The command was (script) (real_npcV2,{)

 

So, that's not good...

 

Next one, then, hopefully this one works!

 

I do the same stuff like with the last one...aaaaaaand...nope, still an error

 

It is similar to the first one, but this thime the wrong command was ''(Tiered) (Secrets,Script)


  • Lightwulf likes this

#5 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 09 July 2020 - 06:07 AM

Aha! There's the problem. It's a common issue, the "Import ASM" options are for importing ZASM scripts (an assembly language), an often unused feature. Basically all scripts on the database are written in ZScript unless otherwise specified. So you need to compile them into ZASM with Quest->Scripts->Compile ZScript...
 
From there you'll be given some options:
Edit: Lets you edit the ZScript buffer. Every script in your quest ends up in here, either through import instructions or loading your files directly. Importing lets you compile scripts from files in your ZC folder instead of having to copy all of it into the buffer every time. So for example if you had:

import "MyQuest/MyScript.txt"

That'd tell it to copy all of "MyScript.txt" from the folder "MyQuest" into the buffer. 
Load: This copies a file into the buffer. If you're using this instead of the import instruction method, you want to have all your scripts in one big text file so they can be imported this way. Be aware that clicking confirm will clear the entire buffer even if you don't select a file to import. This can wipe all your scripts from the quest. Be very careful.
Export: The opposite of Load, for saving everything in the buffer to a file.
Compile: Hitting this will compile your scripts and let you assign them to slots. Any scripts whose names match up with already assigned slots will be auto assigned. If a script is missing from the buffer on compile it will be lost and will have a ** next to its slot. You need to recompile your entire batch of scripts every time or they won't be saved.

And a couple other things. Most script files use the extension .z, .zs, or .zh (for header files). This is purely cosmetic for distinguishing them from regular text/readme files, you can use whatever extensions you like. 2.53 will also default to using #include instead of import. They do the same thing aside from the order they check folders I believe. The three folders that it will check for paths from are the main ZC folder, headers, and include.


Edited by Moosh, 09 July 2020 - 06:12 AM.

  • Lightwulf likes this

#6 Shmirko

Shmirko

    GOATED

  • Members
  • Real Name:Mirko Metsue Tombeur
  • Location:Kessel-Lo, Leuven

Posted 09 July 2020 - 06:58 AM

So I am trying the first method. Can I just have separate files when doing this? And do the scripts need to be in the same folder as the quest for this to work?

 

So I wrote this in 'edit buffer':

 

import "DoR/Permanent Tiered Secrets Code.txt"

 

import "DoR/Lemmy Koopa NPC.txt"

 

then I exited and saved changes to buffer, and click compile.

 

But I got a couple errors. 

 

The second method is also not working, I don't have a file I can import, it doesn't want .txt files, but .z files, and I can't just put .z after the files to make it work.


  • Lightwulf likes this

#7 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 09 July 2020 - 08:09 AM

Were there errors that it couldn't find one or both of those files? If it says anything beyond "failure to parse imported file" then you know the error is with one of the scripts, but otherwise it's with whatever path you specified, it was unable to find that file. 

 

For the second issue, it's probably default Windows settings at play. For whatever reason Microsoft has done everything in their power to render their OS bloody unusable. In the searchbar, look for "File Explorer Options" and open that. Under the View tab, uncheck the box that says "Hide extensions for known file types". With that it'll actually let you see the file extensions and change them to whatever you please when you rename the file at that location. You also won't get hit by certain old school email worms, not that those are much of a thing anymore. :P

 

After that, to change the program associated with .zs and .zh files you can right click the file and go to Properties. There'll be an option that says "Opens With" and you can change that to Notepad or Notepad++. Notepad++ is a blessing for its ability to highlight syntax, fold code, and give you easily readable line numbers for troubleshooting errors.


Edited by Moosh, 09 July 2020 - 08:15 AM.

  • Lightwulf likes this

#8 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 09 July 2020 - 10:34 AM

^ Generally, what you'll want to do is have all your files be '.zs' or '.zh' (.zh will likely tell you that they should be that). There's no REAL difference, it's just semantic (meaning, the compiler doesn't actually care, it's just to help scripters tell the difference)

What you can easily do is create ANOTHER file, which has nothing but import statements in it. Have that file import all your other files. Then, in ZQ, in the script buffer, import THAT file only. Then, every time you modify a script, you won't ever need to edit the buffer again; just click 'Compile'.

 

I also highly recommend using Notepad++ for editing scripts. You can set it up to highlight keywords and such for you, making it exponentially easier to edit/view scripts. By default, the best option is likely C++ highlighting; but that won't cover everything. By going to 'Language -> Define your language -> Import' you can import a custom language file. (Note: After importing, you may need to close and re-open Notepad++ for the highlight to work). I've developed custom highlighting for this purpose, which is available here: https://tinyurl.com/ZScript-NPP


  • ShadowTiger and Lightwulf like this

#9 Shmirko

Shmirko

    GOATED

  • Members
  • Real Name:Mirko Metsue Tombeur
  • Location:Kessel-Lo, Leuven

Posted 10 July 2020 - 07:56 AM

I am not able to use zh and zs files only z files. When I make the scripts z files and import them, I get the same error as before. So there must be something wrong with the actual scripts.

 

Were there errors that it couldn't find one or both of those files? If it says anything beyond "failure to parse imported file" then you know the error is with one of the scripts, but otherwise it's with whatever path you specified, it was unable to find that file. 

 

It does say something beyond failure to parse imported file, so there must be something wrong with the scripts, not the method I use.

 

maybe could you look at the scripts to find out the issue?

 

I'll just copy the links again for convenience: https://www.purezc.n...showtopic=46059https://www.purezc.n...=scripts&id=119

 

Man, I am bad at this kinda stuff...

Glad you guys are helping me tho!


  • Lightwulf likes this

#10 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 10 July 2020 - 10:25 AM

Hmm...Both scripts compiled fine for me. My first guess would be you're missing a header. Do you have import "std.zh" (or #include) at the top of the buffer? Some scripts will require additional files. Some are packaged with ZC itself, others are on the database, and the scripts will tell you which they need. In this case the majority of scripts use std.zh, it's basically always assumed that it's needed.

If that's not the cause, we'll have to take a look at the errors themselves. After compiling, the errors ZQuest spits out should also be printed to allegro.log. Can you copy the errors from there and paste them here (preferably in [code=auto:0] tags so the forum software doesn't mangle any of it).

Sorry for the slow troubleshooting process btw. You're not doing anything wrong so much as the process itself is rather technical. But once you get that down and recognize the more common snags yourself it gets much easier.
  • Lightwulf likes this

#11 Shmirko

Shmirko

    GOATED

  • Members
  • Real Name:Mirko Metsue Tombeur
  • Location:Kessel-Lo, Leuven

Posted 10 July 2020 - 12:09 PM

Hmm...Both scripts compiled fine for me. My first guess would be you're missing a header. Do you have import "std.zh" (or #include) at the top of the buffer? Some scripts will require additional files. Some are packaged with ZC itself, others are on the database, and the scripts will tell you which they need. In this case the majority of scripts use std.zh, it's basically always assumed that it's needed.

If that's not the cause, we'll have to take a look at the errors themselves. After compiling, the errors ZQuest spits out should also be printed to allegro.log. Can you copy the errors from there and paste them here (preferably in [code=auto:0] tags so the forum software doesn't mangle any of it).

Sorry for the slow troubleshooting process btw. You're not doing anything wrong so much as the process itself is rather technical. But once you get that down and recognize the more common snags yourself it gets much easier.

 

I have std.zh in my zquest folder, idk if it needs to be in the same folder the quest is in tho.

 

I have looked at the allegro.org file, and found the error for loading up the z-file for the NPC script:

Pass 1: Parsing
Pass 2: Preprocessing
Pass 3: Building symbol tables
tmp, line 21: Error S09: Variable FFCF_OVERLAY is undeclared.
tmp, line 21: Error S09: Variable FFCF_OVERLAY is undeclared.
tmp, line 46: Error S09: Variable DIR_DOWN is undeclared.
tmp, line 48: Error S09: Variable DIR_UP is undeclared.
tmp, line 52: Error S09: Variable DIR_LEFT is undeclared.
tmp, line 54: Error S09: Variable DIR_RIGHT is undeclared.
tmp, line 123: Error S09: Variable DIR_UP is undeclared.
tmp, line 124: Error S09: Variable DIR_DOWN is undeclared.
tmp, line 125: Error S09: Variable DIR_RIGHT is undeclared.
tmp, line 126: Error S09: Variable DIR_LEFT is undeclared.
tmp, line 130: Error S09: Variable DIR_RIGHT is undeclared.
tmp, line 130: Error S09: Variable DIR_LEFT is undeclared.
tmp, line 130: Error S09: Variable DIR_DOWN is undeclared.
tmp, line 130: Error S09: Variable DIR_UP is undeclared.

It says that all that stuff is "undeclared". IIRC that is what the error says if I load up any other script, but the undeclared thing are a bit different, depending on what is needed for the script, I think.


  • Lightwulf likes this

#12 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 10 July 2020 - 01:50 PM

All of those constants appear in std_constants.zh, which is included as part of std.zh. If you're getting those errors, then std isn't getting imported correctly. In addition to having std.zh in your ZQuest folder, you'll need to have this line at the top of your script file:

 

import "std.zh"

  • Lightwulf likes this

#13 Shmirko

Shmirko

    GOATED

  • Members
  • Real Name:Mirko Metsue Tombeur
  • Location:Kessel-Lo, Leuven

Posted 10 July 2020 - 02:18 PM

 

All of those constants appear in std_constants.zh, which is included as part of std.zh. If you're getting those errors, then std isn't getting imported correctly. In addition to having std.zh in your ZQuest folder, you'll need to have this line at the top of your script file:

import "std.zh"

 

I have put all my files in the same folder, made one big txt file where I put all the scripts in, with the import ''std.zh command'' on top, and turned the file into a z-file. Then I imported and clicked compile, but I got this error:

Pass 1: Parsing
Pass 2: Preprocessing
Pass 3: Building symbol tables
tmp, line 194: Error S04: Function SetInput was already declared with that type signature.

  • Lightwulf likes this

#14 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 10 July 2020 - 02:29 PM

Okay, what that error means is that two different scripts you have tried to make a function called SetInput. Assuming they're both the same function and it's just used by two different scripts, what you can do to make it work is go to line 194, find that function, and delete it.

 

If you paste your script file here (the easiest way is to copy it all to pastebin, upload, and then copy the link here), it'll be easier for us to look over and spot any issues like this.


  • Lightwulf and Shmirko like this

#15 Shmirko

Shmirko

    GOATED

  • Members
  • Real Name:Mirko Metsue Tombeur
  • Location:Kessel-Lo, Leuven

Posted 10 July 2020 - 02:45 PM

Ait fo sho!

 

https://pastebin.pl/view/6549582c


Edited by Shmirko, 10 July 2020 - 02:47 PM.

  • Lightwulf likes this



Also tagged with one or more of these keywords: Scripts, NPCs

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users