[ create a new paste ] login | about

Link: http://codepad.org/plYhHtTd    [ raw code | output | fork ]

Lua, pasted on Oct 13:
-- 2 arrays with the title and code of each predefined reviewer field to be used.
local reviewer_code = {'1UP', 'Atrip', 'AdvGamers', 'Allgame', 'CVG', 'Edge', 'EGM', 'EuroG', 'Fam', 'G4', 'GCritics', 'GI', 'GameFan', 'GamePro', 'GRadar', 'GMaster', 'GameRev', 'GSpot', 'GSpy', 'GTM', 'GT', 'GW', 'GameZone', 'Hyper', 'IGN', 'JOY', 'MaxPC', 'N64Mag', 'NG', 'NGCMag', 'NP', 'NWR', 'ONM', 'OPM', 'OPMUK', 'OPMAU', 'OXM', 'OXMUK', 'PCGUK', 'PCGUS', 'PCZone', 'Play', 'PSM', 'PSM3', 'RPG', 'TX', 'VG', 'XPlay'}
local reviewer_name = {'[[1UP.com]]', '[[ActionTrip]]', '[[Adventure Gamers]]', '[[Allgame]]', '[[Computer and Video Games]]', '[[Edge (magazine)|Edge]]', '[[Electronic Gaming Monthly]]', '[[Eurogamer]]', '[[Famitsu]]', '[[G4 (TV channel)|G4]]', 'GameCritics', '[[Game Informer]]', '[[GameFan|GameFan Magazine]]', '[[GamePro]]', '[[GamesRadar]]', '[[GamesMaster]]', '[[Game Revolution]]', '[[GameSpot]]', '[[GameSpy]]', '[[gamesTM]]', '[[GameTrailers]]', 'GameWire', '[[GameZone]]', '[[Hyper (magazine)|Hyper Magazine]]', '[[IGN]]', '[[Joystiq]]', '[[Maximum PC]]', '[[N64 Magazine]]', '[[NGamer]]', '[[NGC Magazine]]', '[[Nintendo Power]]', 'Nintendo World Report', '[[Official Nintendo Magazine]]', '[[Official U.S. PlayStation Magazine|Official PlayStation Magazine (US)]]', '[[PlayStation Official Magazine (UK)|Official PlayStation Magazine (UK)]]', '[[Official PlayStation Magazine (Australia)]]', '[[Official Xbox Magazine]]', '[[Official Xbox Magazine|Official Xbox Magazine UK]]', '[[PC Gamer|PC Gamer UK]]', '[[PC Gamer|PC Gamer US]]', '[[PC Zone]]', '[[Play (UK magazine)|Play Magazine]]', '[[PlayStation: The Official Magazine|PlayStation Magazine]]', '[[PSM3|PlayStation 3 Magazine]]', '[[RPGamer]]', '[[TeamXbox]]', '[[VideoGamer.com]]', '[[X-Play]]'}
local system_code = {'A2600', 'CV', 'DS', 'GB', 'GBA', 'GBC', 'iOS', 'N-G', 'N64', 'NES', 'NGC', 'PC', 'PS', 'PS2', 'PS3', 'PSP', 'SDC', 'SGG', 'SNES', 'SMD', 'SMS', 'SSAT', 'TG16', 'XBOX', 'X360', 'WII'}
keys = {'pc', 'hello', '1UP_XBOX', '1UP_WII', '1UP_DS', 'Atrip_XBOX'}

output = {}

function Split(str, delim, maxNb)
    if string.find(str, delim) == nil then
        return { str }
    end
    if maxNb == nil or maxNb < 1 then
        maxNb = 0 -- No limit
    end
    local result = {}
    local pat = "(.-)" .. delim .. "()"
    local nb = 0
    local lastPos
    for part, pos in string.gfind(str, pat) do
        nb = nb + 1
        result[nb] = part
        lastPos = pos
        if nb == maxNb then break end
    end
    if nb ~= maxNb then
        result[nb + 1] = string.sub(str, lastPos)
    end
    return result
end

--
-- Review count and output for reviewers only
--
    local k = 1
    for i = 1, #keys do
        if string.find(tostring(keys[i]), '_') then
            key = Split(tostring(keys[i]), '_')
            for j = 1, #reviewer_code do
                if key[1] == reviewer_code[j] and key[1] ~= '' then
                    output[k] = {}
                    output[k][2] = {}
                        if output[j][1] == reviewer_code[j] then
                            print("i=",i,"l=",l,"-if",output[j][1],"==",reviewer_code[j],"key",key[2]);
                            output[j][2][#output[j][2]+1] = key[2]
                        else
                            print("i=",i,"l=",l,"--if",reviewer_code[j],"==",output[j][1],"key",key[2])
                            output[j][1] = reviewer_code[j]
                            output[j][2][1] = key[2]
                            k = k + 1
                        end
                end
            end
        end
    end

for i = 1, #output do
    local j = 1
    while j <= #reviewer_code do
        if output[i][1] == reviewer_code[j] then
            print(reviewer_name[j])
            j = #reviewer_code + 1
        end
        j = j + 1
    end
    for p = 1, #output[i][2] do
        for m = 1, #system_code do
            if output[i][2][p] == system_code[m] then
                print(output[i][1] .. '_' .. output[i][2][p])
            end
        end
    end
end


Output:
1
2
3
4
5
6
7
8
9
10
i=	3	l=	nil	--if	1UP	==	nil	key	XBOX
i=	4	l=	nil	-if	1UP	==	1UP	key	WII
i=	5	l=	nil	-if	1UP	==	1UP	key	DS
i=	6	l=	nil	--if	Atrip	==	nil	key	XBOX
[[1UP.com]]
1UP_XBOX
1UP_WII
1UP_DS
[[ActionTrip]]
Atrip_XBOX


Create a new paste based on this one


Comments: