Maxscript: Scripted Plugin Splitting UI and Logic

Hey Everyone,

I’m working on a scripted plugin that I want to split the UI from however I’ve had no success in this. Using fileIn seems to error out in a scripted plugin giving me the following error:

-- Syntax error: at name, expected Plugin clause: 
--  In line: 	fileIn "

I’ve had success doing this with this outside of a scripted plugin with no problems. Any ideas how I can split my UI and logic easily?

Thank you

Can you post more of the code, at least that whole filein statement as it appears in the script?

We’ve found the easiest approach is to put our functional/library scripts in the stdscripts folder:
<max dir>\stdplugs\stdscripts\

Any .ms files in that folder (or in subdirs under it) are executed early in the startup process, even before scripts\startup. Then you don’t need filein statements and can just call the structs/functions and know they’re defined at the global level.

Don’t use fileIn use include. FileIn is like running a script, include takes the actual code body and compiles with the plugin. I can imagine a scripted plugin can’t use fileIn on compile time.

Johan

Sorry for lack of code, didn’t occour to me to post it :rolleyes: So here is basically what I’m trying to do:

--myPlugin.ms
plugin material myPlugin
name:"My Plugin"
classID:#(0x3e7dceea, 0x7ad829f2)
extends:DirectX_9_Shader replaceUI: true version: 1
(
   -- include "myRollout.ms" is a similar error
   fileIn "myRollout.ms";
)
--myRollout.ms
rollout myRollout "My Rollout"
(
   --Rollout layout, event handlers, etc...
)

I’ve already tried using include, that was my first attempt. The problem with an include is the same with filein, it’s not accepted as a rollout clause isn’t found.

Edit: Forgot to mention, moving everything from myRollout.ms into the plugin works fine.

Thanks for the replies.

That´s weird, include should just work.
Not behind max though, can´t test.

Johan

I’d never do this, but you can sorta achieve what you’re trying to do by wrapping an ‘include’ with your rollout statement.


plugin material myPlugin
name:"My Plugin"
classID:#(0x3e7dceea, 0x7ad829f2)
extends:DirectX_9_Shader 
replaceUI: true 
version: 1
(
	
	rollout thisRollout "A rollout" 
	(
		include "myRollout.ms"
	)
	   
)

then, inside myRollout, include your buttons and methods and such


-- note the lack of rollout definition
button btn_abutton "aButton"
button another_button "aButton2"

Crazy. (and yes, I did test this)

well that would be complicated… have any ideas???.. Table Protector

Thats ok, because its invalid Max Script when used with a plugin. :p:

Testing it returns the following error on the included file:

Type error: Call needs function or class, got: undefined

The button needs to be within a function/class of some kind.

Finally some time to test it.

This works for me


--c:\	est_plugin.ms

plugin material mydxPlugin
name:"My Plugin"
classID:#(0x3e7dceea, 0x7ad827f2)
extends:DirectX_9_Shader replaceUI:true version:1
(
	include "c:\	est_myrollout.ms"
--    fileIn "c:\	est_myrollout.ms";
)

and


--test_myrollout.ms
rollout myRollout "My Rollout"
(
	button btnL "L" width:10 height:10 offset:[0,0] across:1
   --Rollout layout, event handlers, etc...
)

Not sure why that does work and yours doesn’t.
Tested on max2010.

-Johan

So I dunno if I should laugh or cry at this one. If i remove the semi-colon at the end of my include line it works.

Thanks for all the help Johan! :slight_smile: