1. #1
    Senior Member Follow User Gallery
    Join Date
    Sep 2004
    Posts
    499

    Default How do i make my zscript load a tool automatically?

    i'm working on a tutorial that shows people how to incorporate Zbrush into their low-poly workflow.. this tutorial spans multiple programs (maya, zbrush, photoshop, etc), so naturally i'm working with lots of files here. i'm providing the base-level ztools and other project files with the tutorial, and at one point in the zscript, i need to load a custom ztool. when i playback my zscript though, it doesnt actually load the file, it opens the file dialog though. is there any way i can make it load the file automatically?

    specifically i'm looking to replace this line:
    [IPress,Tool:Load Tool]

    any ideas? or should i just put a 'note' in there and tell people to browse for the correct ztl file?

  2. #2
    Senior Member Follow User Gallery
    Join Date
    Sep 2004
    Posts
    499

    Default

    just figured it out actually.. for those wondering:

    [FileNameSetNext,toolname.ztl]
    [IPress,Tool:Load Tool]

    just make sure toolname.ztl is in the same folder as your zscript

  3. #3
    Member Follow User Gallery
    Join Date
    Apr 2004
    Location
    Graveyard
    Age
    36
    Posts
    67

    Default

    btw, if my script file is in another folder, how to specify that? thanks

  4. #4
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    osamu, you can specify the path like this:

    [FileNameSetNext,"ZBRUSH_ZTools\subfolder\toolname. ztl"]

    where 'subfolder' is the name of a subfolder of the ZTools folder.

    Or you can use:

    [FileNameSetNext,"subfolder\toolname.ztl"]

    if the file you are loading is in a subfolder of the folder where your zscript resides.

    HTH,
    Marcus

  5. #5
    Senior Member Follow User Gallery
    Join Date
    Jun 2003
    Location
    Hawaii,USA
    Posts
    1,765

    Default

    [CODE] [FileNameSetNext,toolname.ztl]
    [IPress,Tool:Load Tool] [/CODE]

    ok Cool!!!!

    But what if we wanna Load and play a wave file?


    here is a Zscript I found By Muvlo Redond that will allow user to play a wavefile....



    [CODE] // Muvlo Redond
    // 20040409

    Simple test of the new ZScript audio playback features in Z2

    [IButton,"Play Sound","Click to load and play a WAV file",
    [VarDef,filename,""] // Declare a variable to store the file's name in
    [VarSet,filename, // Set the variable here, not in the VarDef, so that it will work without reloading the ZScript
    [FileNameAsk, // Ask the user for the WAV file
    [StrMerge,"WAV (*.wav)", // This bit here is because I don't know what the character
    [StrFromAsc,124],"*.wav" // used in the documentation is, but I found the ASCII number
    ],,"Load audio file..." // with StrFromAsc...
    ]
    ]
    [If,[StrLength,filename], // If the the user didn't click cancel to the Open dialog...
    [MemCreateFromFile,AudioFile,filename] // Create a memory block and load the audio file
    [SoundPlay,AudioFile,1] // Play the sound, pause at this point 'til the file is done playing
    [MemDelete,AudioFile] // Delete the mem block
    ]
    ] [/CODE]



    What I want is to have a folder full of audio clips, and at certain points in My Zscript, I que the .Wave file and it gives a playback of some boaring Over descriptive Dialog of what I just painted or modeled...

    anyways, anyone know how to que/play a wave file from inside Zscript?

    I am going to go and hack away at it for a while... If I get it, I will return here and Share my findings

    also If end user has .OGG and .MP3 codecs, will we be able to use that format?
    or is it plain old .WAV files only ?

    I am trying to save bandwidth...


    TIA for any help
    For Hire.

  6. #6
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    This is straightforward enough. You just point to each wav file in turn. This is for a folder called "wavs" containing the wav files which is a subfolder of the folder containing the zscript.

    [CODE][MemCreateFromFile,MC_soundmem,"wavs\sound01.wav"]//Loads first sound file into memory
    [SoundPlay,MC_soundmem,0]/*Plays the sound but doesn't wait before going on - a "1" would stop the
    zscript and play whole sound before going on.*/
    [/CODE]

    I've used "MC_soundmem" to name the memory block because that's more likely to be a unique name than the "AudioFile" in Muvlo's example. Non-unique memory block names could cause problems with other zscripts.

    Later in your script you put your next sound file:
    [CODE]
    [MemDelete,MC_soundmem]//Clears memory to make room for next file
    [MemCreateFromFile,MC_soundmem,"wavs\sound02.wav"]//loads next sound file
    [SoundPlay,MC_soundmem,1]//Plays the sound to the end
    [MemDelete,MC_soundmem]//Clears memory at end of zscript[/CODE]

    If you use '0' in the [SoundPlay] code (as in my first example) you need to make sure that there's enough time for the sound to play before the next sound plays. You might use [ISet,Zscript:Replay Delay,500] to slow down playback or insert pauses using [Delay,1] (1 second pause).
    If you use '1' in the [SoundPlay] code then the wav file will play out before the zscript continues. It's a good idea to use this if you play a sound at the end of your script.

    I don't think that you can play any other files but wavs like this but I've not experimented. Mono will give smaller files, of course. Apologies for the poor sound in my example!
    Attached Files Attached Files

  7. #7
    Senior Member Follow User Gallery
    Join Date
    Jun 2003
    Location
    Hawaii,USA
    Posts
    1,765

    Default :) Nice

    Thankyou verry much Marcus

    This looks very easy to do, I am going to go and give this a try

    in the future, i see people useing the sounds to make a Machieanimae cinemas

    Well anyways, Thanks again Marcus, I really appreciate your help
    For Hire.

Posting Permissions

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