从另一个maxscript调用maxscript

Gho*_*ool 6 maxscript

我正在尝试编写一个调用外部脚本的函数,但是语法没有运气

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
)
Run Code Online (Sandbox Code Playgroud)

JHN*_*JHN 10

在这里区分两种可能的解决方案是很好的:

  1. FILEIN
  2. 包括

fileIn将与"运行脚本"相同或在编辑器中评估所有内容.它可以使一个函数可用,如果它是全局声明的(不是优选的,尽可能使用较少的全局变量),如果它是在该脚本中本地声明的,则无法访问它.

Include实际上从该文件中获取代码并在该点注入它.因此,如果您有一个大型脚本并且想要更好地组织事物,您可以在单独的文件中编写某些函数,并在脚本执行时包含该函数,以便该函数始终可访问,因为它包含在该范围内.


Gho*_*ool 5

弄清楚了!

--- "hello_world.ms"
enter function hello =
(
print "hello the world"
)


---- another _script.ms
fileIn "hello_world.ms"

-- use function to call scripts
Run Code Online (Sandbox Code Playgroud)

你好 ()

看来 fileIn 比 include 效果更好