Skip to content

Instantly share code, notes, and snippets.

@Softwave
Created June 23, 2014 17:58
Show Gist options
  • Save Softwave/8fb99db9ce7844dddc66 to your computer and use it in GitHub Desktop.
Save Softwave/8fb99db9ce7844dddc66 to your computer and use it in GitHub Desktop.
csvTest.lua
groups = DAME.GetGroups()
groupCount = as3.tolua(groups.length) -1
FileExt = as3.tolua(VALUE_FileExt)
csvDir = as3.tolua(VALUE_CSVDir)
-- Output tilemap data
function exportMapCSV( mapLayer, layerFileName, groupName )
-- get the raw mapdata. To change format, modify the strings passed in (rowPrefix,rowSuffix,columnPrefix,columnSeparator,columnSuffix)
mapText = as3.tolua(DAME.CreateTextForSprites(mapLayer,"%xpos%, %ypos%\n",groupName))
-- DAME.CreateTextForSprites( layer:SpriteLayer, defaultCreationText:String, defaultClass:String, bmpfontText:String = "", baseDirectory:String = null ):String
--print("output to "..as3.tolua(VALUE_CSVDir).."/"..layerFileName)
DAME.WriteFile(csvDir.."/"..layerFileName, mapText );
end
for groupIndex = 0,groupCount do
group = groups[groupIndex]
groupName = as3.tolua(group.name)
groupName = string.gsub(groupName, " ", "_")
layerCount = as3.tolua(group.children.length) - 1
-- Go through each layer and store some tables for the different layer types.
for layerIndex = 0,layerCount do
layer = group.children[layerIndex]
isMap = as3.tolua(layer.map)~=nil
layerSimpleName = as3.tolua(layer.name)
layerSimpleName = string.gsub(layerSimpleName, " ", "_")
if as3.tolua(layer.IsSpriteLayer()) == true then
mapFileName = "mapCSV_"..groupName.."_"..layerSimpleName.."."..FileExt
-- Generate the map file.
exportMapCSV( layer, mapFileName, groupName )
end
end
end
return 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment