- UID
- 2546
- 积分
- 159
- 帖子
- 30
- 主题
- 5
- 论坛币
- 868
- 威望
- 0
- EP值
- 134
- MP值
- 0
- 阅读权限
- 50
- 注册时间
- 2015-5-9
- 在线时间
- 52 小时
- 最后登录
- 2024-10-20
|
本帖最后由 Seekladoom 于 2021-8-26 04:01 编辑
【Aegisub:函数变量识别符为!!】
- [V4+ Styles]
- Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
- Style: OPCN,思源宋体,70,&H00FFFFFF,&H00000000,&H003767E6,&H00000000,-1,0,0,0,100,100,6,0,1,2,0,2,0,0,10,1
- Comment: 0,0:00:00.00,0:00:00.00,OPCN,,0,0,0,template char noblank,!retime("line",0,0)!{\an5\pos($center,$middle)\fry!math.random(30,60)!}
- Comment: 0,0:00:0.00,0:00:01.00,OPCN,,0,0,0,karaoke,{\k100}字幕测试
复制代码 注:!!是Aegisub的内置脚本语言AUTO4特有的函数变量识别符,原生Lua本身跟Python一样也是用()进行函数识别的,但在针对具体的嵌入式开发应用场景时会发生变化。
!!的函数识别逻辑在Aegisub的kara-templater.lua下,代码为:
- -- Function for evaluating expressions
- local function expression_evaluator(expression)
- f, err = loadstring(string.format("return (%s)", expression))
- if (err) ~= nil then
- aegisub.debug.out(2, "Error parsing expression: %s\nExpression producing error: %s\nTemplate with expression: %s\n\n", err, expression, template)
- return "!" .. expression .. "!"
- else
- setfenv(f, tenv)
- local res, val = pcall(f)
- if res then
- return val
- else
- aegisub.debug.out(2, "Runtime error in template expression: %s\nExpression producing error: %s\nTemplate with expression: %s\n\n", val, expression, template)
- return "!" .. expression .. "!"
- end
- end
- end
复制代码
【TCAX:函数变量识别符为()】
- from tcaxPy import * #请用这个帖子(http://www.tcax.org/forum.php?mod=viewthread&tid=2120)中的tcaxPy.py文件
- def tcaxPy_Init():
- pass
-
- def tcaxPy_Main(_i, _j, _n, _BT, _ET, _SK, _KT, _X, _Y, _A, _TXT):
- ASS_BUF = [] # 用于保存ASS特效
-
- ass_main(ASS_BUF,SubL(_BT,_ET,0),an5+pos(_X,_Y)+fry(randint(30,60)),_TXT)
-
- return (ASS_BUF, None)
复制代码
|
|