View Full Version : include vs. filein?
lehthanis 07-04-2008, 09:46 PM I just split up my script because its getting large...
I'm having a hard time getting all the parts to be recognized at startup though...
my structure is:
Scripts\startup\XPlaneObj8Tools.ms
Scripts\XPlane\Helpers.ms
Scripts\XPlane\Modifiers.ms
Scripts\XPlane\Functions.ms
Scripts\XPlane\Export.ms
Scripts\XPlane\Import.ms
I'm currently using include, but it doesn't seem to be working...
For all of the things I want to have recognized above, do I want to use filein or include?
|
|
FileIn might be better for what you are doing. Also you might want to run the
Scripts\XPlane\Helpers.ms
Scripts\XPlane\Modifiers.ms
Scripts\XPlane\Functions.ms
Scripts\XPlane\Export.ms
Scripts\XPlane\Import.ms
Out of plugins instead of scripts. That way you know they are loaded and all in memory already. You can just make the calls to them and don't have to do a fileIN at all.
lehthanis
07-04-2008, 09:59 PM
Well...my Scripts\startup\XPlaneObj8Tools.ms file contains the following:
MacroScript XPlaneObj8Tools category:"X-PlaneObjTools"
(
include "XPlane\Helpers.ms"
include "XPlane\Modifiers.ms"
include "XPlane\Functions.ms"
include "XPlane\Export.ms"
include "XPlane\Import.ms"
XPlaneObjRolloutFloater = newRolloutFloater "X-Plane OBJ Tools" 250 300
addrollout XPlaneObj8Export XPlaneObjRolloutFloater
addrollout XPlaneObj8Import XPlaneObjRolloutFloater
)
What needs to change there if I move the other parts to plugins?
Well that is a macro script and needs to have the extension .mcr. Also it will need to reside in the macro scripts folder.
Use fileIn then instead of include.
lehthanis
07-04-2008, 10:12 PM
wow, as in ui\macroscripts?
I'm confused now...what shoudl my final structure be?
lehthanis
07-04-2008, 10:14 PM
By the way...I wanted it to be a plugin really...an export plugin...Should I not be using the macroscript command to setup a rollout?
You really need to start doing some tutorials.
lehthanis
07-04-2008, 10:38 PM
Well, thats how I got where I am now...Considering I'm a casual scripter, and once this export script is finished I probably won't do much more scripting (I'm more of a modeller really)...
The script is already quite a piece of work, I'm finding the maxscript help docs so convoluted and unlike any programming reference I've ever used before, some of the hard things seem to be easy to find and the easy simple basic stuff is buried.
To have someone tell me to take tutorials instead of helping me work through a problem is rather cold. Especially considering my script already exports geometry with normals, UVWs, and some basic animation to a format thats quite unlike any other standard modelling format. Sounds like I've come pretty far on my own to be told to go take a tutorial. I hope you're a little nicer to people who are interested in buying from you. But pardon me for being cynical.
lehthanis
07-04-2008, 10:51 PM
To turn this around....given the fact that I've already written an almost complete export script, and am having trouble with simple things such as program structure and the rotate around a parent pivot issue...what tutorials would you recommend?
I don't want to come off the wrong way, and I'd like to learn this stuff so I can release this script to the XPlane community...so please forgive me for being defensive. I really do appreciate all the help you guys have given me thus far.
RobGalanakis
07-04-2008, 11:18 PM
This may help?
http://tech-artists.org/wiki/index.php/Macro_installation_(maxScript)
There are also a few sections in Help that will aid you.
I should also mention I don't find Paul's comment that cold, you've made about half a dozen threads in the past couple days. Whether or not it is true, it gives the impression you aren't trying as hard as you should be, since your questions aren't exactly difficult or new (there is a good Search functionality here that you should try to use more often).
lehthanis
07-04-2008, 11:39 PM
That page seems liek its goign to help me a lot actually...
And as for the threads I've made recently...I see what you mean...and what makes it come across as so unprepared is the fact that I've kinda spent the last few months working this script, and the rash of threads is basically the final stages and polishing off to close this project down...Its kinda like I saved all my questions till the end.
Terribly sorry about all that, and thanks for the link!
lehthanis
07-05-2008, 02:11 AM
Ok...Its coming along...your link helped quite a bit actually...I'm understanding a bit more about how the macroscripts thing is working...though I'm not sure if I like it...I'm thinking perhaps macroscript isn't what I want to use???
I'm currently having a function scope problem and I've tried various different combinations of global declaration and everything, to no avail.
I've got it set up like so:
my scripts\startup folder has an ms file that merely calls the base macro in the scripts\xplane folder which is XPlaneObj8ToolsBase.mcr
scriptsDir = getDir #scripts
f = scriptsDir + "\\XPlane\\XPlaneObj8ToolsBase.mcr"
fileIn f
The macro file has this in it.
MacroScript XPlaneObj8Tools category:"X-PlaneObjTools"
(
include "XPlane\\Helpers.ms"
include "XPlane\\Modifiers.ms"
include "XPlane\\Functions.ms"
include "XPlane\\Export.ms"
include "XPlane\\Import.ms"
XPlaneObjRolloutFloater = newRolloutFloater "X-Plane OBJ Tools" 250 300
addrollout XPlaneObj8Export XPlaneObjRolloutFloater
addrollout XPlaneObj8Import XPlaneObjRolloutFloater
)
I have a function that is defined in functions.ms that is basically a filter for a pick button. When this was all in one file, it appeared to work...now that I've split it into multiple files the function doesn't seem to want to be found...even though all the helpers, modifiers, and rollouts do.
The function is declared in the root of the functions.ms file, and its being called as a ui element of one of the simplemods in modifiers.ms
I tried putting the function call inside the simplemod () block and it recognized it...but the filter is filtering it to the classof the scripted helper in helpers.ms...which it then doesn't recognize...
So its either not recognizing the function if its defined outside of the simplemod, or its not recognizing the helper its filtering to if its defined inside the simplemod...What gives?
RobGalanakis
07-05-2008, 02:34 AM
It is probably a scope problem, as you assume (I assume it is giving you the 'Type error: Call needs function or class, got: undefined'?)
You need to make sure your functions are declared before they are evaluated in any script. I can try to give you an example from my experience. I was using the function myStruct.myFunction in a script before I was declaring what myStruct was- whenever I ran the script, I would get the Type error undefined error. Honestly, I am not exactly sure why, even though it should be simple (I know the simple answer but it still doesn't seem right- if I use it undeclared, adn then later declare it as a Global, shouldn't that first call look to the global?).
Lesson is, make sure anything you use is declared BEFORE you use it. The best thing you can do is break out all your common functions into some Structs that you load before the actual macro, that way you will not get any scope problems/conflicts.
lehthanis
07-05-2008, 03:10 AM
which puts me into a bit of a quandary...chicken or egg first...
I have a simplemod that needs a function that filters a pickbutton so it only lets the user pick the helper object. I can globally declare the function, but it still needs to know the scripted helper object.
The fact that its all happening inside the () block of a macroscript (assuming include declares everything in the order in which its included) confuses me greatly...does the order in which it appears in the macroscript file specify the order in which its declared?
lehthanis
07-05-2008, 03:18 AM
The actual error I get is code block not created, unable to access code block local or parameter: pivot_filter
RobGalanakis
07-05-2008, 03:58 AM
Uh oh... are you using globals/external variables in your functions? Or is everything you are using in your function declared as a local in your function or passed in as a parameter? If you are not using an external values in your functions, then no idea, without seeing the actual code.
lehthanis
07-05-2008, 04:09 AM
I think I figured it out...I had EVERYTHING happening INSIDE of the macroscript...I've moved the scripted helpers, simplemods, and functions outside of the macroscript, and left only the export and import rollouts inside the macroscript...so this way the helpers, mods, and functions are already declared when the macro fires. I think...so far so good...we'll see.
Now...if someone can figure out http://forums.cgsociety.org/showthread.php?f=98&t=649625 I'll have pretty much all of my questions answered for the moment.
Thanks much!!!
CGTalk Moderation
07-05-2008, 04:09 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.