Created
February 12, 2020 18:11
-
-
Save Achie72/50b84716ee33a3e76577acad7e72d5fd to your computer and use it in GitHub Desktop.
Pico-8 map string decoder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parseMap(_mapString) | |
local mapString = _mapString | |
local actualMap = {} | |
while #mapString > 0 do | |
local firstToken=sub(mapString,1,1) | |
local cut = 2 | |
if (firstToken!=",") then | |
local workString = sub(mapString,2) | |
local secondToken = sub(workString,1,1) | |
if (secondToken!=",") then | |
local workString = sub(mapString,3) | |
local thirdToken = sub(workString,1,1) | |
if (thirdToken!=",") then | |
local actualToken = firstToken..secondToken..thirdToken | |
add(actualMap,actualToken) | |
cut = 4 | |
else | |
local actualToken = firstToken..secondToken | |
add(actualMap,actualToken) | |
cut = 3 | |
end | |
else | |
add(actualMap,firstToken) | |
cut = 2 | |
end | |
end | |
mapString=sub(mapString,cut) | |
end | |
return actualMap | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment