Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #cs ----------------------------------------------------------------------------
- AutoIt Version: 3.3.10.2
- Author: JBRWolf
- Script Function:
- Convert Feral Heart Maps into Impressive Title server ones.
- #ce ----------------------------------------------------------------------------
- ;---------------Includes---------------
- #include <WindowsConstants.au3>
- #include <GUIConstantsEx.au3>
- #include <EditConstants.au3>
- #include <GuiEdit.au3>
- #include <ScrollBarsConstants.au3>
- #include <File.au3>
- #include <Array.au3>
- ;--------------------------------------
- ;---Program Resource Location Variables---
- ;--Should exist--
- $resourceDir = @ScriptDir&"\resources"
- $dataDir = $resourceDir&"\data"
- $tempDir = $resourceDir&"\temp"
- $optionsApp = $resourceDir&"\changeOptions.exe"
- ;----------------
- ;--Dynamic Files--
- $errorLog = @ScriptDir&"\Error Log.txt"
- $normalLog = @ScriptDir&"\log.txt"
- $optionsFile = $dataDir&"\options.dat"
- $tempFolder = ""
- ;-----------------
- ;-
- $mapName = ""
- $FHFolder = ""
- $FHTerrainsFolder = ""
- $FHMapFile = ""
- $FHMapFolder = ""
- $FHObjectsFolder = ""
- $CopyObjectFiles = ""
- $OutputFolder = ""
- ;----
- ;--
- $mapXSize = 0
- $mapZSize = 0
- $mapHeight = 0
- $mapDisplayName = ""
- ;----
- ;-----------------------------------------
- ;-Resource Check-
- if Not FileExists($resourceDir) Then
- error("Missing dirctory '"&$resourceDir&"'",1,True)
- EndIf
- if Not FileExists($dataDir) Then
- error("Missing dirctory '"&$dataDir&"'",2,True)
- EndIf
- if Not FileExists($optionsApp) Then
- error("Missing file '"&$optionsApp&"'",3,True)
- EndIf
- if Not FileExists($tempDir) Then
- error("Missing dirctory '"&$tempDir&"'",9,True)
- EndIf
- ;----------------
- Run($optionsApp)
- while ProcessExists("changeOptions.exe")
- Sleep(100)
- WEnd
- if FileExists($normalLog) Then
- FileDelete($normalLog)
- EndIf
- ;----------------------------------------GUI----------------------------------------
- $GuiWin = GUICreate("Map Converter Version 0.6", 500, 300,-1,-1)
- $skin = GUICtrlCreatePic("",0,0,0,0) ; --------------- Background image
- GUICtrlSetState(-1, $GUI_DISABLE)
- $optionsButton = GUICtrlCreateButton("Options",200,10,100,50)
- GUICtrlSetFont(-1,14)
- $objectscovertButton = GUICtrlCreateButton("Objects Only Convert",160,75,180,50) ;place holder
- GUICtrlSetState(-1,$GUI_DISABLE )
- GUICtrlSetFont(-1,12)
- $convertButton = GUICtrlCreateButton("Convert",200,140,100,50)
- GUICtrlSetFont(-1,14)
- $credit = GUICtrlCreateLabel("-By JBRWolf-",5,5,100,20)
- $outputBox = GUICtrlCreateEdit("",0,200,500,80,BitOR($WS_VSCROLL,$ES_READONLY,$ES_CENTER))
- GUISetState(@SW_SHOW)
- ;-----------------------------------------------------------------------------------
- ;============================ Run Time ============================
- outputPrint("================================== Startup ==================================")
- loadOptions()
- outputPrint("Clearing temp files..")
- ClearFoldersInFolder($tempDir)
- outputPrint("Temp files cleared")
- While 1
- $msg = GUIGetMsg()
- If $msg == $GUI_EVENT_CLOSE Then ExitLoop
- If $msg == $optionsButton Then
- Run($optionsApp)
- while ProcessExists("changeOptions.exe")
- Sleep(100)
- WEnd
- loadOptions()
- EndIf
- if $msg == $convertButton Then
- loadOptions()
- outputPrint("")
- outputPrint("-Checking file existance -")
- outputPrint("")
- if FileExists($FHMapFile) Then
- outputPrint($FHMapFile&" exists!")
- if FileExists($FHObjectsFolder) Then
- outputPrint($FHObjectsFolder&" exists!")
- if FileExists($OutputFolder) Then
- outputPrint($OutputFolder&" exists!")
- if FileExists($FHMapFolder) Then
- outputPrint($FHMapFolder&" exists!")
- outputPrint("-----------------")
- outputPrint("")
- outputPrint("Finding terrain file..")
- $terrainFile = $FHMapFolder&"\"&$mapName&"Terrain.cfg"
- outputPrint("Checking for "&$terrainFile)
- if FileExists($terrainFile) Then
- outputPrint("Terrain file detected: "&$terrainFile)
- outputPrint("Clearing temp files..")
- ClearFoldersInFolder($tempDir)
- outputPrint("Temp files cleared")
- $tempFolder = $tempDir&"\"&$mapName
- outputPrint("Creating temp folder "&$tempFolder)
- if FileExists($tempDir) then
- if FileExists($tempFolder) Then
- DirRemove($tempFolder,1)
- outputPrint("Removed already existing temp folder "&$tempFolder)
- EndIf
- DirCreate($tempFolder)
- outputPrint("Temp folder created")
- outputPrint("Reading map dimensions..")
- $no_lines = _FileCountLines($terrainFile)
- outputPrint("Terrain file is "&$no_lines&" lines long")
- if $no_lines > 3 Then
- $foundx = False
- $foundz = False
- $foundh = False
- for $i = 0 To $no_lines
- $line = FileReadLine($terrainFile,$i)
- outputPrint("Reading line "&$i&": "&$line)
- $line = StringLower($line)
- if StringLeft($line,11) == "pageworldx=" Then
- $mapXSize = Number(StringTrimLeft($line,11))
- $foundx = True
- outputPrint("Found map x size: "&$mapXSize)
- Else
- if StringLeft($line,11) == "pageworldz=" Then
- $mapZSize = Number(StringTrimLeft($line,11))
- $foundz = True
- outputPrint("Found map z size: "&$mapZSize)
- Else
- if StringLeft($line,10) == "maxheight=" Then
- $mapHeight = Number(StringTrimLeft($line,10))
- $foundh = True
- outputPrint("Found map height: "&$mapHeight)
- EndIf
- EndIf
- EndIf
- if $foundx and $foundz and $foundh Then
- ExitLoop
- EndIf
- Next
- if $foundx and $foundz and $foundh Then
- outputPrint("")
- outputPrint("---Dimensions found---")
- outputPrint("$mapXSize = "&$mapXSize)
- outputPrint("$mapZSize = "&$mapZSize)
- outputPrint("$mapHeight = "&$mapHeight)
- outputPrint("----------------------")
- outputPrint("")
- outputPrint("Copying terrain file to temp folder")
- FileCopy($terrainFile,$tempFolder&"\"&$mapName&"Terrain.cfg")
- outputPrint("Copied '"&$terrainFile&"' to '"&$tempFolder&"\"&$mapName&"Terrain.cfg"&"'")
- outputPrint("")
- outputPrint("==================== .world file ====================")
- outputPrint("")
- outputPrint("Getting map display name and spawn position...")
- $no_lines = _FileCountLines($FHMapFile)
- outputPrint("Map file is "&$no_lines&" lines long")
- if $no_lines > 3 Then
- $foundDisplayName = False
- $foundSpawn = False
- $spawnPos = ""
- $hasPortal = False
- $section = ""
- for $i = 0 To $no_lines ;Could of done all the reading now but oh well
- $line = FileReadLine($FHMapFile,$i)
- outputPrint("Reading line "&$i&": "&$line)
- $lowerline = StringLower($line)
- if StringLeft($lowerline,5) == "name=" Then
- if $section == "map" Then
- $mapDisplayName = StringTrimLeft($line,5)
- $foundDisplayName = True
- outputPrint("Found map display name: "&$mapDisplayName)
- EndIf
- Else
- if StringLeft($lowerline,1) == "[" Then
- $section = StringTrimRight(StringTrimLeft($lowerline,1),1)
- Else
- if $section == "portal" Then
- If StringLeft($lowerline,10) == "hasportal=" Then
- if StringTrimLeft($lowerline,10) == "true" Then
- $hasPortal = True
- EndIf
- Else
- if $hasPortal Then
- If StringLeft($lowerline,9) == "position=" Then
- $spawnPos = StringTrimLeft($lowerline,9)
- outputPrint("Found map spawn pos: "&$spawnPos)
- $foundSpawn = True
- EndIf
- EndIf
- EndIf
- EndIf
- EndIf
- EndIf
- Next
- if $foundDisplayName Then
- $worldFile = $tempFolder&"\"&$mapDisplayName&".world"
- outputPrint("")
- outputPrint("Writing world file basics...")
- FileWriteLine($worldFile,"[Initialize]")
- FileWriteLine($worldFile,$mapName&"Terrain.cfg")
- FileWriteLine($worldFile,$mapXSize)
- FileWriteLine($worldFile,$mapZSize)
- ;Spawn position?
- if $foundSpawn Then
- FileWriteLine($worldFile,$spawnPos)
- Else
- FileWriteLine($worldFile,$mapXSize/2&" "&$mapHeight/2&" "&$mapZSize/2)
- EndIf
- ;---
- outputPrint("Reading and writing weather, water and music sections(if any)..")
- outputPrint("")
- $section = ""
- $mapWeather = ""
- $mapSong = ""
- $mapOceanPos = ""
- $mapOceanSize = ""
- $foundMapOceanPos = False
- $foundMapOceanSize = False
- for $i = 0 To $no_lines
- $line = FileReadLine($FHMapFile,$i)
- outputPrint("Reading line "&$i&": "&$line)
- $lowerline = StringLower($line)
- if StringLeft($lowerline,1) == "[" Then
- $section = StringTrimRight(StringTrimLeft($lowerline,1),1)
- outputPrint("Now reading section: "&$section)
- Else
- if $section == "weather" Then
- if StringLeft($lowerline,9) == "filename=" Then
- $mapWeather = StringTrimLeft($line,9)
- outputPrint("Found and writing weather cycle: "&$mapWeather)
- FileWriteLine($worldFile,"[WeatherCycle]")
- FileWriteLine($worldFile,$mapWeather)
- EndIf
- EndIf
- if $section == "music" Then
- if StringLeft($lowerline,5) == "name=" Then
- $mapSong = StringTrimLeft($line,5)
- outputPrint("Found and writing music: "&$mapSong)
- FileWriteLine($worldFile,"[Music]")
- FileWriteLine($worldFile,$mapSong)
- EndIf
- EndIf
- if $section == "water" Then
- if StringLeft($lowerline,6) == "ocean=" Then
- $mapOceanPos= StringTrimLeft($line,6)
- $foundMapOceanPos = True
- outputPrint("Found water pos: "&$mapOceanPos)
- Else
- if StringLeft($lowerline,10) == "oceansize=" Then
- $mapOceanSize= StringTrimLeft($line,10)
- $foundMapOceanSize = True
- outputPrint("Found water size: "&$mapOceanSize)
- EndIf
- EndIf
- if $foundMapOceanPos and $foundMapOceanSize Then
- outputPrint("Writing Water Plane")
- FileWriteLine($worldFile,"[WaterPlane]")
- FileWriteLine($worldFile,$mapOceanPos)
- Local $osize = StringSplit($mapOceanSize, " ")
- outputPrint("X: "&$osize[1])
- outputPrint("Z: "&$osize[2])
- FileWriteLine($worldFile,$osize[1])
- FileWriteLine($worldFile,$osize[2])
- EndIf
- EndIf
- EndIf
- Next
- outputPrint("")
- outputPrint("Reading gates file..")
- $gatesFile = $FHMapFolder&"\"&$mapName&"Gates.cfg"
- if FileExists($gatesFile) Then
- $no_lines = _FileCountLines($gatesFile)
- outputPrint("Gates file is "&$no_lines&" lines long")
- if $no_lines > 1 Then
- if FileReadLine($gatesFile,1) == "" Then
- outputPrint("No gates found")
- Else
- for $i = 0 To $no_lines
- $line = FileReadLine($gatesFile,$i)
- outputPrint("Reading line "&$i&": "&$line)
- Local $gateParts = StringSplit($line,";")
- $gatePartsLen = UBound($gateParts)
- if $gatePartsLen > 4 Then
- $gatePos = $gateParts[1]
- $gateEndPos = $gateParts[5]
- $gateName = $gateParts[4]
- outputPrint("Writing gate "&$gateName&" with pos "&$gatePos&" to pos "&$gateEndPos)
- FileWriteLine($worldFile,"[Gate]")
- FileWriteLine($worldFile,"GateMatBlack")
- FileWriteLine($worldFile,$gatePos)
- FileWriteLine($worldFile,$gateName)
- FileWriteLine($worldFile,$gateEndPos)
- EndIf
- Next
- EndIf
- Else
- outputPrint("No gates found")
- EndIf
- Else
- outputPrint("Failed to find gates file("&$gatesFile&")")
- EndIf
- outputPrint("")
- outputPrint("Reading objects file..")
- $objectsFile = $FHMapFolder&"\"&$mapName&"Objects.cfg"
- if FileExists($objectsFile) Then
- $no_lines = _FileCountLines($objectsFile)
- outputPrint("Objects file is "&$no_lines&" lines long")
- if $no_lines > 1 Then
- if FileReadLine($objectsFile,1) == "" Then
- outputPrint("No objects found")
- Else
- $curObj = ""
- $objectBlueprintFile = ""
- $objFileLen = 0
- $objLinePos = 0
- Global $EmptyArray[1]
- Global $blueprintMeshes[1]
- Global $blueprintColls[1]
- $blueprintMeshes = $EmptyArray
- $blueprintColls = $EmptyArray
- for $i = 0 To $no_lines
- $line = FileReadLine($objectsFile,$i)
- outputPrint("Reading line "&$i&": "&$line)
- if StringLeft($line,1) == "[" Then
- $curObj = StringTrimRight(StringTrimLeft($line,1),1)
- outputPrint("Current object: "&$curObj)
- Local $objparts = StringSplit($curObj,"/")
- if UBound($objparts) == 3 Then
- $objectBlueprintFile = $FHObjectsFolder&"\"&$objparts[1]&".object"
- if FileExists($objectBlueprintFile) Then
- outputPrint("")
- outputPrint("Reading file "&$objectBlueprintFile)
- $objFileLen = _FileCountLines($objectBlueprintFile)
- outputPrint("Object blueprint file is "&$no_lines&" lines long")
- outputPrint("")
- outputPrint("Searching for object "&$objparts[2])
- outputPrint("")
- $foundLine = False
- $inBPSection = False
- $blueprintMeshes = $EmptyArray ;# Version 0.6
- $blueprintColls = $EmptyArray
- for $z = 0 To $objFileLen
- $line2 = FileReadLine($objectBlueprintFile,$z)
- outputPrint(" > Reading(object blueprint file) line "&$z&": "&$line2)
- if StringLeft($line2,1) == "[" Then
- $tempObjBlue = StringTrimRight(StringTrimLeft($line2,1),1);Sometimes you just run out of things to name your variables xD
- if $tempObjBlue == $objparts[2] Then
- outputPrint("Found object blueprint at line "&$z)
- $objLinePos = $z
- $inBPSection = True
- $foundLine = True
- Else
- $inBPSection = False
- EndIf
- EndIf
- if $inBPSection Then
- if StringLeft($line2,4) == "mesh" Then
- $linetrimmed = StringReplace($line2,"%","")
- $linetrimmed = StringTrimLeft($linetrimmed,StringInStr($linetrimmed,"="))
- outputPrint("Found mesh "&$linetrimmed)
- _ArrayInsert($blueprintMeshes, 1, $linetrimmed)
- Else
- if StringLeft($line2,4) == "coll" Then
- $linetrimmed = StringReplace($line2,"%","")
- $linetrimmed = StringTrimLeft($linetrimmed,StringInStr($linetrimmed,"="))
- outputPrint("Found collision "&$linetrimmed)
- _ArrayInsert($blueprintColls, 1, $linetrimmed)
- EndIf
- EndIf
- EndIf
- Next
- if Not $foundLine Then
- $curObj = ""
- outputPrint("Failed to find object blueprint")
- EndIf
- Else
- outputPrint("Failed to find object blueprint file")
- $curObj = ""
- EndIf
- Else
- outputPrint("Error reading object name")
- $curObj = ""
- EndIf
- Else
- if $line == "" Then
- Else
- ;This is starting to get confusing xD
- outputPrint("")
- outputPrint("Reading placement details..")
- outputPrint("")
- $myObjectPos = ""
- $myObjectPosX = 0
- $myObjectPosY = 0
- $myObjectPosZ = 0
- $myObjectScale = ""
- $myObjectScaleX = 0
- $myObjectScaleY = 0
- $myObjectScaleZ = 0
- $myObjectRot = ""
- $myObjectRotP = 0 ;pitch
- $myObjectRotY = 0 ;yaw
- $myObjectRotR = 0 ;roll
- $myObjectRotX = 0 ; ? Lol
- if StringInStr($line,";") Then
- local $myObjectTmpArr = StringSplit($line,";")
- $TmpArrSize = UBound($myObjectTmpArr)
- ;pos
- local $myObjectTmpPosArr = StringSplit($myObjectTmpArr[1]," ");You can tell I did this second because it doesn't have the winner comment
- if UBound($myObjectTmpPosArr) == 4 then
- $myObjectPos = $myObjectTmpArr[1]
- $myObjectPosX = Number($myObjectTmpPosArr[1])
- $myObjectPosY = Number($myObjectTmpPosArr[2])
- $myObjectPosZ = Number($myObjectTmpPosArr[3])
- EndIf
- ;scale
- if $TmpArrSize > 2 then
- local $myObjectTmpScaleArr = StringSplit($myObjectTmpArr[2]," ");This variable is actually longer xD
- if UBound($myObjectTmpScaleArr) == 4 then
- $myObjectScale = $myObjectTmpArr[2]
- $myObjectScaleX = Number($myObjectTmpScaleArr[1])
- $myObjectScaleY = Number($myObjectTmpScaleArr[2])
- $myObjectScaleZ = Number($myObjectTmpScaleArr[3])
- EndIf
- EndIf
- ;Rot
- if $TmpArrSize > 3 then
- local $myObjectTmpRotArr = StringSplit($myObjectTmpArr[3]," ")
- if UBound($myObjectTmpRotArr) == 5 then
- $myObjectRot = $myObjectTmpArr[3]
- $myObjectRotP = Number($myObjectTmpRotArr[1])
- $myObjectRotY = Number($myObjectTmpRotArr[2])
- $myObjectRotR = Number($myObjectTmpRotArr[3])
- $myObjectRotX = Number($myObjectTmpRotArr[4])
- EndIf
- EndIf
- outputPrint("Object x:"&$myObjectPosX)
- outputPrint("Object y:"&$myObjectPosY)
- outputPrint("Object z:"&$myObjectPosZ)
- ;Can't be bothered to output the rest xD
- Else ;Only position info available for this obj
- $myObjectPos = $line
- local $myObjectTmpPosArr = StringSplit($myObjectPos," ");And the winner of the longest variable name goes to
- if UBound($myObjectTmpPosArr) == 4 then
- $myObjectPosX = Number($myObjectTmpPosArr[1])
- $myObjectPosY = Number($myObjectTmpPosArr[2])
- $myObjectPosZ = Number($myObjectTmpPosArr[3])
- outputPrint("Object x:"&$myObjectPosX)
- outputPrint("Object y:"&$myObjectPosY)
- outputPrint("Object z:"&$myObjectPosZ)
- ;default scale and rotation
- $myObjectScale = "1 1 1"
- $myObjectScaleX = 1
- $myObjectScaleY = 1
- $myObjectScaleZ = 1
- $myObjectRot = "0 0 0 0"
- $myObjectRotP = 0
- $myObjectRotY = 0
- $myObjectRotR = 0
- $myObjectRotX = 0
- EndIf
- EndIf
- ;Time to go backwards in the script and make an array system for the blueprint
- ;Guess who's back? Back again. Welp time for the hard part? Hah, I'm gonna go make a cup of tea
- ;-Slurps tea- Anyway, enough procastination(probably spelt that wrong) time to write dis thing
- $meshListLen = UBound($blueprintMeshes)
- $collListLen = UBound($blueprintColls)
- outputPrint("")
- outputPrint("Blueprint meshes len: "&$meshListLen)
- ;_ArrayDisplay($blueprintMeshes)
- outputPrint("Blueprint colls len: "&$collListLen)
- ;_ArrayDisplay($blueprintColls)
- if $meshListLen > 1 Then
- for $y = 0 To $meshListLen-1 ; the amount of for loops in this script xD
- $MEMeshName = ""
- if $blueprintMeshes[$y] == "" Then
- Else
- if StringInStr($blueprintMeshes[$y],";") Then
- Local $meshExplode = StringSplit($blueprintMeshes[$y],";")
- if UBound($meshExplode) > 4 Then
- $MEMeshName = $meshExplode[1]
- $MEMeshPos = $meshExplode[2]
- $MEMeshPosX = 0
- $MEMeshPosY = 0
- $MEMeshPosZ = 0
- local $posExplode = StringSplit($meshExplode[2]," ")
- if UBound($posExplode) == 4 Then
- $MEMeshPosX = Number($posExplode[1])
- $MEMeshPosY = Number($posExplode[2])
- $MEMeshPosZ = Number($posExplode[3])
- EndIf
- $MEMeshScale = $meshExplode[3]
- $MEMeshScaleX = 1
- $MEMeshScaleY = 1
- $MEMeshScaleZ = 1
- local $scaleExplode = StringSplit($meshExplode[3]," ")
- if UBound($scaleExplode) == 4 Then
- $MEMeshScaleX = Number($scaleExplode[1])
- $MEMeshScaleY = Number($scaleExplode[2])
- $MEMeshScaleZ = Number($scaleExplode[3])
- EndIf
- $MEMeshRot = $meshExplode[4]
- $MEMeshRotP = 0
- $MEMeshRotY = 0
- $MEMeshRotR = 0
- $MEMeshRotX = 0
- local $rotExplode = StringSplit($meshExplode[4]," ")
- if UBound($rotExplode) == 5 Then
- $MEMeshRotP = Number($rotExplode[1])
- $MEMeshRotY = Number($rotExplode[2])
- $MEMeshRotR = Number($rotExplode[3])
- $MEMeshRotX = Number($rotExplode[4])
- EndIf
- if UBound($meshExplode) == 6 Then
- ;insert get mesh blueprint material code here(possible future feature)
- EndIf
- if $MEMeshName == "" Then
- Else
- outputPrint("Writing object "&$MEMeshName)
- FileWriteLine($worldFile,"[Object]")
- FileWriteLine($worldFile,$MEMeshName)
- $myObjectPos = $myObjectPosX+$MEMeshPosX&" "&$myObjectPosY+$MEMeshPosY&" "&$myObjectPosZ+$MEMeshPosZ
- outputPrint("Pos: "&$myObjectPos)
- FileWriteLine($worldFile,$myObjectPos)
- $myObjectScale = $MEMeshScaleX*$myObjectScaleX&" "&$MEMeshScaleY*$myObjectScaleY&" "&$MEMeshScaleZ*$myObjectScaleZ
- outputPrint("Scale: "&$myObjectScale)
- FileWriteLine($worldFile,$myObjectScale)
- $myObjectRot = $myObjectRotP+$MEMeshRotP&" "&$myObjectRotY+$MEMeshRotY&" "&$myObjectRotR+$MEMeshRotR&" "&$myObjectRotX+$MEMeshRotX
- outputPrint("Rot: "&$myObjectRot)
- FileWriteLine($worldFile,$myObjectRot)
- outputPrint("")
- EndIf
- EndIf
- EndIf
- EndIf
- Next
- EndIf
- ;halfway done ^^ now for collisions
- if $collListLen > 1 Then
- for $y = 0 To $collListLen-1
- $MECollType = ""
- if $blueprintColls[$y] == "" Then
- Else
- if StringInStr($blueprintColls[$y],";") Then
- Local $meshExplode = StringSplit($blueprintColls[$y],";")
- if UBound($meshExplode) > 3 Then
- $MEMeshPosX = 0
- $MEMeshPosY = 0
- $MEMeshPosZ = 0
- if $meshExplode[1] == "b" Then
- $MECollType = "CollBox"
- local $posExplode = StringSplit($meshExplode[2]," ")
- if UBound($posExplode) == 4 Then
- $MEMeshPosX = Number($posExplode[1])
- $MEMeshPosY = Number($posExplode[2])
- $MEMeshPosZ = Number($posExplode[3])
- EndIf
- $MEMeshScaleX = 1
- $MEMeshScaleY = 1
- $MEMeshScaleZ = 1
- local $scaleExplode = StringSplit($meshExplode[3]," ")
- if UBound($scaleExplode) == 4 Then
- $MEMeshScaleX = Number($scaleExplode[1])
- $MEMeshScaleY = Number($scaleExplode[2])
- $MEMeshScaleZ = Number($scaleExplode[3])
- EndIf
- outputPrint("Writing collision "&$MECollType)
- FileWriteLine($worldFile,"["&$MECollType&"]")
- $myObjectPos = $myObjectPosX+$MEMeshPosX&" "&$myObjectPosY+$MEMeshPosY&" "&$myObjectPosZ+$MEMeshPosZ
- outputPrint("Pos: "&$myObjectPos)
- FileWriteLine($worldFile,$myObjectPos)
- $myObjectScale = $MEMeshScaleX*$myObjectScaleX&" "&$MEMeshScaleY*$myObjectScaleY&" "&$MEMeshScaleZ*$myObjectScaleZ
- outputPrint("Scale: "&$myObjectScale)
- FileWriteLine($worldFile,$myObjectScale)
- outputPrint("")
- Else
- if $meshExplode[1] == "s" Then
- $MECollType = "CollSphere"
- local $posExplode = StringSplit($meshExplode[2]," ")
- if UBound($posExplode) == 4 Then
- $MEMeshPosX = Number($posExplode[1])
- $MEMeshPosY = Number($posExplode[2])
- $MEMeshPosZ = Number($posExplode[3])
- EndIf
- $MEMeshScale = 1
- $MEMeshScale = $meshExplode[3]
- outputPrint("Writing collision "&$MECollType)
- FileWriteLine($worldFile,"["&$MECollType&"]")
- $myObjectPos = $myObjectPosX+$MEMeshPosX&" "&$myObjectPosY+$MEMeshPosY&" "&$myObjectPosZ+$MEMeshPosZ
- outputPrint("Pos: "&$myObjectPos)
- FileWriteLine($worldFile,$myObjectPos)
- $scalemultiplier = ($myObjectScaleX+$myObjectScaleY+$myObjectScaleZ)/3
- outputPrint("Scale multiplier: "&$scalemultiplier)
- $myObjectScale = $MEMeshScale*$scalemultiplier
- outputPrint("Scale: "&$myObjectScale)
- FileWriteLine($worldFile,$myObjectScale)
- outputPrint("")
- EndIf
- EndIf
- EndIf
- EndIf
- EndIf
- Next
- EndIf
- outputPrint("")
- EndIf
- EndIf
- Next
- EndIf
- Else
- outputPrint("No objects found")
- EndIf
- EndIf
- ;Yay finished the objects converter finally
- outputPrint("")
- outputPrint("Copying other files to temp folder...")
- CopyFolderFiles($FHMapFolder,$tempFolder)
- outputPrint("")
- outputPrint("Copying files to output...")
- $outoutFile = $OutputFolder&"\"&$mapDisplayName
- if FileExists($outoutFile) Then
- outputPrint("Removing already existing folder "&$outoutFile)
- DirRemove($outoutFile,1)
- EndIf
- outputPrint("Creating output directory "&$outoutFile)
- DirCreate($outoutFile)
- CopyFolderFiles2($tempFolder,$outoutFile)
- outputPrint("")
- outputPrint("")
- outputPrint("=================================================")
- outputPrint("=================================================")
- outputPrint("Done!")
- outputPrint("=================================================")
- outputPrint("=================================================")
- Else
- error("Error finding map display name",14,False)
- EndIf
- Else
- error("Error reading map file",13,False)
- EndIf
- Else
- error("Couldn't read map dimensions",12,False)
- EndIf
- Else
- error("Error reading terrain file",11,False)
- EndIf
- Else
- error("Failed to create temp folder",10,False)
- EndIf
- Else
- error("Failed to find terrain file",4,False)
- EndIf
- Else
- error("Failed to find map folder",5,False)
- EndIf
- Else
- error("Failed to find output folder",6,False)
- EndIf
- Else
- error("Failed to find FH objects folder",7,False)
- EndIf
- Else
- error("Failed to find map file",8,False)
- EndIf
- EndIf
- Sleep(0)
- WEnd
- ;==================================================================
- ;----------------------------Functions----------------------------
- Func error($errorText,$errorNumber,$fatal)
- ConsoleWrite("--Error--"&@CRLF)
- ConsoleWrite($errorNumber&": "&$errorText&@CRLF)
- ConsoleWrite("---------"&@CRLF)
- if $fatal Then
- outputPrint("Fatal Error("&$errorNumber&"): "&$errorText)
- MsgBox(0,"Fatal Error("&$errorNumber&")",$errorText)
- FileWriteLine($errorLog, "["&@MDAY&"/"&@MON&"/"&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC&"] Fatal Error("&$errorNumber&"): "&$errorText) ;Notice how the date is in the format day/month/year, yay British errors!
- Exit
- Else
- outputPrint("Error("&$errorNumber&"): "&$errorText)
- MsgBox(0,"Error("&$errorNumber&")",$errorText)
- FileWriteLine($errorLog, "["&@MDAY&"/"&@MON&"/"&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC&"] Error("&$errorNumber&"): "&$errorText)
- EndIf
- outputPrint("Clearing temp files..")
- ClearFoldersInFolder($tempDir)
- outputPrint("Temp files cleared")
- EndFunc
- Func loadOptions()
- if FileExists($optionsFile) Then
- Local $ops
- _FileReadToArray($optionsFile, $ops)
- outputPrint("")
- outputPrint("-Loading Options-")
- outputPrint("")
- if UBound($ops) == 9 Then
- $mapName = $ops[1]
- outputPrint("Loaded Option 1:"&$ops[1])
- $FHFolder = $ops[2]
- outputPrint("Loaded Option 2:"&$ops[2])
- $FHTerrainsFolder = $ops[3]
- outputPrint("Loaded Option 3:"&$ops[3])
- $FHMapFile = $ops[4]
- outputPrint("Loaded Option 4:"&$ops[4])
- $FHMapFolder = $ops[5]
- outputPrint("Loaded Option 5:"&$ops[5])
- $FHObjectsFolder = $ops[6]
- outputPrint("Loaded Option 6:"&$ops[6])
- $CopyObjectFiles = $ops[7]
- outputPrint("Loaded Option 7:"&$ops[7])
- $OutputFolder = $ops[8]
- outputPrint("Loaded Option 8:"&$ops[8])
- outputPrint("-----------------")
- outputPrint("")
- Return
- EndIf
- EndIf
- $mapName = ""
- $FHFolder = ""
- $FHTerrainsFolder = ""
- $FHMapFile = ""
- $FHMapFolder = ""
- $FHObjectsFolder = ""
- $CopyObjectFiles = ""
- $OutputFolder = ""
- outputPrint("-----------------")
- outputPrint("")
- EndFunc
- Func saveOptions()
- outputPrint("")
- outputPrint("-Saving Options-")
- outputPrint("")
- if FileExists($optionsFile) Then
- outputPrint("-Deleting old options-")
- FileDelete($optionsFile)
- EndIf
- FileWriteLine($optionsFile,$mapName)
- outputPrint("Saved Option 1($mapName):"&$mapName)
- FileWriteLine($optionsFile,$FHFolder)
- outputPrint("Saved Option 2($FHFolder):"&$FHFolder)
- FileWriteLine($optionsFile,$FHTerrainsFolder)
- outputPrint("Saved Option 3($FHTerrainsFolder):"&$FHTerrainsFolder)
- FileWriteLine($optionsFile,$FHMapFile)
- outputPrint("Saved Option 4($FHMapFile):"&$FHMapFile)
- FileWriteLine($optionsFile,$FHMapFolder)
- outputPrint("Saved Option 4($FHMapFolder):"&$FHMapFolder)
- FileWriteLine($optionsFile,$FHObjectsFolder)
- outputPrint("Saved Option 5($FHObjectsFolder):"&$FHObjectsFolder)
- FileWriteLine($optionsFile,$CopyObjectFiles)
- outputPrint("Saved Option 5($CopyObjectFiles):"&$CopyObjectFiles)
- FileWriteLine($optionsFile,$OutputFolder)
- outputPrint("Saved Option 6($OutputFolder):"&$OutputFolder)
- outputPrint("-----------------")
- outputPrint("")
- EndFunc
- Func outputPrint($outtxt)
- FileWriteLine($normalLog,$outtxt)
- GUICtrlSetData($outputBox,StringRight(GUICtrlRead($outputBox)&@CRLF&$outtxt,5000))
- _GUICtrlEdit_Scroll($outputBox, $SB_SCROLLCARET)
- EndFunc
- Func ClearFoldersInFolder($SourceFolder)
- Local $Search
- Local $File
- Local $FileAttributes
- Local $FullFilePath
- $Search = FileFindFirstFile($SourceFolder & "\*.*")
- While 1
- If $Search = -1 Then
- ExitLoop
- EndIf
- $File = FileFindNextFile($Search)
- If @error Then ExitLoop
- $FullFilePath = $SourceFolder & "\" & $File
- $FileAttributes = FileGetAttrib($FullFilePath)
- If StringInStr($FileAttributes,"D") Then
- DirRemove($FullFilePath,1)
- outputPrint("Deleted folder "&$FullFilePath)
- EndIf
- WEnd
- FileClose($Search)
- EndFunc
- Func ScanFolder($SourceFolder)
- Local $Search
- Local $File
- Local $FileAttributes
- Local $FullFilePath
- Local $scanfolderarray[1]
- $Search = FileFindFirstFile($SourceFolder & "\*.*")
- While 1
- If $Search = -1 Then
- ExitLoop
- EndIf
- $File = FileFindNextFile($Search)
- If @error Then ExitLoop
- $FullFilePath = $SourceFolder & "\" & $File
- $FileAttributes = FileGetAttrib($FullFilePath)
- If StringInStr($FileAttributes,"D") Then
- Else
- ;if $sExtension == ".cfg" Then
- ; outputPrint("EXTENSION: "&$sExtension)
- ;Else
- _ArrayInsert($scanfolderarray, 1, $File)
- ;EndIf
- EndIf
- WEnd
- FileClose($Search)
- Return $scanfolderarray
- EndFunc
- Func CopyFolderFiles($OldFolder, $NewFolder)
- Local $files = ScanFolder($OldFolder)
- Local $size = UBound($files)
- If $size > 0 Then
- for $iz = 1 to $size-1
- $f = $NewFolder&"\"&$files[$iz]
- $of = $OldFolder&"\"&$files[$iz]
- Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = ""
- Local $aPathSplit = _PathSplit($of, $sDrive, $sDir, $sFilename, $sExtension)
- if $sExtension == ".cfg" Then
- Else
- If FileExists($f) Then
- outputPrint("Deleting alreadying existing file "&$f)
- FileDelete($f)
- EndIf
- outputPrint("Copying '"&$of&"' to '"&$f&"'")
- FileCopy($of,$f)
- EndIf
- Next
- EndIf
- EndFunc
- Func CopyFolderFiles2($OldFolder, $NewFolder)
- Local $files = ScanFolder($OldFolder)
- Local $size = UBound($files)
- If $size > 0 Then
- for $iz = 1 to $size-1
- $f = $NewFolder&"\"&$files[$iz]
- $of = $OldFolder&"\"&$files[$iz]
- ;Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = ""
- ; Local $aPathSplit = _PathSplit($of, $sDrive, $sDir, $sFilename, $sExtension)
- ;if $sExtension == ".cfg" Then
- ;Else
- If FileExists($f) Then
- outputPrint("Deleting alreadying existing file "&$f)
- FileDelete($f)
- EndIf
- outputPrint("Copying '"&$of&"' to '"&$f&"'")
- FileCopy($of,$f)
- ; EndIf
- Next
- EndIf
- EndFunc
- ;-----------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement