1. #1
    Senior Member Follow User Gallery
    Join Date
    Jul 2002
    Location
    Copenhagen
    Age
    45
    Posts
    2,561

    Default Tip: Zscripting Workflow 2015

    Hello,

    I thought it might be useful to both new and old zscriptors alike if we could share our zscripting workflows. Methodological, practical or whatever you feel like.

    I will try to describe the tools I use and how I combine them to create a more pleasing zscripting workflow. Although I am now predominantly a Mac user most of the programs listed have a Windows counterpart or equivalent. If I don't mention a Windows equivalent please feel free to add your own personal favourite and perhaps why you find it valuable. It does not matter if it is Vim or Notepad, whatever gets the job done.

    Just remember, every time you use a keyboard shortcut you postpone hair loss.

    Have you finished searching Google about hair loss? Then let's get on with it.


    Editor

    Every zscriptor needs a good editor that they can cuddle up to during the long lonely nights of zscripting. I have tried numerous editors (Ultraedit, available on Windows, Mac and Linux; Notepad++, available on Windows) and finally settled on Sublime Text a couple of years ago (available on Windows, Mac and Linux).

    It has a spartan interface and you change the vast majority of settings by editing text files, which can be off-putting when you are just starting out. But if you want to focus on the task at hand the lack of interface is wonderful (shortcuts, remember?) and the customisation through text files is weirdly liberating (what I don't see I don't worry about). It supports nearly all syntaxes under the sun and has a superb collection of user created plugins with a vibrant community always adding more. The fuzzy logic search is great for finding a function or file or even triggering a Sublime Text command. Just hit SHIFT + CMD + P to trigger the Command Palette and type SSZ which will Set Syntax Zscript or STZ which will also trigger the Zscript syntax. It is fuzzy and very intuitive.

    As the paragraph above mentioned a couple of times it also has ZScript syntax, thanks to Britney Zpheres () and I am fine-tuning a build system that automatically reloads the zscript in ZBrush (more on that later). Snippet support is included so typing ‘ibu’ and hitting TAB could insert the IButton syntax with support for tabbing between the variables.


    Documentation

    Marcus has done an amazing job of documenting the zscript language but I like to have all my documentation in one place. Dash for OS X and iOS (separate purchase) is my go to place for looking up functions in C, OS X, iOS, .net, Javascript, PHP, CSS, HTML and ... well you get the point. Dash has documentation for nearly everything and is blazingly fast even when searching through all the docsets at once. It also integrates with Sublime Text and a dozen other editors so you can CMD + click IButton and get taken to the definition in Dash. Well, you can when I actually finish the zscript documentation for Dash. Docsets are stored locally so you can browse without an internet connection.

    If you have 20GB to spare you can even download a data dump of stackoverflow.com (updated quarterly) which is both insanely cool and simply insane at the same time. In any case try out Dash, you will absolutely love it. There is an equivalent for Windows called Velocity and another called Zeal for Windows and Linux (free and open source). For Android there is LovelyDocs.


    Documenting the Programming Process

    During any project I like to extensively document the process from the beginning, not just for me but also for the user. After iterating through the development of a ZPlugin you can become too familiar with the way it functions that you cannot see how anybody would not understand you need to press button B before button A.

    Flowcharts are a simple, obvious way of laying out the foundation of a ZPlugin and a great way to revisit your ZPlugin with fresh eyes when writing documentation for the user. I tend to draw them on paper as I mainly work on a laptop, have little screen real estate and like to have them next to me. If anyone has any recommendations towards flowcharting or mind mapping apps I would love to hear about them.

    For everything else I use .txt files written in Multi Markdown (a variant of Markdown). If you have no idea what Markdown is then take one single minute to read the Markdown basics, that is all the time it takes.

    To begin with I managed the text files with Scrivener (available on OS X and Windows) but migrated to Ulysses (OS X and iOS) due to it’s more focused writing experience. Ulysses, like Sublime Text, is wonderfully devoid of interface clutter and has excellent search functionality. Like Scrivener it also allows you to attach tags, notes and images to each text document.

    Ulysses has pretty good export functionality (html, pdf, ePub and rtf) but I use Marked 2 (OS X only) to export into more conventional formats; many people still want documents in Microsoft Word format . I am not to familiar with Markdown apps for Windows but I have heard MarkdownPad should be good.


    Testing ZPlugins

    Manually reloading your zscript after every code change can be irksome but at least you know it will reload properly. However, reloading a zplugin is bound to fail at the second, the first, who knows, maybe the fifth reload. Speed and reliability is usually high on any programmers wishlist and luckily we can address both.

    When testing Zplugins (Zscripts that live in the ZBrush palettes) you should create two ZPlugins; the main ZPlugin that you will release and a reload ZPlugin whose sole purpose in life is to please you.

    If your Zplugin is called boxify.txt and resides in the ZPlugin > Make Box subpalette you would create reloadboxify.txt which would contain the following:

    [IButton, "Zplugin:Reload Make Box", ,
    [If, [IExists, "Zplugin:Make Box"], [IClose, "Zplugin:Make Box"]]
    [FileNameSetNext, "Boxify.text"]
    [IPress, "ZScript:load"]
    ]

    That only takes care of reloading your Zplugin. Every time you change something you still need to save the script in your editor, switch to ZBrush and press the Zplugin > Reload Make Box button. Manageable? I guess. Can we do better? You bet my receding hairline we can.

    I am currently polishing a Mac OS X app that you can call from any editor that supports custom build configurations. In Sublime Text, for example, I would press CMD + B to start the build process which simply sends some arguments to my app which in turn sends a key press to the Reload Make Box button in ZBrush and makes ZBrush the frontmost app. Which is kind of nice.


    Testing Dynamic / Shared Libraries

    Once attached to the ZBrush process, dynamic libraries are not closed by ZBrush. That means you can compile however many times you want but you will not see the changes until you reload ZBrush and the Zplugin that calls your library.

    I have not gotten around to Windows yet but on OS X you can change the build settings so as to compile a library with an incrementing value; mylib01.lib, mylib02.lib and so forth. Back in ZBrush your script would check for the highest value filename .lib and load that (I am sure there is a better way). You will end up with many libraries attached to the ZBrush process and many many warnings in Console.app about calling method X while library Y is the first instantiated library with that method. But you will have saved yourself a lot of time from restarting ZBrush. I am not calling this method infallible yet as I still have more testing to do. But if you want to give it a shot then try the following:

    Set the Current Project Version in the Versioning section of your projects Build Settings to your start integer value. Still in the Build Settings change the Product Name, found in the Packaging section. Set it to: yourproductname$(CURRENT_PROJECT_VERSION). To complete the setup select Build Phases and add a new Run Script. The script should simply be a call to a command line executable: agvtool next-version. From now on you will output yourLib1.lib, yourLib2.lib, etc..




    That is it from me. I hope you will share any cool tool you find useful to zscripting or just your regular workflow. As long as you find it useful then please share.
    Last edited by TVeyes; 03-31-15 at 10:56 PM. Reason: Graaamaar
    Mark

  2. #2
    Senior Member Follow User Gallery
    Join Date
    May 2007
    Location
    Bellevue,WA
    Posts
    500

    Default

    This is really Awesome... You have no idea of how I appreciate this Thread
    __________________________________________________

    My GumRoad

    ZTree
    Terrain Tools (OS X)
    Terrain Tools (Win x64)

  3. #3

    Default

    I don't know much about programing or Zscripting but seeing your passion for it is very inspiring, hope I can learn enough to make my own plugin someday =)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •