local sub = string.sub local find = string.find local fileName = "mappieces.dat" local firstLevel = 'file_example.fpm' g_mapPieceValues = g_mapPieceValues or "FFFFFFFFFF" -- ten values local fileRead = false local levelName = nil local function saveValues() local file = io.open( "scriptbank\\" .. fileName, "w+" ) io.output( file ) if file ~= nil then io.write( levelName, "\n" ) io.write( g_mapPieceValues, "\n" ) end io.close( file ) end function fe_setPiece( num ) local str = g_mapPieceValues if num == 1 then g_mapPieceValues = 'T' .. sub( str, 2, #str ) elseif num == #str then g_mapPieceValues = sub( str, 1, num - 1 ) .. 'T' elseif num < #str then g_mapPieceValues = sub( str, 1, num - 1 ) .. 'T' .. sub( str, num + 1, #str ) end saveValues() end function fe_gotPiece( num ) return sub( g_mapPieceValues, num, num ) == 'T' end function file_example_init( e ) end local function getLevelName( str ) local spos = 1 local epos = 0 while epos < #str do epos = find( str, '\\', spos + 1 ) or #str if epos < #str then spos = epos + 1 end end return sub( str, spos, epos ) end function file_example_main( e ) if not fileRead then local thisLevel = getLevelName( g_LevelFilename ) local fl = firstLevel if strLevelFilename ~= nil then local strLevel = getLevelName( strLevelFilename ) if strLevel == thisLevel then fl = strLevel end end if thisLevel ~= fl then local file = io.open( "scriptbank\\" .. fileName, "r") if file ~= nil then local level = file:read() if thisLevel ~= level then g_mapPieceValues = file:read() end io.close( file ) end end fileRead = true levelName = thisLevel end local pieces = "" local allFound = true for i = 1, #g_mapPieceValues do if fe_gotPiece( i ) then pieces = pieces .. i .. " " else allFound = false end end if allFound then Prompt( "All Found" ) else Prompt( pieces ) end end