Call maxscript from another maxscript

I am trying to write a function that calls an external script, but I have no 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 ) 
+6
source share
2 answers

It turned out!

 --- "hello_world.ms" enter function hello = ( print "hello the world" ) ---- another _script.ms fileIn "hello_world.ms" -- use function to call scripts 

hello ()

FileIn seems to work better than include

+3
source

It is good to reflect two possible solutions here:

  • Filein
  • Enable

fileIn will do the same as run script or evaluate everything in the editor. It can make an accessible function if it is declared globally (it is not preferable to use as few globals as possible), if it was declared locally inside this script, you cannot get to it.

Include actually takes the code from this file and enters it at that moment. Therefore, if you have a large script and you want to streamline things a little, you can write certain functions to a separate file and include this function when the script is executed, so that the function will always be available because it is included in this volume.

+10
source

Source: https://habr.com/ru/post/927765/


All Articles