Ok so I'm building a Text-based adventure in lua... If anyone thinks that is a bad idea well I am the master of bad ideas but the question is about the level up function... So here it is
function lvl()
if xp >= xpr then
level = level + 1
xpr = xpr * 1.5
xp = 0
io.write("Congrats! Somehow you didn't die and lose everything!", "\n")
io.write("Your level is now:" .. level .. "\n")
sp = sp + 6
io.write("Do you want to allocate your " .. sp .. " skill points?", "\n")
sac = io.read()
if sac == "yes" then
io.write("How much do you want to put into strength?", "\n")
strsp = io.read()
if sp == 0 then
io.write("You don't have any skill points!", "\n")
else
str = str + strsp
io.write("Strength: ", str, "\n")
end
io.write("How much do you want to put into dexterity?", "\n")
dexsp = io.read()
if sp == 0 then
io.write("You don't have any skill points!", "\n")
else
dex = dex + dexsp
io.write("Dexterity: ", dex, "\n")
end
io.write("How much do you want to put into constitution?", "\n")
consp = io.read()
if sp == 0 then
io.write("You don't have any skill points!", "\n")
else
con = con + consp
io.write("Constitution: ", str, "\n")
end
io.write("How much do you want to put into intelligence?", "\n")
intsp = io.read()
if sp <= 0 then
io.write("You don't have any skill points!", "\n")
else
int = int + intsp
end
io.write("How much do you want to put into wisdom?", "\n")
wissp = io.read()
if sp <= 0 then
io.write("You don't have any skill points!", "\n")
else
wis = wis + wissp
end
io.write("How much do you want to put into charisma", "\n")
chasp = io.read()
if sp <= 0 then
io.write("You don't have any skill points!", "\n")
else
cha = cha + chasp
end
elseif xp < xpr then
io.write("You didn't level up!", "\n")
end
end
and the problem lies within the skill allocation system. I cannot figure out how to limit the amount of skill points you spend... Thank you in advance!
PS: I'm very new to lua.