1. #1
    Senior Member Follow User Gallery
    Join Date
    Oct 2006
    Posts
    151

    Default VarSave & VarLoad

    I'm trying to save some variable data to a seperate file so the person using my script can pick up where they last left off before closing ZBrush.

    I have 3 variables to save, they contain the individual R, G and B channels.

    I define my variables at the beginning of the script. And later in the script, this is how the value get stored...

    [VarSet, colorStoreR, Color:R]

    This sets the variable, colorStoreR, to the value of the current R color channel. Next, saving the channel to a file..

    [VarSave,colorStoreR,session]

    Now I have the correct color information stored in my variable, and I am assuming that those values are also being stored into a file called session.zvr

    Next I got about loading the stored values. When you click the load button this is the order of execution.

    [VarLoad,colorStoreR]

    I assumed that this line would set the variable to the previously saved value. And then finally..

    ISet,Color:R,colorStoreR

    Which sets the Red color channel to the current value of the ColorStoreR varialble....

    PROMBLEM

    The script does create a session.zvr file but it's either not saving properly or its not reloading properly. All the variables are stuck in their declared 0,0,0 states.

  2. #2
    Senior Member Follow User Gallery
    Join Date
    Oct 2006
    Posts
    151

    Default

    Well I got it finally, I needed a seperate .zvr for each individual color channel.

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

    Default

    The other way you can do it is to declare a list variable:

    [VarDef, myColors(3),0] //declares a list variable with 3 items, initialized to 0


    Then assign the colors to it (the index starts at zero):

    [VarSet, myColors(0), Color:R]
    [VarSet, myColors(1), Color:G]
    [VarSet, myColors(2), Color:B]

    To save you simply save the variable thus:

    [VarSave, myColors, settings.zvr]

    and load in the same way.

  4. #4
    Senior Member Follow User Gallery
    Join Date
    Oct 2006
    Posts
    151

    Default

    Oooh thats elegant. Thanks for the tip.

Posting Permissions

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