ZBrushCentral

Store the current value and call it after restart

I made a slider, I set the current value to 3 (this value can be customized by the user), I think the next restart will still be my customized value, how can I write a script, I think it can use memory block, but I have been testing for a long time with no results, hope to get your help! thanks

http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/technical/

thanks

I still can’t solve it, can anyone please help?

Hi,

You can do it like this:

[VarDef,SettingsFile,"ZPUBLIC_ZPluginData/MySliderMem.dat"]


[If,[MemGetSize,MC_MySliderMem],
	//memblock exists - do nothing
	,//else create it
	[If,[FileExists,SettingsFile],//if there's a file create memblock from it
		[MemCreateFromFile,MC_MySliderMem,SettingsFile]
		,//else create memblock with default value
		[MVarDef,MC_MySliderMem,1,0]
		[MVarSet,MC_MySliderMem,0,50]//50 is the default slider setting
	]
]

[ISubPalette,"Zplugin:My Plugin"]

[ISlider,"Zplugin:My Plugin:My Slider",[MVarGet,MC_MySliderMem,0],1,0,100
,"Popup info Text",
//save new slider value to memblock
[MVarSet,MC_MySliderMem,0,[IGet,0]]
//save memblock to file
[MemSaveToFile,MC_MySliderMem,SettingsFile,1]
,,1]

The file name set at the beginning will save to the C:\Users\Public\Documents\ZBrushData2022\ZPluginData folder - the “ZPUBLIC_” is a short way of telling ZBrush you want the path to the ZBrushData2022 folder.

When the plugin is first loaded when ZBrush starts, the memblock code runs and creates the memory block from the file if it exists, or uses default values if it does not.

When the user adjusts the slider the new value is saved to the file, so it is there ready for the next session.

Thank you for your guidance, I have gained a lot and opened the door for me to write scripts. Thank you so much!

1 Like

You are welcome! I’m glad you find zscript interesting.

1 Like

Great, I can’t live without it

2 Likes