All pastes #921489 Raw Edit

Anonymous

public text v1 · immutable
#921489 ·published 2008-02-28 02:02 UTC
rendered paste body
var grablevel : flexible array 1 .. 1 of string     % each part of the array stores a different part of the map file
var mapPartsArray : array 1 .. 100 of string
var curMapObject : string       % This is the string of the current type of object we are parsing
var blockcounter : int          % This is counting what individual block we are on.
var lngth : int                 % Show the length of the 
var mapfile : int
var curObjectType : int         % This is the type of the object we are parsing. IE: the ground blocks are a "1"


open : mapfile, "levels/1.txt", get

curObjectType := 1

loop    % grabbing the data from the level
    exit when eof (mapfile)
    get : mapfile, grablevel (upper (grablevel))
    new grablevel, upper (grablevel) + 1
    put "Success! Map object #", curObjectType, " was parsed correctly: ".. % let's see if this succedes after each loop
    put grablevel(curObjectType)
    curObjectType := curObjectType + 1
    delay (400)
end loop

delay (1500)

curObjectType := 1
blockcounter := 1

loop        % Let's loop to parse all 5 map objects                                   
    curMapObject := grablevel(curObjectType)            % setting the current type of object we are parsing
    lngth := length (curMapObject)                      % grabbing the length of the 
    put grablevel (curObjectType),  " :: curObjectType"     % print the current map file section we are parsing
    put curMapObject, " :: curMapObject"                    % make sure that the current "block" of code was inserted into it's string properly
    delay (1500)
    loop    % loop until we parse the whole string
        mapPartsArray (blockcounter) := curMapObject (1)    % make the the location in the array specified by 'blockcounter' be equal to the first char of the current "block" of the map file
        delay (100)                                         % slow so we can see what is going on
        put mapPartsArray (blockcounter)                    % make sure things are being parsed correctly
        blockcounter := blockcounter + 1                    % lets add up how many blocks we've inspected
        curMapObject := curMapObject (2 .. lngth)           % shave off the first char of curMapObject. It's been stored in an array, we don't need it anymore
        lngth := length (curMapObject)                      % grab the new length after shaving off the first char
        exit when lngth = 0                                 % exit the loop when we've parsed the whole string
    end loop
    put " "
    curObjectType := curObjectType + 1                      % why not move onto the next map object?
exit when curObjectType = 6                                 % end the loop once we've parsed all the map objects :: must be one higher then the actual # of objects
end loop