- UID
- 2546
- 积分
- 159
- 帖子
- 30
- 主题
- 5
- 论坛币
- 868
- 威望
- 0
- EP值
- 134
- MP值
- 0
- 阅读权限
- 50
- 注册时间
- 2015-5-9
- 在线时间
- 52 小时
- 最后登录
- 2024-10-20
|
本帖最后由 Seekladoom 于 2021-7-13 12:28 编辑
相关链接:
用TCAX制作分段特效时注意到的一些问题
初学者用Python语言写代码时很容易踩代码缩进的坑,容易写出多种空格缩进代码混用的情况,而Python语言对代码缩进很敏感,混用会直接导致TCAX无法运行。用惯了Aegisub去写lua代码的人在接触Python时很容易碰到这个问题,因为lua语言的缩进并没有python这么严格,多种缩进混用只要没有大错一般也能跑,容错性较高。
补充:如果反复修改TCAX脚本的两格缩进和四格缩进,运行TCAX时就有可能出现即便统一了代码缩进格式也依然报错的情况,特别是刚把两格缩进全换成四格缩进或者四格缩进全换成两格缩进时,这种情况最容易发生,这个时候你即便写对了,TCAX也依然会反馈缩进错误。这种情况下建议关掉TCAX重开或者改完以后等十几秒再跑TCAX就能正常运行了。
贴一下两格缩进与四格缩进的代码示例,推荐用四格缩进,因为四格缩进便于浏览且论坛内写的人也多,工业生态相对较好:
两格缩进- from tcaxPy import *
- def tcaxPy_Init():
- global _FD # frame duration, in millisecond
- global _Blur
- _FD = 1000 / GetVal(val_FXFPS)
- _Blur = GetVal(val_Blur)
- def tcaxPy_Fin():
- pass
- def tcaxPy_Main(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt):
- ASS_BUF = [] # used for saving ASS FX lines
-
- if _i < 5:
- ass_main(ASS_BUF, SubL(_start+_j*3-20,_start+_elapk,0,'OPJP'), pos(_x,_y)+color1('3767E6')+color3('FFFFFF')+blur(2)+fad(200,0), _txt) #入场特效 - start2syl
- ass_main(ASS_BUF, SubL(_start+_elapk,_start+_elapk+_k,0,'OPJP'), pos(_x,_y)+blur(2)+color1('3767E6')+color3('FFFFFF')+t(color1('FFFFFF')+color3('3767E6')), _txt) #卡拉OK特效 - syl
- ass_main(ASS_BUF, SubL(_start+_elapk+_k,_end-(_n-_j-1)*3+20,0,'OPJP'), pos(_x,_y)+color1('FFFFFF')+color3('3767E6')+blur(2)+fad(0,200), _txt) #退场特效 - syl2end
- if _i >= 5:
- ass_main(ASS_BUF, SubL(_start+_j*3-20,_start+_elapk,0,'OPJP2'), pos(_x,_y)+color1('3767E6')+color3('FFFFFF')+blur(2)+fad(200,0), _txt) #入场特效 - start2syl
- ass_main(ASS_BUF, SubL(_start+_elapk,_start+_elapk+_k,0,'OPJP2'), pos(_x,_y)+blur(2)+color1('3767E6')+color3('FFFFFF')+t(color1('FFFFFF')+color3('3767E6')), _txt) #卡拉OK特效 - syl
- ass_main(ASS_BUF, SubL(_start+_elapk+_k,_end-(_n-_j-1)*3+20,0,'OPJP2'), pos(_x,_y)+color1('FFFFFF')+color3('3767E6')+blur(2)+fad(0,200), _txt) #退场特效 - syl2end
- return (ASS_BUF, None)
复制代码
四格缩进- from tcaxPy import *
- def tcaxPy_Init():
- global _FD # frame duration, in millisecond
- global _Blur
- _FD = 1000 / GetVal(val_FXFPS)
- _Blur = GetVal(val_Blur)
- def tcaxPy_Fin():
- pass
- def tcaxPy_Main(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt):
- ASS_BUF = [] # used for saving ASS FX lines
-
- if _i < 5:
- ass_main(ASS_BUF, SubL(_start+_j*3-20,_start+_elapk,0,'OPJP'), pos(_x,_y)+color1('3767E6')+color3('FFFFFF')+blur(2)+fad(200,0), _txt) #入场特效 - start2syl
- ass_main(ASS_BUF, SubL(_start+_elapk,_start+_elapk+_k,0,'OPJP'), pos(_x,_y)+blur(2)+color1('3767E6')+color3('FFFFFF')+t(color1('FFFFFF')+color3('3767E6')), _txt) #卡拉OK特效 - syl
- ass_main(ASS_BUF, SubL(_start+_elapk+_k,_end-(_n-_j-1)*3+20,0,'OPJP'), pos(_x,_y)+color1('FFFFFF')+color3('3767E6')+blur(2)+fad(0,200), _txt) #退场特效 - syl2end
- if _i >= 5:
- ass_main(ASS_BUF, SubL(_start+_j*3-20,_start+_elapk,0,'OPJP2'), pos(_x,_y)+color1('3767E6')+color3('FFFFFF')+blur(2)+fad(200,0), _txt) #入场特效 - start2syl
- ass_main(ASS_BUF, SubL(_start+_elapk,_start+_elapk+_k,0,'OPJP2'), pos(_x,_y)+blur(2)+color1('3767E6')+color3('FFFFFF')+t(color1('FFFFFF')+color3('3767E6')), _txt) #卡拉OK特效 - syl
- ass_main(ASS_BUF, SubL(_start+_elapk+_k,_end-(_n-_j-1)*3+20,0,'OPJP2'), pos(_x,_y)+color1('FFFFFF')+color3('3767E6')+blur(2)+fad(0,200), _txt) #退场特效 - syl2end
- return (ASS_BUF, None)
复制代码 |
|