我正在尝试编写一个调用外部脚本的函数,但在语法方面却一无所获
scripts_folder = "C:\\Program Files\\Autodesk\\3ds Max 2008\\Scripts"
var script1 = "hello_world.ms"
-- use function to call scripts
callScript(script1)
-- function callScript
function callScript script =
(
getFiles scripts_folder + "\\" + script
)
发布于 2012-10-16 00:34:02
想明白了!
--- "hello_world.ms"
enter function hello =
(
print "hello the world"
)
---- another _script.ms
fileIn "hello_world.ms"
-- use function to call scripts
hello ()
看起来fileIn比include工作得更好
发布于 2012-10-18 17:06:59
在这里区分两种可能的解决方案是很好的:
fileIn将在编辑器中执行与“运行脚本”或全部求值相同的操作。如果函数是全局声明(不是最好,使用尽可能少的全局变量),则it 可以使该函数可用,如果该函数是在脚本中本地声明的,则无法访问它。
Include实际上从该文件中获取代码,并在该点注入它。因此,如果您有一个很大的脚本,并且想要更好地组织事情,您可以在单独的文件中编写某些函数,并在脚本执行时包含该函数,以便始终可以访问该函数,因为它包含在该作用域中。
https://stackoverflow.com/questions/12899966
复制相似问题