call maxscript from another maxscript

Ghoul Fool picture Ghoul Fool · Oct 15, 2012 · Viewed 7.5k times · Source

I'm trying to write a function that calls an external script but am not having any luck with the syntax

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
)

Answer

JHN picture JHN · Oct 18, 2012

It's good to distinct two possible solutions here:

  1. FileIn
  2. Include

fileIn will do the same as "run script" or evaluate all in the editor. It can make a function available if it's globally declared (not preferable, use as less globals as possible), if it was locally declared within that script you cannot get to it.

Include actually takes the code from that file and injects it at that point. So if you have a large script and you want to organize things a bit better you can write certain functions in a separate file and include that function when the script get executed, so that function would always accessible because it is included in that scope.