Код: Выделить всё
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
Все параметры аналогичны параметрам из редактора кораблей в программе.
Единственное исключение - scale. Оно отвечает за масштаб расстояний. С ним наверное придется повозиться опытным путем чтобы понять какой параметр дает 1:1 перенос координат в движок, у меня от всех этих этапов конверсий (В максе есть видимые юниты, которые на самом деле пересчитываются в системные юниты, которые экспортируются в обж в масштабе, который потом ещё надо подкручивать в SE ещё одним масштабом...) голова кругом.
Пока единственное ограничение скрипта в том что он может выводить только одну настройку двигателей за раз, и он не сохраняет эти настройки.
► Показать