Permalink
Browse files

Added config file - No menu when starting script now

  • Loading branch information...
1 parent ceb6318 commit 4b340d7fbb1f3769a7c7a52771da18be9f436ae6 @rejcx rejcx committed Dec 5, 2012
Showing with 21 additions and 63 deletions.
  1. +1 −1 README.md
  2. +11 −9 converter.lua
  3. +9 −53 main.lua
View
@@ -21,7 +21,7 @@ To get all of the features of the map converter, you need to do a few things wit
And of course, export your tmx map files as .lua files
-** View changes to the map spec at: https://github.com/Moosader/tools/wiki/Version-Changes **
+** View changes to the map spec at: https://github.com/Moosader/Tiled-Lua-to-Moo-Map-Converter/wiki/Version-Changes **
## Using the Converter
Put your map file in the Input/ folder, then run:
View
@@ -1,18 +1,20 @@
--- Map conversion tool
+-- Tiled Lua to Moo Map Converter
-- Rachel J. Morris, moosader.com / github.com/moosader
-- zlib license
+require "config"
+
tileList = {}
function ConvertMap( options )
- print( "\nOpening Lua map \"" .. options["infile"] .. "\"..." )
- luaMap = require( options["infile"] )
+ print( "\nOpening Lua map \"" .. config["files"]["input"] .. "\"..." )
+ luaMap = require( config["files"]["input"] )
print( "Converting map to tile list..." )
- CreateTileList( luaMap, options["unit"] )
+ CreateTileList( luaMap, config["map"]["unit"] )
- print( "Saving map file as \"" .. options["outfile"] .. "\"..." )
- tileCount = SaveMap( options, luaMap )
+ print( "Saving map file as \"" .. config["files"]["output"] .. config["files"]["extention"] .. "\"..." )
+ tileCount = SaveMap( luaMap )
print( "Converted a total of " .. tileCount .. " tiles\n" )
end
@@ -76,10 +78,10 @@ function CreateTileList( map, unitType )
end
end
-function SaveMap( options, map )
- local file = io.open( options["outfile"], "w" )
+function SaveMap( map )
+ local file = io.open( config["files"]["output"] .. config["files"]["extention"], "w" )
- file:write( "# Converted with LuaMapConverter, version " .. options["versionNumber"] )
+ file:write( "# Converted with LuaMapConverter, version " .. config["software"]["version"] )
file:write( "\n# https://github.com/Moosader/tools/tree/master/LuaMapConverter" )
file:write( "\n\ntileset" .. DynamicTab( "tileset" ) .. map["tilesets"][1]["image"] )
View
@@ -1,62 +1,18 @@
--- Map conversion tool
+-- Tiled Lua to Moo Map Converter
-- Rachel J. Morris, moosader.com / github.com/moosader
-- zlib license
require "converter"
+require "config"
-options = {}
-optionsOK = false
--- Map converter version number
-options["versionNumber"] = "2012-12-05"
+print( "########################################" )
+print( config["software"]["name"] )
+print( "Version " .. config["software"]["version"] )
+print( "By Rachel J. Morris / Moosader" )
+print( "########################################" )
+print( "Please set up \"config.lua\" if you have not already!" )
-while ( optionsOK == false ) do
- print( "########################################" )
- print( "Tiled Lua Map to Custom Format converter" )
- print( "Version " .. options["versionNumber"] )
- print( "By Rachel J. Morris / Moosader" )
- print( "########################################" )
- print( "\nOPTION SETUP:" )
-
- print( "\n# UNITS #################" )
- print( "#########################" )
- print( "Would you like coordinates based on [P]ixels, or [T]iles?" )
- print( "Example: Pixels: 0, 32, 64, ...\tTiles: 0, 1, 2, ..." )
- print( "ENTER for default: Pixels" )
- choice = io.read( "*line" )
- if ( choice == "T" or choice == "t" ) then
- options["unit"] = "tiles"
- else
- options["unit"] = "pixels"
- end
-
- print( "\n# ORIGINAL MAP ##########" )
- print( "#########################" )
- print( "What is the Lua map file you want to load?" )
- print( "Example: MyMap" )
- print( "** DO NOT INCLUDE \".lua\" IN NAME!" )
- print( "ENTER for default: \"map\" in the Input folder" )
- options["infile"] = io.read( "*line" )
- if ( options["infile"] == "" ) then options["infile"] = "map" end
- options["outfile"] = "Output/" .. options["infile"] .. ".moo"
- options["infile"] = "Input/" .. options["infile"]
-
- print( "\n# VERIFY OPTIONS ########" )
- print( "#########################" )
- print( "Units: " .. options["unit"] )
- print( "Infile: " .. options["infile"] .. ".lua" )
- print( "Outfile: " .. options["outfile"] )
- print( "\nIs this OK? (y/n) or ENTER for yes" )
- choice = io.read( "*line" )
-
- if ( choice == "N" or choice == "n" ) then
- optionsOK = false
- else
- optionsOK = true
- end
-end
-
--- map file, output filename
-ConvertMap( options )
+ConvertMap()

0 comments on commit 4b340d7

Please sign in to comment.