4_Commands
2025/5/5
Comments 注释
// My Comment - 行注释
[IPress,]/* My Comment */[IPress,] // 块注释 -之间所有内容都会变灰

[IButton]
按钮
三种不同类型的Button控件
[IButton, Button name, Popup info Text,
Commands group to execute when button is pressed,
Initially Disabled? (0:Enabled(ByDefault) NonZero:Disabled),
Button width in pixels (0:AutoWidth NonZero:Specified width),
Optional hotkey,
Optional button icon (.psd .bmp + .pct for Mac Systems),
Button height in pixels (0:AutoHeight NonZero:Specified height)]
/*
[按钮,按钮名称,弹出信息文本,
按下按钮时要执行的命令组,
按钮是否初始处于禁用状态?(0:启用(默认情况下) 非零值:禁用),
按钮的像素宽度(0:自动宽度 非零值:指定宽度),
可选的热键,
可选的按钮图标(.psd .bmp + .pct 格式适用于 Mac 系统),
按钮的像素高度(0:自动高度 非零值:指定高度)]
*/
按钮名称
[IButton, "my Button", ]
(加双引号能包括在内的所有文本内容,包括空格号)

按钮位置
[IButton, "ZPlugin:my Button", ]
(双引号内添加路径信息时 也就是xxx:
会在对应的工具窗口路径下创建)

添加Note提示
[IButton, "my Button", "my Button info Text",
[Note, "Hello,World!",,1]
]

displayTime 显示时间

Disabled 按钮禁用
[IButton, "my Button", "my Button info Text",
[Note, "Hello,World!",,1,]
,1,
]

比例宽度
- 长
[IButton, "my Button", "my Button info Text",
[Note, "Hello,World!",,1,]
,,100, /* 像素 */
]
[IButton, "my Button", "my Button info Text",
[Note, "Hello,World!",,1,]
,,.0.5, /* 百分比 0.5% */
]
- 高
这个50所在的位置就是高了。
[IButton, "my Button", "my Button info Text",
[Note, "Hello,World!",,1,]
,,100,,,50,
]
快捷键
可以通过这个网站获取 keycode Key and Character Codes vs. Event Types
比如按了 A 键位 那么 网站显示的 keyCode 则是 65

那么代码则是,执行按快捷键也会提示Hello,World!
[IButton, "my Button", "my Button info Text",
[Note, "Hello,World!",,1,]
,,100,65,
]
图标按钮
我们需要准备PSD文件 放在插件目录下的自定义文件夹即可
例如: 我们准备一个长方形为 150*50 像素的PSD 图标。
[IButton, "my Button", "my Button info Text",
[Note, "Hello,World!",,1,]
,,150,65,"Data/hello.psd",50
]
那么代码上的比例也得一起改。

字体 隔断 颜色
[IButton, "my Button", "my Button \n 0x2B821F info Text",
[Note, "Hello,World!",,1,]
,,150,65,"Data/hello.psd",50
]

