Advertisement
Guest User

Untitled

a guest
May 27th, 2015
884
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. ; #Warn  ; Enable warnings to assist with detecting common errors.
  3. SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
  4. SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  5.  
  6. ; Let's read complete.xml and create a godot style xml file out of it named goditcomplete.xml
  7.  
  8. Loop, read, complete.xml, godotcomplete.xml
  9. {
  10.     ; Let's add the file header.
  11.     ; Also, first line is junk so let's skip trying to parse it.
  12.     if A_Index = 1
  13.     {
  14.         fileappend,
  15.         (
  16. <?xml version="1.0" encoding="UTF-8" ?>
  17. <resource_file type="TileSet" subresource_count="4" version="1.1" version_name="Godot Engine v1.1.stable.d3b42e41b0">
  18.     <ext_resource path="res://complete.png" type="Texture"></ext_resource>
  19.     <main_resource>`n
  20.         )
  21.         Continue
  22.     }
  23.    
  24.    
  25.    
  26.     Loop, parse, A_LoopReadLine, %A_Space%
  27.     {
  28.         if A_Index = 2 ; Tile name
  29.         {
  30.             StringTrimLeft, String2, A_LoopField, 6
  31.             StringTrimRight, String3, String2, 5
  32.             TileName := String3
  33.             Continue
  34.         }
  35.         if A_Index = 3 ; Tile X
  36.         {
  37.             StringTrimLeft, String2, A_LoopField, 3
  38.             StringTrimRight, String3, String2, 1
  39.             TileX := String3
  40.             Continue
  41.         }
  42.         if A_Index = 4 ; Tile Y
  43.         {
  44.             StringTrimLeft, String2, A_LoopField, 3
  45.             StringTrimRight, String3, String2, 1
  46.             TileY := String3
  47.             Continue
  48.         }
  49.         if A_Index = 5 ; Tile Width
  50.         {
  51.             StringTrimLeft, String2, A_LoopField, 7
  52.             StringTrimRight, String3, String2, 1
  53.             TileWidth := String3
  54.             TileVectorX := TileWidth / 2.0
  55.             Continue
  56.         }
  57.         If A_Index = 6 ; Tile Height
  58.         {
  59.             StringTrimLeft, String2, A_LoopField, 8
  60.             StringTrimRight, String3, String2, 3
  61.             TileHeight := String3
  62.             TileVectorY := TileHeight / 2.0
  63.             Continue
  64.         }  
  65.        
  66.     }
  67.    
  68.     ResourceNumber := A_Index - 2
  69.    
  70.     ;The filename (in this case complete.png) will need to be changed if I use this again.
  71.     fileappend,
  72.     (
  73.         `t`t<string name="%ResourceNumber%/name"> "%TileName%" </string>
  74.         <resource name="%ResourceNumber%/texture" resource_type="Texture" path="res://complete.png">  </resource>
  75.         <vector2 name="%ResourceNumber%/tex_offset"> 0, 0 </vector2>
  76.         <resource name="%ResourceNumber%/material"></resource>      <rect2 name="%ResourceNumber%/region"> %TileX%, %TileY%, %TileWidth%, %TileHeight% </rect2>
  77.         <vector2 name="%ResourceNumber%/occluder_offset"> %TileVectorX%, %TileVectorY% </vector2>
  78.         <resource name="%ResourceNumber%/occluder"></resource>      <vector2 name="%ResourceNumber%/navigation_offset"> %TileVectorX%, %TileVectorY% </vector2>
  79.         <resource name="%ResourceNumber%/navigation"></resource>        <vector2 name="%ResourceNumber%/shape_offset"> 0, 0 </vector2>
  80.         <array name="%ResourceNumber%/shapes" len="0" shared="false">
  81.         </array>`n
  82.     )
  83. }
  84.  
  85. fileappend,
  86. (
  87.         `t`t</main_resource>
  88.     </resource_file>
  89. ), godotcomplete.xml
  90.    
  91. exit
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement