Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- ; Let's read complete.xml and create a godot style xml file out of it named goditcomplete.xml
- Loop, read, complete.xml, godotcomplete.xml
- {
- ; Let's add the file header.
- ; Also, first line is junk so let's skip trying to parse it.
- if A_Index = 1
- {
- fileappend,
- (
- <?xml version="1.0" encoding="UTF-8" ?>
- <resource_file type="TileSet" subresource_count="4" version="1.1" version_name="Godot Engine v1.1.stable.d3b42e41b0">
- <ext_resource path="res://complete.png" type="Texture"></ext_resource>
- <main_resource>`n
- )
- Continue
- }
- Loop, parse, A_LoopReadLine, %A_Space%
- {
- if A_Index = 2 ; Tile name
- {
- StringTrimLeft, String2, A_LoopField, 6
- StringTrimRight, String3, String2, 5
- TileName := String3
- Continue
- }
- if A_Index = 3 ; Tile X
- {
- StringTrimLeft, String2, A_LoopField, 3
- StringTrimRight, String3, String2, 1
- TileX := String3
- Continue
- }
- if A_Index = 4 ; Tile Y
- {
- StringTrimLeft, String2, A_LoopField, 3
- StringTrimRight, String3, String2, 1
- TileY := String3
- Continue
- }
- if A_Index = 5 ; Tile Width
- {
- StringTrimLeft, String2, A_LoopField, 7
- StringTrimRight, String3, String2, 1
- TileWidth := String3
- TileVectorX := TileWidth / 2.0
- Continue
- }
- If A_Index = 6 ; Tile Height
- {
- StringTrimLeft, String2, A_LoopField, 8
- StringTrimRight, String3, String2, 3
- TileHeight := String3
- TileVectorY := TileHeight / 2.0
- Continue
- }
- }
- ResourceNumber := A_Index - 2
- ;The filename (in this case complete.png) will need to be changed if I use this again.
- fileappend,
- (
- `t`t<string name="%ResourceNumber%/name"> "%TileName%" </string>
- <resource name="%ResourceNumber%/texture" resource_type="Texture" path="res://complete.png"> </resource>
- <vector2 name="%ResourceNumber%/tex_offset"> 0, 0 </vector2>
- <resource name="%ResourceNumber%/material"></resource> <rect2 name="%ResourceNumber%/region"> %TileX%, %TileY%, %TileWidth%, %TileHeight% </rect2>
- <vector2 name="%ResourceNumber%/occluder_offset"> %TileVectorX%, %TileVectorY% </vector2>
- <resource name="%ResourceNumber%/occluder"></resource> <vector2 name="%ResourceNumber%/navigation_offset"> %TileVectorX%, %TileVectorY% </vector2>
- <resource name="%ResourceNumber%/navigation"></resource> <vector2 name="%ResourceNumber%/shape_offset"> 0, 0 </vector2>
- <array name="%ResourceNumber%/shapes" len="0" shared="false">
- </array>`n
- )
- }
- fileappend,
- (
- `t`t</main_resource>
- </resource_file>
- ), godotcomplete.xml
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement