

Code: Select all
TxtFilePathName = "C:/tast.txt"
PositionScaleFactor =0.02649
EngineEffect = "Chemical"
EngineGroup = "Thruster"
EngineSize = "0.45 0.45 1.25"
EngineColor = "0.05 0.05 0.05"
EngineVolume = "0.5"
EngineSound = "Spacecraft/Shuttle_thruster.ogg"
RoundUp = false
AddToFile = true
fn round_to val n =
(
local mult = 10.0 ^ n
(floor ((val * mult) + 0.5)) / mult
)
fn CreateTxtFile =
(
close TXTfile
if (AddToFile != false) then (
TXTfile = openFile TXTfilePathName mode:"a"
)
else (
TXTfile = createFile TxtFilePathName
close TXTfile
TXTfile = openFile TXTfilePathName mode:"wt"
)
for a in selection do
(
if (RoundUp != false) then (
d_pos_x = (round_to(a.pos.x * PositionScaleFactor) 0) as integer
d_pos_y = (round_to(a.pos.y * PositionScaleFactor) 0) as integer
d_pos_z = (round_to(a.pos.z * PositionScaleFactor) 0) as integer
)
else (
d_pos_x = (formattedPrint (a.pos.x * PositionScaleFactor) format:"#.2f") as float
d_pos_y = (formattedPrint (a.pos.y * PositionScaleFactor) format:"#.2f") as float
d_pos_z = (formattedPrint (a.pos.z * PositionScaleFactor) format:"#.2f") as float
)
d_rot_x = (round_to a.rotation.x_rotation 0) as integer
d_rot_y = (round_to a.rotation.y_rotation 0) as integer
d_rot_z = (round_to a.rotation.z_rotation 0) as integer
format ("EngineEffect \"" + a.name + "\"\n{\n\tGroup\t\"" + EngineGroup +"\"\n\tType\t\"" + EngineEffect + "\"\n") to: TXTfile
format "%
" ("\tPos \t(" + d_pos_x as string + " " + d_pos_y as string + " " + d_pos_z as string + ")") to: TXTfile
format "%
" ("\tRot \t(" + d_rot_x as string + " " + d_rot_y as string + " " + d_rot_z as string +")" ) to: TXTfile
format ("\tSize\t(" + EngineSize + ")\n\tColor\t(" + EngineColor + ")\n\tVolume\t" + EngineVolume + "\n" + EngineSound + "}\n\n") to: TXTfile
)
close TXTfile
messagebox "Done!"
)
rollout ThrustExport "Export Thrusters v1.2"
(
editText folderPathTxt text:"C:/test.txt"
button btnBrowse "Select file"
checkbox AddtheButt "Don't replace file" tooltip:"Check to add new thrusters to file instead of wiping it clean before adding thrusters"
spinner ScaleFactorButt "Scale " type:#float range:[0, 1000, 0.02649] tooltip:"Scale position of objects by this amount, if the position in SE end up mismatching with positions in 3ds max"
checkbox RoundUpButt "Strip decimals" tooltip:"SE sometimes defaults position to 0 0 0 if there's decimals in the values. Check this if that'll happen, it'll round position to nearest integer"
dropdownlist EffectButt "Engine effect" items:#("Fusion", "Chemical", "Ion", "Ion2", "Aerospike", "Square")
dropdownlist GroupType "Engine Group" items:#("Main", "Retro", "Thruster", "Hover", "Warp")
edittext EngineSizeButt "Engine Size:" text:"0.45 0.45 1.25" tooltip:"I don't know what SE uses as scale measurement, so test what looks right"
colorpicker theColor "Exhaust color:" color:[20,20,20]
spinner ScaleSoundButt "Sound volume" type:#float range:[0, 1, 0.9999]
dropdownlist SoundEffectButt "Sound effect" items:#("None", "Starship_engine", "Starship_thruster", "Starship_warp", "Shuttle_engine", "Shuttle_thruster", "Shuttle_hover") selection:2
button bake_butt "Export thrusters!"
on btnBrowse pressed do
(
local path = getSaveFileName types:"Text(*.txt)|*.txt|"
if path != undefined do folderPathTxt.text = path
)
on bake_butt pressed do (
TxtFilePathName = folderPathTxt.text
PositionScaleFactor=ScaleFactorButt.value as float
EngineEffect = EffectButt.selected
EngineGroup = GroupType.selected
EngineSize = EngineSizeButt.text -- "0.45 0.45 1.25"
EngineColor = ((formattedPrint (theColor.color.red /255) format:"#.3f") as string + " " + (formattedPrint (theColor.color.green /255) format:"#.3f") as string + " " + (formattedPrint (theColor.color.blue /255) format:"#.3f") as string ) as string--"0.05 0.05 0.05"
EngineVolume = ScaleSoundButt.value as string
-- EngineSound = ("Spacecraft/" + SoundEffectButt.selected as string + ".ogg") as string
RoundUp = RoundUpButt.checked
AddToFile = AddtheButt.checked
if (SoundEffectButt.selection != 1) then (
EngineSound = ("\tSound\t\"" + ("Spacecraft/" + SoundEffectButt.selected as string + ".ogg") as string + "\"\n") as string
)
else (
EngineSound = " " as string
)
if (selection.count != 0) then (
CreateTxtFile()
)
else messagebox "No objects selected"
)
)
createDialog ThrustExport width:180

All options for the script are in the top, almost all mirror the settings in the definitions themselves and used to fill them in (I'd recommended to initially place one thruster in SE and set it up to your liking (Scale, color, etc), and then use it's parameters in the script).
The only outcast is the Scale Factor - It controls, well, relative scale of the positions relative to model. My model was done in a scale 1:100, using centimeters as display units (So every centimeter actually equals 1 meter... That ship is big) and inches as system units, and also was exported in obj in a scale of 1.0, according to export settings. In SE I had to set "Unit" parameter in .cfg file of the module to 2.649 in order for the thing to be 1:1 scale in the engine, and by experimenting with the script i found out that same 2.649 put in there provides correct offsets so that thruster flames in SE are in the same places as dummies are in the 3ds max. These conversions and juggling of several unit systems confuse me, so make out of that information what you will, I hope it'll help you.
One another thing is that for some reason in SE the pivot point of the model became shifted forward 90 meters, so I had to adjust the positions of the dummies accordingly. Maybe that was me borking something during either export or conversion, but I thought I'd mention that too just in case.
Current limitation of the script is that it is able to output only one thruster setup at once, so you'd need to edit it and run it multiple times with different parameters and selecting dummies in groups. I don't yet know how to streamline it into version that's capable of generating multiple thruster setups, but maybe I'll manage that in the future. Somehow.
Another limitation is that it it usable only by those who have 3ds max, but oh well, I work with what I use, sorry...
► Show Spoiler