unlockables = { {stone = 50, type = 'buff', prototype = {name = 'mining_speed', value = 10}}, {stone = 50, type = 'buff', prototype = {name = 'inventory_slot', value = 3}}, {stone = 50, type = 'market', prototype = {price = 50, name = 'raw-fish'}}, {stone = 50, type = 'market', prototype = {price = 175, name = 'steel-axe'}}, {stone = 250, type = 'buff', prototype = {name = 'mining_speed', value = 5}}, {stone = 250, type = 'buff', prototype = {name = 'inventory_slot', value = 2}}, {stone = 250, type = 'market', prototype = {price = 50, name = 'small-electric-pole'}}, {stone = 250, type = 'market', prototype = {price = 50, name = 'small-lamp'}}, {stone = 250, type = 'market', prototype = {price = 25, name = 'stone-brick'}}, {stone = 250, type = 'market', prototype = {price = 125, name = 'stone-wall'}}, {stone = 450, type = 'buff', prototype = {name = 'mining_speed', value = 5}}, {stone = 450, type = 'buff', prototype = {name = 'inventory_slot', value = 2}}, {stone = 450, type = 'market', prototype = {price = 850, name = 'submachine-gun'}}, {stone = 450, type = 'market', prototype = {price = 50, name = 'firearm-magazine'}}, {stone = 450, type = 'market', prototype = {price = 500, name = 'light-armor'}}, {stone = 750, type = 'buff', prototype = {name = 'mining_speed', value = 5}}, {stone = 750, type = 'buff', prototype = {name = 'inventory_slot', value = 1}}, {stone = 1250, type = 'buff', prototype = {name = 'mining_speed', value = 5}}, {stone = 1250, type = 'buff', prototype = {name = 'inventory_slot', value = 1}}, {stone = 1750, type = 'buff', prototype = {name = 'mining_speed', value = 5}}, {stone = 1750, type = 'buff', prototype = {name = 'inventory_slot', value = 1}}, {stone = 2500, type = 'buff', prototype = {name = 'mining_speed', value = 5}}, {stone = 2500, type = 'buff', prototype = {name = 'inventory_slot', value = 1}}, {stone = 4000, type = 'buff', prototype = {name = 'mining_speed', value = 5}}, {stone = 4000, type = 'buff', prototype = {name = 'inventory_slot', value = 1}}, {stone = 6500, type = 'buff', prototype = {name = 'mining_speed', value = 5}}, {stone = 6500, type = 'buff', prototype = {name = 'inventory_slot', value = 1}}, {stone = 8000, type = 'buff', prototype = {name = 'mining_speed', value = 5}}, {stone = 8000, type = 'buff', prototype = {name = 'inventory_slot', value = 1}}, {stone = 10000, type = 'buff', prototype = {name = 'mining_speed', value = 5}}, {stone = 10000, type = 'buff', prototype = {name = 'inventory_slot', value = 1}}, {stone = 10000, type = 'market', prototype = {price = 750, name = 'heavy-armor'}}, {stone = 15000, type = 'buff', prototype = {name = 'mining_speed', value = 2}}, {stone = 15000, type = 'buff', prototype = {name = 'inventory_slot', value = 1}}, {stone = 25000, type = 'buff', prototype = {name = 'mining_speed', value = 2}}, {stone = 25000, type = 'buff', prototype = {name = 'inventory_slot', value = 1}}, {stone = 35000, type = 'buff', prototype = {name = 'mining_speed', value = 2}}, {stone = 35000, type = 'buff', prototype = {name = 'inventory_slot', value = 1}}, {stone = 35000, type = 'market', prototype = {price = 100, name = 'piercing-rounds-magazine'}}, {stone = 35000, type = 'market', prototype = {price = 1500, name = 'modular-armor'}}, {stone = 50000, type = 'buff', prototype = {name = 'mining_speed', value = 2}}, {stone = 50000, type = 'buff', prototype = {name = 'inventory_slot', value = 1}}, {stone = 75000, type = 'buff', prototype = {name = 'mining_speed', value = 2}}, {stone = 75000, type = 'buff', prototype = {name = 'inventory_slot', value = 1}}, {stone = 100000, type = 'buff', prototype = {name = 'mining_speed', value = 2}}, {stone = 100000, type = 'buff', prototype = {name = 'inventory_slot', value = 1}}, {stone = 125000, type = 'buff', prototype = {name = 'mining_speed', value = 2}}, {stone = 150000, type = 'buff', prototype = {name = 'mining_speed', value = 2}}, {stone = 175000, type = 'buff', prototype = {name = 'mining_speed', value = 2}}, {stone = 200000, type = 'buff', prototype = {name = 'mining_speed', value = 2}}, {stone = 225000, type = 'buff', prototype = {name = 'mining_speed', value = 2}}, {stone = 250000, type = 'buff', prototype = {name = 'mining_speed', value = 2}}, {stone = 275000, type = 'buff', prototype = {name = 'mining_speed', value = 2}}, {stone = 300000, type = 'buff', prototype = {name = 'mining_speed', value = 2}}, {stone = 350000, type = 'buff', prototype = {name = 'mining_speed', value = 2}}, {stone = 400000, type = 'buff', prototype = {name = 'mining_speed', value = 2}}, {stone = 500000, type = 'buff', prototype = {name = 'mining_speed', value = 2}}, } function print_r(arr, indentLevel) local str = "" local indentStr = "#" if(indentLevel == nil) then print(print_r(arr, 0)) return end for i = 0, indentLevel do indentStr = indentStr.."\t" end for index,value in pairs(arr) do if type(value) == "table" then str = str..indentStr..index..": \n"..print_r(value, (indentLevel + 1)) else str = str..indentStr..index..": "..value.."\n" end end return str end function test(unlocks, stone, type) local result = {} for _, data in pairs(unlocks) do if data.stone == stone and data.type == type then table.insert(result, data) end end return result end local function set_fields(tab, fields, val) -- fields is an array of field names -- (use empty string to skip value at corresponging position) --local values = {...} for k, field in ipairs(fields) do if field ~= "" then tab[field] = val[k] end end return tab end local function get_fields(tab, fields) local values = {} for k, field in ipairs(fields) do values[k] = tab[field] end return (table.unpack or unpack)(values, 1, #fields) end local sortedUnlockables = {} local lastStone = 0 -- define lastStone with first stone value to start on correct position local lastType = '' --unlockables[1].type local buffs = {} local items = {} local nbrRows = 0 local myUnlockables = {} local row = {} for _, data in pairs(unlockables) do table.insert(myUnlockables, data) end for i = 1, #myUnlockables do if myUnlockables[i].stone ~= lastStone then -- get items and buffs for each stone value buffs = test(myUnlockables, myUnlockables[i].stone, 'buff') items = test(myUnlockables, myUnlockables[i].stone, 'market') -- get number of rows if #buffs < #items then nbrRows = #items else nbrRows = #buffs end --[[ print('stone : ' .. myUnlockables[i].stone) print('nbrRows: ' .. nbrRows) print('----------------') ]] -- loop through buffs and items for number of rows for j = 1, nbrRows do --print('j : ' .. j) local result = {} if buffs[j] ~= nil then --print(buffs[j].stone) result[1] = buffs[j].stone else --print(items[j].stone) result[1] = items[j].stone end if buffs[j] ~= nil then result[2] = '+ '.. buffs[j].prototype.value .. '% ' .. buffs[j].prototype.name else result[2] = '' end if items[j] ~= nil then result[3] = '+ '.. items[j].prototype.name else result[3] = '' end table.insert(row, result) end end --print('i : ' .. i) -- save lastStone lastStone = myUnlockables[i].stone end for i = 1, #row do --print('stone: ' .. myUnlockables[i][1]) --print('type : ' .. myUnlockables[i][2]) --print('----------------') end print_r(row) --[[] local suppe = {'eins', 'zwei', 'vier', 'funf', 'sex'} table.insert(suppe, 3, 'drei') for i = 1, #suppe do print('i : ' ..i) print('suppe : ' .. suppe[i]) end ]] -- sort the unlocks table --[[ local sortedUnlockables = set_fields({}, { 1, 3, 2, 4, -- 50 stone 5, 7, 6, 8, 9, 10, -- 250 11, 13, 12, 14, 15, -- 450 16, 17, -- 750 18, 19, -- 1.250 20, 21, -- 1.750 22, 23, -- 2.500 24, 25, -- 4.000 26, 27, -- 6.500 28, 29, -- 8.000 30, 32, 31, -- 10.000 33, 34, -- 15.000 35, 36, -- 25.000 37, 39, 38, 40, -- 35.000 41, 42, -- 50.000 43, 44, -- 75.000 45, 46, -- 100.000 47, -- 125.000 48, -- 150.000 49, -- 175.000 50, -- 200.000 51, -- 225.000 52, -- 250.000 53, -- 275.000 54, -- 300.000 55, -- 350.000 56, -- 400.000 57 -- 500.000 }, unlockables)]] local sortedUnlockables = set_fields({}, { 2, 5, 3, 6, -- 50 stone 8, 11, 9, 12, 15, 18, -- 250 20, 23, 21, 24, 27, -- 450 29, 32, -- 750 35, 38, -- 1.250 41, 44, -- 1.750 47, 50, -- 2.500 53, 56, -- 4.000 59, 62, -- 6.500 65, 68, -- 8.000 71, 74, 72, -- 10.000 77, 80, -- 15.000 83, 86, -- 25.000 89, 92, 90, 93, -- 35.000 95, 98, -- 50.000 101, 104, -- 75.000 107, 110, -- 100.000 113, -- 125.000 116, -- 150.000 119, -- 175.000 122, -- 200.000 125, -- 225.000 128, -- 250.000 131, -- 275.000 134, -- 300.000 137, -- 350.000 140, -- 400.000 143 -- 500.000 }, unlockables) for i = 1, 48 do -- every row if sortedUnlockables[(i*3) - 2] == nil then if sortedUnlockables[(i*3) - 1] == nil then --print('stone : ' .. sortedUnlockables[(i*3)].stone) else --print('stone : ' .. sortedUnlockables[(i*3)-1].stone) end end if sortedUnlockables[(i*3) - 1] ~= nil then --print('buff : i = ' .. (i*3) - 1) else --print('empty buff! i = ' .. (i*3) - 1) end if sortedUnlockables[(i*3)] ~= nil then --print('item : i = ' .. (i*3)) else --print('empty item! i = ' .. (i*3)) end end for i = 1, #sortedUnlockables do if not sortedUnlockables[i] then --print(sortedUnlockables[i+1].stone) else --print(sortedUnlockables[i].stone) --print(sortedUnlockables[i].type) --print('---------') end end
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more