Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

call maxscript from another maxscript

Tags:

maxscript

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
)
like image 641
Ghoul Fool Avatar asked Oct 15 '12 16:10

Ghoul Fool


2 Answers

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.

like image 173
JHN Avatar answered Oct 13 '22 00:10

JHN


Figured it out!

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


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

-- use function to call scripts

hello ()

It seems that fileIn works better than include

like image 29
Ghoul Fool Avatar answered Oct 12 '22 23:10

Ghoul Fool