Jump to content

Photo

Getting Back Into Scripting - Questions


  • Please log in to reply
6 replies to this topic

#1 kurt91

kurt91

    Follower of Destiny

  • Members
  • Real Name:Kurtis
  • Location:Eastern Washington University

Posted 16 June 2021 - 03:16 PM

Forgive me if I don't respond often, I'm in an area where I don't often get an Internet connection I can write replies with. My grandparents are on dial-up with a barely-functioning router, in a cell-phone dead-zone. I'm actually writing this post in Notepad, so I can copy/paste it and hopefully get it posted before the connection craps out. I can manage viewing topics somewhat, though, so I will be able to see responses.

Anyways, I'm looking at scripting again. I've taken a handful more programming courses, and I think this would work for something I can do over the summer to stay in practice. I've gotten used to how C and Java programming works, though, and wanted to know if some of the things I've come to take for granted are possible in ZScript.

Mainly, I want to know about multiple script files in a single project. I know that external headers can be imported, such as ghost.zh, via simply adding in ' import "ghost.zh" '. What about other files, like additional .z files? For read-ability's sake, I'd like to keep all of non-global scripts as separate files, and just import them into the main file that's loaded into the quest script buffer. That way, if I'm having problems with a specific script, I can load up that file and only see the code for that script, rather than have to navigate a mile-long single .z file.

Also, I don't suppose there's anything for Notepad++ to help with writing ZC scripts? Right now, I'm telling it that I'm coding in C, so it at least colors my comments and makes it easier to tell what is actually part of my code and what isn't. It would be nice if there was a full ZScript option to be able to distinguish individual function names, variables, etc. Does one of these exist?

 

Oh yeah. If it matters, I'm using ZC 2.55 - Alpha 92



#2 Mani Kanina

Mani Kanina

    Rabbits!

  • Members

Posted 16 June 2021 - 04:59 PM

You can use the import statement for any file, yeah. So splitting up your projects into multiple files is very much possible, in fact, it would be the recommended approach if you ask me for organization.



#3 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 16 June 2021 - 07:03 PM

When you use import it'll look first in the headers folder, then the include folder, then  then the main ZC directory. There's also #include which does the same but looks in include first. You can specify a subfolder, for example

import "MyQuest/MyScripts/MyScriptFile.z"

That'll look for a script folder inside a folder for your project. You can use this to better organize your script files into subfolders when you start to have a lot of them. 
 
For file extensions it really doesn't matter what you use as long as it's plaintext. I named my script file MooshIsA.clown once.
 
There are ZScript language files for Notepad++, but I don't use them so I don't exactly have them on hand.

 

Edit: Got a download link from Dimi

https://cdn.discorda...t_07FEB2021.xml


Edited by Moosh, 16 June 2021 - 07:36 PM.


#4 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 16 June 2021 - 08:59 PM

Import statements can import any file, extension is not limited. By standard, ".z" is a deprecated format, due to conflicts with archiving software. The 'official' extensions for scripts are ".zs" and ".zh" only. But, ZQ will take a ".txt" if you tell it to, so no strong enforcement of that.

 

I would offer my np++ language highlighting, but it seems Moosh already found a link. 

 

As for script organization, I tend to split things up categorically. I have all my global scripts in one file, all my global constants in another file, then a file for items, a file for enemies, a file for anything that seems to deserve one. I mean, have a look at my MM2D folder organization. ...Yes, those are still ".z", I haven't updated it in 2 years.



#5 Mitchfork

Mitchfork

    no fun. not ever.

  • Members
  • Real Name:Mitch
  • Location:Alabama

Posted 17 June 2021 - 10:13 AM

Yeah - I would really recommend something like this (long spoiler block):

Spoiler

Then in ZQuest, the only thing in your buffer is something like

import "crucible.z"

to point to this file. Makes maintaining and editing way easier than putting actual script bodies inside your buffer.



#6 kurt91

kurt91

    Follower of Destiny

  • Members
  • Real Name:Kurtis
  • Location:Eastern Washington University

Posted 17 June 2021 - 01:26 PM

Okay, so any file can be imported, and I downloaded the link Moosh gave to get NotePad++ to work fully with ZScript. This is a pretty big help, so thanks! Next thing to do is to pull up my old script files and start looking into porting them to the new 2.55 setup.

 

Actually, one more question...

 

I'm going to port everything to 2.55 Alpha 92, and noticed that there's a lot of changes regarding headers and an entire script folder hierarchy already set up by default. Does this version of zquest already look in the appropriate folders in this setup, and I can just start placing my converted scripts into the appropriate spots with a simple import "script.zs" line, or do I still need to list all the sub-directories en-route to my files? Also, I read that some of the commands from some external headers have been moved to the default set of commands. I currently have the following list of headers set up:

 

import "std.zh"
import "string.zh"
import "stdExtra.zh"
import "ffcscript.zh"
import "ghost.zh"

 

Is there anything I'm missing that I ought to have added to that list, or anything that's now obsolete and no longer needed? I'm noticing that quite a few scripts that I originally had from making requests now have public versions available, though I haven't looked to see if they're the same scripts and just updated, or different scripts that do the same thing. Either way, if they still work the way I remember them, that should save me a good bit of time and bug-fixing.


Edited by kurt91, 17 June 2021 - 01:47 PM.


#7 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 17 June 2021 - 02:37 PM

Okay, so any file can be imported, and I downloaded the link Moosh gave to get NotePad++ to work fully with ZScript. This is a pretty big help, so thanks! Next thing to do is to pull up my old script files and start looking into porting them to the new 2.55 setup.

 

Actually, one more question...

 

I'm going to port everything to 2.55 Alpha 92, and noticed that there's a lot of changes regarding headers and an entire script folder hierarchy already set up by default. Does this version of zquest already look in the appropriate folders in this setup, and I can just start placing my converted scripts into the appropriate spots with a simple import "script.zs" line, or do I still need to list all the sub-directories en-route to my files? Also, I read that some of the commands from some external headers have been moved to the default set of commands. I currently have the following list of headers set up:

 

import "std.zh"
import "string.zh"
import "stdExtra.zh"
import "ffcscript.zh"
import "ghost.zh"

 

Is there anything I'm missing that I ought to have added to that list, or anything that's now obsolete and no longer needed? I'm noticing that quite a few scripts that I originally had from making requests now have public versions available, though I haven't looked to see if they're the same scripts and just updated, or different scripts that do the same thing. Either way, if they still work the way I remember them, that should save me a good bit of time and bug-fixing.

The folders that will be scanned when looking for imported files include:

-The ZC folder itself

-Any folders listed in "ZScript->Compiler Settings" under "Include Paths", which should default to "include/;headers/;scripts/" (semicolon-delimited).

I would not ever remove "include/;" from the list, as that is where std_zh stuff is. You can add things as needed to point to where you want to auto-search. 

 

It will search FROM *all* of those folders, using subdirs. So, if I did 'import "foo/foo.zs"', it would check "ZC/foo/foo.zs", then "ZC/include/foo/foo.zs", then "ZC/headers/foo/foo.zs", etc.

You can use '#include' instead of 'import' in 2.55, i.e. '#include "std.zh"'. The difference is that '#include' will search all of the include paths BEFORE it searches the ZC folder, while import searches the ZC folder first, before the include paths.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users