\n
下一行0x2B821F
web color#2B821F
0x
等于#
[ISwitch] 开关
[ISwitch, ClickMe, 1, "Info text", [MessageOK, On], [MessageOK, Off]]
[ISwitch,
Button Text, //名称
Initial state (1=pressed,0=unpressed), //初始状态
Popup info Text, //弹出提示文本
Commands group to execute when button is pressed, //按下时的命令
Commands group to execute when button is unpressed, //松开时的命令
Initially Disabled? (0=Enabled(ByDefault) NonZero=Disabled), //是否禁用
Button width in pixels (0=AutoWidth NonZero=Specified width), //宽度
Button height in pixels (0=AutoHeight NonZero=Specified height), //高度
Optional button icon (.psd .bmp ) //图标
]
[If Else] Statements If Else 语句
if-else 语句用于检查某事物是真还是假,
为真,则可以运行某些命令,如果为假,则可以运行其他一些
[IButton, "If Check",,
[If,((5>3)&&(4<2))||(4>=4), //true
[Note, true]
, //else·false
[Note, false]
]
- Evaluation Operators-
< Smaller than
> Greater than
<= Smaller or equal than
>= Greater or equal than
== equal to
&& And
|| or
! Not
[If,
True Or False Evaluation ,
Commands group to be executed if false (is zero),
Commands group to be executed if true (not zero)
]
[IGet] [ISet] [IToggle] [IPress] [IUnPress]
[ISwitch, "My Switch",0,"My Pop up Info",
// // Commands to execute when pressed 按下时要执行的命令
// [Note, Pressed]
,
// // Commands to execute when unpressed 未按下时要执行的命令
// [Note,UnPressed]
,1,100]
[IEnable, "Zscript:My Switch"]//bug workaround 错误解决方法
[IButton, Get,,
[If,[IGet,"Zscript:My Switch"], //这种情况会发生
[Note, Pressed]
, // else do this 否则就这样做
[Note,UnPressed]
]
]
// Iset 使用on off 设置 按钮的开关
[IButton, On,,
[ISet,"Zscript:My Switch",1]
]
[IButton, Off,,
[ISet,"Zscript:My Switch",0]
]
// Ioggle 顾名思义 切换 也就是切换启用或者关闭的切换按钮
[IButton, Toggle,,
[IToggle,"Zscript:My Switch"]
]
// 就点一下 Press 启用 或者 unpress 关闭 和 On off 一样就是不需要数值变量确定
[IButton, Press,,
[IPress,"Zscript:My Switch"]
]
[IButton, UnPress,,
[IUnPress,"Zscript:My Switch"]
]
/*
[[IGet,
Interface item path //界面项路径
]]
[ISet,
Interface item path, // 界面项路径
value, 0/1 // 0/1 判断启用/关闭
Secondary value
]
[IToggle,
Interface item path //界面项路径
]
[IPress,
Interface item path //界面项路径
]
[IUnPress,
Interface item path //界面项路径
]
*/
Radio Button 单选按钮
// Learn - ZScript Fundamentals - Radio Button 单选按钮
// https://www.youtube.com/watch?v=kKZ4UF57-HI&list=PLuvCsqbtUSFBDPXvB3SScoMD1VapO9Z0v&index=11
//目前有三个单选按钮-A是启用的如果点击B那么关闭AC 同理点击C 则AB是关闭状态
// Button A
[ISwitch, "A",1,"My Pop up Info",
[Iunpress,"Zscript:B"]
[Iunpress,"Zscript:C"]
,
]
[IEnable, "Zscript:A"]
// Button B
[ISwitch, "B",0,"My Pop up Info",
[Iunpress,"Zscript:A"]
[Iunpress,"Zscript:C"]
,
]
[IEnable, "Zscript:B"]
// Button C
[ISwitch, "C",0,"My Pop up Info",
[Iunpress,"Zscript:A"]
[Iunpress,"Zscript:B"]
,
]
[IEnable, "Zscript:C"]
[ISlider] 滑动条
// Learn - ZScript Fundamentals - [ISlider] 滑块
// https://www.youtube.com/watch?v=kKZ4UF57-HI&list=PLuvCsqbtUSFBDPXvB3SScoMD1VapO9Z0v&index=12
//一个滑块-目前20-最大值100
[ISwitch, Mysitch, 1, ]
[ISlider,
"My slider", 20, 10, 0, 100,"hallo",
// [Note, "Hello There",,.5] //执行打印文本0.5秒后消失提示
[Note,[IGet,0]] // 直接获取当前的滑条值
// [Note,[IGet,-1]] // -1 获取上一个控件的状态 1 / 0
// [Note,[IGet,1]] // -1 获取下一个控件的状态 0 / 1
,,200
]
[ISwitch, Mysitch, 0, ]
[IButton, set Slider on 50,,
[ISet,"Zscript: My slider",50]
]
/*
[ISlider,
Slider name,
CurValue,
Resolution,
MinValue,
MaxValue,
Popup info Text,
Commands group to execute when value is changed,
Initially Disabled? (0:Enabled(ByDefault) NonZero:Disabled),
Slider width in pixels (0:AutoWidth NonZero:Specified width)
]
// 滑块名称
// current value - 当前值
// 解析度
// 最小值
// 最大值、
// 弹出信息文本、
// 值更改时要执行的命令组、
// 初始禁用?(0:已启用(默认) 非零:禁用)、
// 滑块宽度(以像素为单位)(0:自动宽度 非零:指定宽度
*/
NumberVariables 数值变量
// Learn - ZScript Fundamentals - Number Variables 数字 变量
// https://www.youtube.com/watch?v=kKZ4UF57-HI&list=PLuvCsqbtUSFBDPXvB3SScoMD1VapO9Z0v&index=13
// 变量是任何计算机语言中非常重要的一部分,变量名中不能有任何空格
//var 表示变量 Def用于定义
[VarDef,myNumberVar,5]// 基础数字变量
// [VarDef,myStringVar,""]// 基础字符串变量
// [VarSet,myNumberVar,5] //Set变量为最新变量值
// [VarSet,myNumberVar,myNumberVar+5]
// [VarSet,myNumberVar,myNumberVar+10]
// [VarAdd,myNumberVar,5] // 加法
// [VarSub,myNumberVar,2] // 减法
// [VarMul,myNumberVar,2] //乘法 Multiply
// [VarDiv,myNumberVar,2] //除法 Division
// [VarDec,myNumberVar] //从变量中-1
// [VarInc,myNumberVar] //从变量中+1
// [VarInc,myNumberVar,2]
[IButton, "Click MyVar", ,
// [VarSet,myNumberVar,15] //如果在按钮内set则为最新的变量值
[Note,myNumberVar]
// [Note,[Var,myNumberVar]] // 如果变量没有值 会提示 这个变量为空
// [If,#myNumberVar, // 使用井号会直接提示 未寻找这个变量
// [Note,true]
// ]
]
//如果myNumberVar变量中没有值,则直接返回myNumberVar
/*
[[Var,
Variable name
]
[VarAdd,
Variable name,
Value To Add
]
[VarSub,
Variable name,
Value To Subtract
]
[VarDec,
Variable name
]
[VarInc,
Variable name
]
[VarDiv,
Variable name,
Value to Divide By
]
[VarMul,
Variable name,
Value To Multiply
]
[VarSize,
Variable name
]
[VarDef,
Variable name,
Variable defaultValue
]
[[VarSet,
Variable name,
New Value
]
[VarLoad, userData, tempFile]
[VarSave,
Variable name,
FileName
]
[VarListCopy,
Destination list,
Destination initial index,
Source list,
Source initial index,
Number of items to copy.(if omitted or it is 0,
then all items will be copied)
]
*/
stringVariables 字符串变量
// Learn - ZScript Fundamentals - String Variables 字符串变量
// https://www.youtube.com/watch?v=kKZ4UF57-HI&list=PLuvCsqbtUSFBDPXvB3SScoMD1VapO9Z0v&index=14
[VarDef,myStringVar,""]// 基础字符串变量
[VarSet,myStringVar,"hallo"]
//如果想要字符串内的数字进行计算则需要对字符串如下编写,但只是会得到一个附加值,一般字符串通常不用于这类
// [VarSet,myStringVar,"5"]
// [VarSet,myStringVar,myStringVar+5]
[IButton, "Click MyVar", ,
[Note,myStringVar]
]
strMerge 字符串合并
// Learn - ZScript Fundamentals - StrMerge 字符串合并
// https://www.youtube.com/watch?v=kKZ4UF57-HI&list=PLuvCsqbtUSFBDPXvB3SScoMD1VapO9Z0v&index=15
[VarDef,myStringVar,""]// 基础字符串变量
[VarSet,myStringVar,"hallo "]
[VarSet,myStringVar2," My name is Megestus."]
[VarSet,myStringVar,[StrMerge,myStringVar,"World!",myStringVar2]] //字符串合并需要添加 StrMerge 进行合并
[IButton, "Click MyVar", ,
[Note,myStringVar]
]
/*
[StrMerge,
Str 1,
Str 2,
Optional Str 3,
Opt Str 4,
Opt Str 5,
Opt Str 6,
Opt Str 7,
Opt Str 8,
Opt Str 9,
Opt Str 10,
Opt Str 11,
Opt Str 12
]
*/
StrFind 字符串查找
// Learn - ZScript Fundamentals - StrFind 字符串查找
// https://www.youtube.com/watch?v=kKZ4UF57-HI&list=PLuvCsqbtUSFBDPXvB3SScoMD1VapO9Z0v&index=16
[VarDef,myStringVar,""]// 基础字符串变量
[VarSet,myStringVar,"Hallo World! it's a beautiful day ! "]
[IButton, "Click MyVar", ,
// [Note,
// [StrFind, "World",myStringVar] //会返回索引6 123456 6后面就是World ,如果添加开始搜索索引,那么会在开始的位置循环数
// // [StrFind, "Check",myStringVar]=] //如果输入不存在的查找 会返回 -1 表示不存在
// ]
[If,[StrFind,"check",myStringVar]==-1, // == -1 相等-1时返回 note描述
[Note, "check not found!"]
]
[If,[StrFind,"World",myStringVar]!=-1, // != 不等于-1时返回 note描述
[Note, "World not found!"]
]
]
/*
[StrFind,
find this string, //找到这个字符串
in this string, //在此字符串中
Optional start search index (default:0) //可选的开始搜索索引(默认:0)
]
*/
StrExtract And StrLength 字符串提取和字符串长度
// Learn - ZScript Fundamentals - StrExtract and StrLength 字符串提取和字符串长度
// https://www.youtube.com/watch?v=kKZ4UF57-HI&list=PLuvCsqbtUSFBDPXvB3SScoMD1VapO9Z0v&index=17
[VarDef,myStringVar,""]// 基础字符串变量
[VarSet,myStringVar,"Hi my name is Megestus"]
[IButton, "Click MyVar",,
// [Note, [StrLength,myStringVar ]
//[Note, [StrExtract,myStringVar,6,10] ]
[VarSet,lgnt,[StrLength,myStringVar]] //直接定义新的变量
[VarSet,Megestus,[StrFind,"Megestus",myStringVar]] //设置查找某个字符串为变量
[Note, [StrExtract,myStringVar,Megestus-12,lgnt ] ] //提取输出字符串的某一段 -12 也就是从Megestus往前数12个字符为输出
]
/*
[StrExtract,
Input string, //输入字符串
Start character index (0:left), //起始字符索引(0:左)
End character index (0:left) //结束字符索引(0:左)
]
[StrLength,
String to evaluate // 要评估的字符串
]
*/
UPPERCASE And Lowercase 大写 小写
// Learn - ZScript Fundamentals - UPPERCASE and lowercase 大写和小写
// https://www.youtube.com/watch?v=kKZ4UF57-HI&list=PLuvCsqbtUSFBDPXvB3SScoMD1VapO9Z0v&index=18
[VarDef,myStringVar,""]// 基础字符串变量
[VarSet,myStringVar,"Hi my name is Megestus ~"]
[IButton, "Click MyVar",,
[Note,[StrLower,myStringVar ]] //全小写
// [Note,[StrUpper,myStringVar ]] //全大写
]
/*
[StrLower, //小写
Input string
]
[StrUpper, //大写
Input string
]
*/
[StrAsk] (GetUserInput) 获取用户输入
// Learn - ZScript Fundamentals - StrAsk (Get User Input) (获取用户输入)
// https://www.youtube.com/watch?v=kKZ4UF57-HI&list=PLuvCsqbtUSFBDPXvB3SScoMD1VapO9Z0v&index=19
//如果在任何给定时间您需要用户在脚本中输入某些内容,则可以使用 string ask 命令
[VarDef,userinput,""]// 基础字符串变量
// [IButton, "User input",,
// [StrAsk, "Type text in here", "Please enter a file name"] //就是提示一个输入窗口 文字和窗口标题
// ]
[IButton, "User input",,
[VarSet,userinput,[StrAsk, "Type text in here", "Please enter a file name"]]
//使用的话-就是把这个输入的内容 , 设置存储到自定义变量中 如userinput
[Note,userinput] //打印 serinput
]
/*
[StrAsk,
Initial string,
Title
]
*/
VarList (Arrays) 数组
// Learn - ZScript Fundamentals - VarList (Arrays) 变量列表(数组)
// https://www.youtube.com/watch?v=kKZ4UF57-HI&list=PLuvCsqbtUSFBDPXvB3SScoMD1VapO9Z0v&index=20
[VarDef, mySrtingVarList(3),""]
[VarDef, myNumberVarList(2),0]
// 数组嘛~ 你可以理解为一个图表 就像是mySrtingVarList(2)."" 前有两行 还有可以填写的两个列的 字符串或者数字
// [VarSet,myNumberVarList(0),5]
// [VarSet,myNumberVarList(1),10]
// [IButton,"Check Var",,
// [Note,myNumberVarList(0)]
// ]
[VarSet,mySrtingVarList(0),"Hallo"]
[VarSet,mySrtingVarList(1),"World~"]
[VarSet,mySrtingVarList(2),"kiss kiss ~"]
[IButton,"Check Var",,
// [Note,mySrtingVarList(1)]
[Note,[VarSize,mySrtingVarList]] //size 直接返回数字数量
]
/*
[VarSize,
Variable name
]
*/
[Loop] 循环
// Learn - ZScript Fundamentals - Loop 循环
// https://www.youtube.com/watch?v=kKZ4UF57-HI&list=PLuvCsqbtUSFBDPXvB3SScoMD1VapO9Z0v&index=21
[VarDef, mySrtingVarList(4),""]
[VarSet,mySrtingVarList(0),"Hallo"]
[VarSet,mySrtingVarList(1),"World~"]
[VarSet,mySrtingVarList(2),"kiss kiss ~"]
// [IButton,"Check Var",,
// [Loop, 3, //循环3次
// // [Note, "Hello There"]
// [Note, mySrtingVarList(loopcount)] //循环变量 loopcount(循环次数) 固定搭配
// ,loopcount]
// ]
// [IButton,"Check Var",,
// [Loop, [VarSize,mySrtingVarList], //使用size来按变量数组的大小进行循环,数组内没有变量的则返回0
// [Note, mySrtingVarList(loopcount)]
// ,loopcount]
// ]
// if 判断退出
[VarSet,mySrtingVarListCount,0] //设置一个循环次数变量,用于记录循环次数
[IButton,"Check Var",,
[Loop,999,
[If, [StrLength, mySrtingVarList(loopcount)]==0, //循环查询到值等于0时则退出循环
[LoopExit]
,//else
[Note, mySrtingVarList(loopcount)] // 否则继续查询
[VarInc, mySrtingVarListCount] //循环一次对mySrtingVarListcount的变量进行+1
]
,loopcount]
[Note, [StrMerge,"Loop ended,found ",mySrtingVarListCount," Var placements"]] // 打印一个提示 循环查找了多少次 变量位置
]
/*
[Loop,
RepeatCount, //重复次数
Commands group, //命令组
Optional loop-counter variable (starts at Zero) // 可选的循环计数变量(从 0 开始)
]
*/
[Routines] (Functions) 函数
// Learn - ZScript Fundamentals - Routines (Functions) 例程(函数)
// https://www.youtube.com/watch?v=kKZ4UF57-HI&list=PLuvCsqbtUSFBDPXvB3SScoMD1VapO9Z0v&index=22
// 一个函数模块,Routine的函数名称最好是大写开头。
[VarDef, myVar," Look where I am."]
[RoutineDef, MyRoutine, //函数
[Note, [StrMerge,"Hello ",myVar]] // 调用变量
]
[IButton, "Run Routine", ,
[RoutineCall, MyRoutine] //调用函数
]
/*
[RoutineDef,
Name of the routine, //例程名称
Commands group that will be executed when the routine is called, // 调用例程时将执行的命令组、
Input Var01, //输入变量 01
Input Var02,
Input Var03,
Input Var04,
Input Var05,
Input Var06,
Input Var07,
Input Var08,
Input Var09,
Input Var10
]
[RoutineCall,
Name of the routine to be called, // 要调用的例程名称
Input Var01,
Input Var02,
Input Var03,
Input Var04,
Input Var05,
Input Var06,
Input Var07,
Input Var08,
Input Var09,
Input Var10
]
*/
[MemVar] (MemoryVariables) 内存变量
// Learn - ZScript Fundamentals - MemVar (Memory Variables) (内存 变量)
// https://www.youtube.com/watch?v=kKZ4UF57-HI&list=PLuvCsqbtUSFBDPXvB3SScoMD1VapO9Z0v&index=23
/*
内存变量会在整个 ZBrush 会话期间持续存在,例如,您正在创建宏或脚本,而不是插件,插件则有所不同。但是,如果您正在创建宏脚本,并且要更改变量,使该脚本完成后在另一个脚本中继续存在,另一个宏运行时,您需要使用内存变量,否则该变量将不复存在。定义内存变量的方式是写下MVarDef这实际上与设置普通变量相同。
核心概念是 变量的生命周期。在 ZBrush 脚本(特别是宏)中,普通变量只存在于创建它们的那个脚本的执行期间。脚本一结束,变量就被清除了。而 内存变量 (MVar) 则会在整个 ZBrush 会话(从软件启动到关闭) 期间一直存在,可以被不同的宏或脚本访问和修改
简单比喻:
普通变量: 就像写在便利贴上的临时笔记。你写在一个便利贴(运行一个脚本)上的内容,只能在这个便利贴存在时(脚本运行时)看到。当你扔掉这张便利贴(脚本结束),笔记就消失了。再拿一张新便利贴(运行另一个脚本),你看不到上一张的内容。
内存变量 (MVar): 就像钉在你工作室白板上的永久笔记。你在白板上写的东西(创建 MVar),只要白板还在(ZBrush 没关闭),无论你离开工作室一会儿(一个脚本结束)还是回来做别的事(运行另一个脚本),都能看到并修改它。
原文关键点解析:
目标: 让一个脚本中设置或修改的变量值,在另一个脚本运行时还能继续存在并被使用。
问题: 使用普通变量(如 myVar = 10)做不到这点。脚本A设置的 myVar,在脚本A结束后就消失了。当脚本B运行时,它根本不知道 myVar 是什么。
解决方案: 使用 内存变量 (MVar)。
创建方法: 使用 MVarDef 命令来定义和设置内存变量。这本质上类似于设置普通变量,但关键区别在于它存储在 ZBrush 的特殊内存区域中,生命周期更长。
MVarDef vs MVar: MVarDef("Name", Value) 通常用于定义并初始化一个内存变量。MVar("Name") 用于读取一个已存在内存变量的值。MVar("Name", NewValue) 也可以用于更新一个已存在内存变量的值(这是常见用法)。
作用域: 内存变量的作用域是全局于整个 ZBrush 应用会话。
持久性: 它们会一直存在,直到你关闭 ZBrush。
用途: 非常适合在多个独立的宏/脚本之间传递状态、存储用户偏好、记录计数、保存临时配置等。
插件不同: 如原文所说,开发完整的 ZBrush 插件 (用 C++ 等) 时,变量的持久化机制完全不同,通常涉及更复杂的 SDK 函数或操作系统级别的存储。
变量名: 确保在不同脚本中使用完全相同的变量名(包括大小写)来访问同一个内存变量。
MemVar的名称最好是小写开头,用于识别
*/
//[MVarDef, mMyVar, 1000, 0] //小写的 m 表示内存
//现在内存变量只用于数字,它们不适用于数字
/*
[MVarDef,
Mem block identifier, //内存块标识符
Mem block variables count, //内存块变量计数 & 绘制次数
Initial fill? (omitted:noFill - faster to create) //初始填充?(省略:不填充 - 创建速度更快)
]
*/
/*
[MVarDef,mMyVar,1,θ]
[If,[MemGetSize,mMyVar], // 测试内存块,如果存在则返回 1 或更多
[Note,"Setting Memory Variable!",,1]
[MVarSet,mMyVar,0,10]
//else (当内存大小为 0 且不存在时)
[Note, "No memory block found. \n Could not set as variable does not exist! ",,1]
]
[If,[MemGetSize,mMyVar], // 测试内存块,如果存在则返回 1 或更多
[Note,"Getting Memory Variable!",,1]
[Note,[MVarGet,mMyVar,0]]
//else(当内存大小为 θ 且不存在时)
[Note,"No memory block found. In Could not get as variable does not exist! ",,1]
]
[If,[MemGetSize,mMyVar], // 测试内存块,如果存在则返回 1 或更多
[Note,"Deleting Memory Variable!",,1]
[MemDelete,mMyVar]//删除内存块
//else (当内存大小为 0 且不存在时)
[Note,"No memory block found.\n Could not delete as variable does not exist!",,1]
]
*/
[IButton,myButton,,
[If, ![MemGetSize,mMyVar], //判断是否存在?
[MVarDef,mMyVar,1,0] //定义
]
[MVarSet, mMyVar,0, 10]
[Note, [MVarGet, mMyVar, 0]]
]
VariableScope 变量作用域
// Learn - ZScript Fundamentals - Variable Scope 变量范围 // naming convention and variable scope
// https://www.youtube.com/watch?v=kKZ4UF57-HI&list=PLuvCsqbtUSFBDPXvB3SScoMD1VapO9Z0v&index=24
// Global Variable 全局变量
[VarDef, gmyVar, 10]
// Memory Variable 内存变量
[MVarDef,mMyVar, 1, 0]
// local variable 局部变量
[RoutineDef, MyRoutine,
[VarSet, myVar,20] // local variable
[VarSet, gmyVar,20] // set global var
]
[IButton, myButton, ,
[RoutineCall, MyRoutine] //调用例程(函数)内
[Note, gmyVar]
]
[IButton,myButton,,
[varSet, gMyVar,0] //set global variable in 0
[Loop, 10, // loop 10 0123456789
[VarInc, gMyVar] // global variable + 1
]
]
[IButton, "check loopCount",,
[Note, gMyVar] // so ping gMyVar = 10
]
[VarSave] [VarLoad] And [Combining] 保存变量 加载变量 合并变量
// Learn - ZScript Fundamentals - VarSave, VarLoad and combining NOTE 变量保存和加载和合并注释
// https://www.youtube.com/watch?v=kKZ4UF57-HI&list=PLuvCsqbtUSFBDPXvB3SScoMD1VapO9Z0v&index=25
// 值得注意的是,我们需要自行创建Data文件夹,不然就无法存储到这个位置。
[VarDef,gMyVarList(2), ""] //定义全局数组变量
[If, [FileExists, "Data/gMyVarList.zvr"], //执行文件
[VarLoad,gMyVarList, "Data/gMyVarList.zvr"] //加载变量
,
[VarSet, gMyVarList(0), "Hello"] //设置全局变量
[VarSet,gMyVarList(1)," World"] //设置全局变量
[VarSave, gMyVarList, "Data/gMyVarList.zvr"] //保存变量
]
[RoutineDef, OutputMyVarList, //函数
[loop, 2,
[Note,gMyVarList(LoopCount),, -1] //循环全局变量 ,,-1 和下一个字符合并
,LoopCount]
[Note,""]
]
[IButton, "Output Variable",,
[RoutineCall, OutputMyVarList] //调用函数
]
/*
[FileExecute, //文件执行
File name including the extension (such as plugin.dll ), //文件名,包括扩展名(如 plugin.dll)、
Routine to call, //要调用的例程、
Optional text input, //可选文本输入
Optional number input, //可选数字输入
Optional memory block input, //可选的内存块输入
Optional memory block output //可选内存块输出
]
[VarLoad,
Variable name, //变量名称
FileName, //文件名
Verify only (1:Only Verify that a proper saved variable file exists, // 仅验证(1:仅验证是否存在正确保存的变量文件、
0:(default)Verifies and loads values) // 0:(默认)验证并加载值)
]
[VarSave,
Variable name, //变量名称
FileName //文件名
]
[Note,
"Text line",
Optional path1 of an interface item to be pointed out (default:none),
Display Duration (in seconds) (0:wait for user action(default),
-1:combine with next note command), //与下一个字符命令结合
Popup background color (0x000000<->0xffffff,
default:0x606060,
0:No Background),
Prefered distance of the note from the specified interface item (default:48),
Prefered Note width (in pixels,
default:400),
optional marked windows fill color (0x000000<->0xffffff or (blue+(green*256)+(red*65536))(Omitted value:No fill)),
Frame horizontal size (1:Max width (default)),
Frame vertical size (1:Max height (default)),
Frame left side (0:left (default),
.5:center,
1:right) Omit value for horizontal autocentering,
Frame top side ( 0:top (default),
.5:center,
1:bottom )Omit value for vertical auto-centering,
Optional icon file name
]
*/
Progress Bar with NoteBar and Delay 带字符和延迟的进度条
// Learn - ZScript Fundamentals - Progress Bar with NoteBar and Delay 带字符和延迟的进度条
// https://www.youtube.com/watch?v=kKZ4UF57-HI&list=PLuvCsqbtUSFBDPXvB3SScoMD1VapO9Z0v&index=26
/*
到目前为止,我们一直在使用 note 命令向用户输出信息。在接下来的几个视频中,你将探索一些不同的信息输出方式,并从用户那里获取一些输入。正如我们已经看到的,note只是输出了,但你必须点击屏幕上的任意位置才能让它消失,除非你传递一个时间,比如秒或字母秒。
*/
//百分比进度条
[IButton, "Output Note",,
[NoteBar, "ZScript is calculating, Please wait..."]
[IPress,Tool:SubTool:SelectDown][Delay, .1]
[NoteBar, "ZScript is calculating, Please wait...",.25]
[IPress,Tool:SubTool:SelectDown][Delay, .1]
[NoteBar, "ZScript is calculating, Please wait...",.50]
[IPress,Tool:SubTool:SelectDown][Delay, .1]
[NoteBar, "ZScript is calculating, Please wait...",.75]
[IPress,Tool:SubTool:SelectDown][Delay, .1]
[NoteBar, "ZScript finished calculating!",1]
]
[IButton,"Output Note2" ,,
[NoteBar,"ZScript is calculating..."]
[Loop,50,
[IPress,Tool:SubTool:SelectDown]
[NoteBar, "ZScript is calculating...",gLC*0.1] // 秒
[Delay,.1]
,gLC]
[NoteBar, "ZScript finished calculating!",1]
]
/*
[NoteBar, //将信息显示到状态信息提示中,并不是直接小弹窗形式的提示。
The Message that will be shown (use empty string to clear current note),
// 将显示的信息(使用空字符串可清除当前注释)
Optional progress-bar value (0:Min,1:Max) //可选的进度条值 (0:最小值,1:最大值)
]
*/
[Messages] 消息
// Learn - ZScript Fundamentals - Messages 消息
// https://www.youtube.com/watch?v=kKZ4UF57-HI&list=PLuvCsqbtUSFBDPXvB3SScoMD1VapO9Z0v&index=27
[IButton,"Output",,
[VarSet,gUserInput,[MessageOKCancel,"Message","Title"]]
[If, gUserInput,
[Note, "Continue with script.."]
,
[Note, "Script cancelled!"]
]
]
[IButton,"Output2",,
[VarSet,gUserInput,[MessageYesNoCancel,"Message","Title"]]
[If, gUserInput!=-1,
[If, gUserInput,
[Note,"Run script A"]
,
[Note,"Run script B"]
]
,
[Note,"Script cancelled!"]
]
]
/*
[MessageOK,
The Message that will be shown, //将显示的信息
The Title of the message // 信息标题
]
[MessageOKCancel, // OK返回1 Cancel 返回0
The Message that will be shown,
The Title of the Messages
]
[MessageYesNo,
The Message that will be shown,
The Title of the message
]
[MessageYesNoCancel,
The Message that will be shown,
The Title of the message
]
*/
NoteInterface 通知栏
// Learn - ZScript Fundamentals - Note Interface 注释界面
// https://www.youtube.com/watch?v=kKZ4UF57-HI&list=PLuvCsqbtUSFBDPXvB3SScoMD1VapO9Z0v&index=28
/*
[RoutineDef,"Noteinterface",
[Loop, 999, //循环打开
[NoteIButton,loopCount] //1 //返回循环次数
[NoteIButton,[MouseVPos]] //2 //获取鼠标的实时 V坐标
[NoteISwitch,"Switch 1"] //3
[NoteISwitch,"Switch 2"] //4
[VarSet,result,[Note,"",,.5]] //get result //设置每0.5秒刷新控件
// [Note,[NoteIGet,3]] //这里noteiget 是用于判断启用按钮控件-如果3号控件sitch 1 没有启用则 都返回0 启用后则都返回1
[If,result==2, // 控件等于2时 直接退出
[LoopExit]
]
,loopCount]
]
[IButton, "Note interface", ,
[RoutineCall, Noteinterface]
]
*/
/*
[RoutineDef,"Noteinterface",
[Loop, 999, //循环打开
[NoteIButton,,,,1,1,1,200,100,0,0,0,0,0] //1 //设置背景
[NoteIButton,"please select an option!",,,1,1,1,,,0,0xFF9026,0,1,0] //2
[NoteIButton," OK "] //3
[NoteISwitch," Cancel "] //4
[VarSet,result,[Note,"",,]] //get result
[If, result==3,
[Note, "Cool"]
]
[If, result==4,
[NoteBar, "Cancelled!"]
[LoopExit]
]
]
]
[IButton, "Note interface", ,
[RoutineCall, Noteinterface]
]
*/
// 调用一下变量
[RoutineDef,"Noteinterface",
[Loop, 999, //循环打开
[NoteIButton,,,,1,1,1,200,100,0,0,0,0,0] //1 //设置背景
[NoteIButton,"please select an option!",,,1,1,1,,,0,0xFF9026,0,1,0] //2
[NoteIButton," OK "] //3
[NoteIButton," Cancel "] //4
[VarSet,result,[Note,"",,]] //get result
[If, result==3,
[VarSet,rlt, "Cool"]
]
[If, result==4,
[VarSet,rlt, "Cancelled!"]
]
[LoopExit]
]
,rlt]
[IButton, "Note interface", ,
[VarSet, gRlt,""]
[RoutineCall, Noteinterface, gRlt]
[Note, gRlt]
]
/*
[NoteIButton,
Button name, //按钮名称
Optional button icon, //可选按钮图标
Initially Pressed? (default:unpressed), //初始按下?(默认:未按下
Initially Disabled? (default:enabled), // 初始禁用?(默认值:启用
Optional button H relative position (Positive value:offset from left, //可选按钮 H 的相对位置(正值:向左偏移,
Negative value:offset from right, //负值:从右侧偏移,
0:automatic), // 0:自动)
Optional button V relative position (Positive value:offset from top, //可选按钮 V 的相对位置(正值:从顶部偏移,
Negative value:offset from bottom, //负值:从底部偏移,
0:automatic), // 0:自动)
Optional button width in pixels (default:automatic), //以像素为单位的可选按钮宽度(默认值:自动)
Optional button height in pixels (default:automatic), // 可选按钮高度(像素)(默认:自动
Optional button color (0x000000<->0xffffff or (blue+(green*256)+(red*65536))), // 可选按钮颜色(0x000000<->0xffffff或(蓝+(绿*256)+(红*65536))),
Optional text color (0x000000<->0xffffff or (blue+(green*256)+(red*65536))), // 可选文字颜色(0x000000<->0xffffff或(蓝+(绿*256)+(红*65536))),
Optional background opacity (default:1), //可选背景不透明度(默认值:1)
Optional text opacity (default:1) , // 可选文本不透明度(默认值:1)
Optional image opacity (default:1) //可选图像不透明度(默认值:1)
]
[NoteISwitch,
Switch name,
Optional button icon,
Initially Pressed? (default:unpressed),
Initially Disabled ? (default:enabled),
Optional button H relative position (Positive value:offset from left,
Negative value:offset from right,
0:automatic),
Optional button V relative position (Positive value:offset from top,
Negative value:offset from bottom,
0:automatic),
Optional button width in pixels (default:automatic),
Optional button height in pixels (default:automatic),
Optional button color (0x000000<->0xffffff or (blue+(green*256)+(red*65536))),
Optional text color (0x000000<->0xffffff or (blue+(green*256)+(red*65536))),
Optional background opacity (default:1),
Optional text opacity (default:1),
Optional image opacity (default:1)
]
*/
SelectingSubTools 选择子工具
// Learn - ZScript Fundamentals - Selecting SubTools 选择子工具
// https://www.youtube.com/watch?v=kKZ4UF57-HI&list=PLuvCsqbtUSFBDPXvB3SScoMD1VapO9Z0v&index=29
[IButton,"IGetTitle",,
[Note, [IGetTitle, Tool:Subtool:ItemInfo]]
]
[IButton,"SubToolGetID",,
[Note,[SubToolGetID]]
]
[IButton,"SubToolGetActiveIndex",,
[Note,[SubToolGetActiveIndex]]
]
//由此可以写一个选择子工具的功能,其中返回0 则表示该子工具存在,返回-1 则不存在。
[IButton,"SubToolSelect 0",,
[Note,[SubToolSelect,0]]
]
[IButton,"SubToolSelect 1",,
[Note,[SubToolSelect, 1]]
]
[IButton,"SubToolSelect 2",,
[Note,[SubToolSelect, 2]]
]
// 全部挤压函数
[RoutineDef,SqueezeAll,
[Loop, [SubToolGetCount], //获取所有的子工具数量
[If, [SubToolSelect, LoopCount]!=-1, //选择则工具 判断= -1的排除直接退出
[ISet, Tool:Deformation:Squeeze,20] // 选中的就直接设置执行 对应的功能
,//else
[LoopExit]
]
,Loopcount] //退出循环后停止
]
[IButton,"Squeeze All",,
[RoutineCall,SqueezeAll]
]
// 获取子工具名称
[RoutineDef,GetSubtooLName,
[VarSet, length, [StrLength, [IGetTitle,Tool:Subtool:ItemInfo]]] //设置长度变量 -获取名称的长度
[VarSet, subtoolName, [IGetTitle,Tool:Sustool:ItemInfo]] //设置子工具名称变量 获取titel
[VarSet, subtoolName, [StrExtract,subtoolName, 0, Length - 2]] //对子工具名称变量 进行长度裁剪 从0开始显示到-2 ,这样相对与直接使用 IGetTitle 没有后面的小数点了
,subtoolName]
[IButton,"SubTool Name",,
[VarSet,gSubtoolName,""]
[RoutineCall, GetSubtoolName, gSubtoolName]
[Note,gSubtooLName]
]
/*
[SubToolSelect,
Subtool Index (zero based).
]
[SubToolGetID,
Subtool Index (zero based). If omited then uses the currently selected subtool.
]
[SubToolGetActiveIndex
]
*/
Renaming Subtools 重命名子工具
// Learn - ZScript Fundamentals - Renaming Subtools
// https://www.youtube.com/watch?v=kKZ4UF57-HI&list=PLuvCsqbtUSFBDPXvB3SScoMD1VapO9Z0v&index=30
[IButton,"ToolSetPath","Rename top SubTool",
[ToolSetPath,,"NewName"]
]
/*
[ToolSetPath,
Tool Index (zero based). If omited then uses the currently selected tool., //工具索引(基于零)。如果省略,则使用当前选定的工具、
New Path. Path extension (such as .ztl) will be omited. //新路径。路径扩展名(如 .ztl)将被省略。
]
*/
Moving Subtools to top or bottom 移动子工具到顶部或底部
// Learn - ZScript Fundamentals - Moving Subtools to top or bottom 将子工具移至顶部或底部
// https://www.youtube.com/watch?v=kKZ4UF57-HI&list=PLuvCsqbtUSFBDPXvB3SScoMD1VapO9Z0v&index=31
[IButton,"ToolSetPath","Rename top SubTool",
[Loop,999,
[If, [IsEnabled, Tool:Subtool:MoveUp],
[IPress, TooL :SubtooL :MoveUp], //将子工具移至顶部
,//else
[LoopExit]
]
]
[ToolSetPath,,"NewName"] //重命名
]
/*
*/
Tools And Folders 工具和文件夹
// Learn - ZScript Fundamentals - Tools and Folders 工具和文件夹
// https://www.youtube.com/watch?v=kKZ4UF57-HI&list=PLuvCsqbtUSFBDPXvB3SScoMD1VapO9Z0v&index=32
[IButton,"ToolGetActiveIndex",,//0 based //工具 获取活动索引 也就是当前工具ID
[Note, [ToolGetActiveIndex]]
]
[IButton,"ToolGetCount",, //工具获取计数 //具体直接点击Tool 会显示
[Note,[ToolGetCount]]
]
[IButton,"ToolSelectLastTool",, //工具选择 最后一个工具
[Note,[ToolSelect,[ToolGetCount]-1]]
]
[IButton,"ExportTool",, //导出工具
//[FileNameSetNext, myTool.ztL] //定义导出ztl文件 //取消掉可手动选择存储路径 而不是直接的快速保存-这个快速保存还是最近打开的路径
[IPress, Tool:SaveAs] // 执行动作
[VarSet, mySavedPath, [FileNameGetLastUsed]] //把保存路径设置为变量
]
[IButton,"ImportSavedTool",, //导入保存的工具
[FileNameSetNext, mySavedPath] //获取变量
[IPress, Tool:Load Tool] //执行加载动作
]
[IButton,"SubToolGetFolderIndex",, //子工具 获取文件夹索引 这个子工具索引和SubToolGetActiveIndex 还不一样 文件夹内的所有子工具将会被归为文件夹的索引
[Note,[SubToolGetFolderIndex]]
]
[IButton,"SubToolGetFolderName",, //子工具 获取文件夹名称
[Note,[SubToolGetFolderName]]
]
[IButton,"SubToolGetActiveIndex",, //子工具 获取活动索引
[Note,[SubToolGetActiveIndex]]
]
/*
*/
更新日志
2025/6/8 16:00
查看所有更新日志
00a10
-于d5dba
-于