This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Cing's profile picture

From liquid exp to levels [Solved]

Started by Cing, 25 September 2015 - 09:45 PM
Cing #1
Posted 25 September 2015 - 11:45 PM
Hi everyone,

I am want to make a program that can calculate the level from the amount of exp i got.
If have search for hours to a formula but i couldn't find it.

Does anybody know if there is a standard formula or know's a other way to calculate the level.

Thanks in regards
Edited on 27 September 2015 - 08:57 AM
Lupus590 #2
Posted 26 September 2015 - 12:07 AM
http://minecraft.gamepedia.com/Experience#Leveling_up
Cing #3
Posted 26 September 2015 - 02:24 PM
Thank for the tip but those formulas are from level to exp i need from exp to level.
I am not the good at math does anybody know how to reverse them?
Lupus590 #4
Posted 26 September 2015 - 02:38 PM

Look up the exp value in your tank against the table (exp column) and compare with the level column.

The 'exp from last' column is useless to you.

I would put all the values into a lookup table and have my program use that. I'd put the level in the index of the table with the exp as the value of that index, the program would crawl through the table until it finds an index with a exp value more than the amount of exp in the container. The amount of levels in the container are then equal to the index of the table that I stopped at minus one.


local levelToExpLookupTable = {7,16,27,} --#you will have to fill the rest of the table
local function getLevelFromExp(exp)
  local currentIndex = 1
  while levelToExpLookupTable[currentIndex] <= exp do
	currentIndex = currentIndex + 1
  end
  return currentIndex - 1
end
Edited on 26 September 2015 - 12:50 PM
TYKUHN2 #5
Posted 26 September 2015 - 02:39 PM
2[Current Level] + 7
5[Current Level] - 38
9[Current Level] - 158


Copied from the page linked above
Lupus590 #6
Posted 26 September 2015 - 03:04 PM
2[Current Level] + 7
5[Current Level] - 38
9[Current Level] - 158


Copied from the page linked above

Those are converting level to experience, the OP wants the reverse, which will be difficult to get out of those equations. (The fact that there are 3 equations for different level ranges - the computer will have to check if the value from the result is outside of the equation's range, and then use the next equation if it's too high, then check that range, and then use the third for higher ranges.)

We should probably check which will be quicker for the computer, using the three equations or using a lookup table.

(It should be noted that if you where converting from level to exp, you will know which equation to use by looking at the ranges.)
Edited on 26 September 2015 - 01:07 PM
Cing #7
Posted 26 September 2015 - 03:28 PM
i gone need the table to be to level 200 and on the site is only till 40

is there a way to conveted this equation?: Total Experience = 4.5[Level]2 - 162.5[Level] + 2220
Edited on 26 September 2015 - 01:30 PM
Anavrins #8
Posted 26 September 2015 - 04:28 PM
No need for a lookup table, here's the EXP obelisk code ported from EnderIO to CCLua, http://pastebin.com/diztepge

local liquidXP = tank.getTankInfo()[1]
local exp = xpApi.liquidToExperience(tank.content.amount)
local lvl = xpApi.getLevelForExperience(exp)
Edited on 26 September 2015 - 02:29 PM
Cing #9
Posted 26 September 2015 - 09:00 PM
How do you now i use the exp obelisk??? MIND BLOWN

But really thanks this is exactly what i need
Anavrins #10
Posted 26 September 2015 - 09:39 PM
Well, you were talking about liquid XP in general, and I knew the obelisk has code to do that since the GUI shows how many levels there is in the tank.