Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function reckoner(start,tolevel,havelvl)
- local x = start
- local lvl,y = {}
- local havelvl = havelvl or {}
- if 2 <= tolevel*1 then
- y = x%4
- x=(x-y)*3/4
- lvl[1] = y
- if havelvl[2] then
- x=x+havelvl[2]
- end
- end
- if 3 <= tolevel*1 then
- y = x%3
- x=(x-y)*2/3
- lvl[2] = y
- if havelvl[3] then
- x=x+havelvl[3]
- end
- end
- if 4 <= tolevel*1 then
- y = x%3
- x=(x-y)*2/3
- lvl[3] = y
- if havelvl[4] then
- x=x+havelvl[4]
- end
- end
- if 5 <= tolevel*1 then
- y = x%3
- x=(x-y)*2/3
- lvl[4] = y
- if havelvl[5] then
- x=x+havelvl[5]
- end
- end
- if 6 <= tolevel*1 then
- y = x%2
- x=(x-y)*1/2
- lvl[5] = y
- if havelvl[6] then
- x=x+havelvl[6]
- end
- end
- echo("SHIP TRADE RECKONER!\n")
- echo(x.." final product at level ".. (tolevel*1>6 and 6 or tolevel))
- echo("\nRemainders:\n")
- local remainder = false
- for i=1,5 do
- if lvl[i] ~= 0 then
- echo(lvl[i] .." level ".. i .." items left.\n")
- remainder = true
- end
- end
- if not remainder then echo("NONE!") end
- end
- --Example:
- reckoner(60,5,{[4]=1,[5]=3})
- --[[
- Translation: Starting with 60 level 1 items, going to level 5 item. Already have one level 4 item, and 3 level 5 items.
- shows:
- SHIP TRADE RECKONER!
- 17 final product at level 5
- Remainders:
- NONE!
- Item levels:
- Lvl 1 Lvl 4
- Wool Incense
- Fur Porcelain
- Grain Silk
- Ore Wine
- Salt
- Sandstone
- Cotton
- Lvl 2 Lvl 5
- Sugar Perfume
- Fruits Tabac
- Honey Armaments
- Granite
- Terracotta
- Hemp
- Lvl 3 Lvl 6
- Kawhe Gems
- Glass Spices
- Ceramics
- Marble
- Tea
Add Comment
Please, Sign In to add comment