|
| 15 Sep 2013 02:16 PM |
Basically, it's a leveling system which checks what level you are and then checks if you meet the XP requirement to level up. If you do, it levels up. How would I do this in a more efficient way? I think I could use for i = 1.100 do
but I'm not sure how to do that.
function level() xp = script.Parent.AlchemyXP.Value level = script.Parent.Value if level == 1 then if xp >= 10 then levelup() end elseif level == 2 then if xp >= 17 then levelup() end elseif level == 3 then if xp >= 29 then levelup() end elseif level == 4 then if xp >= 49 then levelup() end elseif level == 5 then if xp >= 84 then levelup() end elseif level == 6 then if xp >= 142 then levelup() end elseif level == 7 then if xp >= 241 then levelup() end elseif level == 8 then if xp >= 410 then levelup() end elseif level == 9 then if xp >= 698 then levelup() end elseif level == 10 then if xp>= 1186 then levelup() end end end |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2013 02:19 PM |
| Make a formula for all that. |
|
|
| Report Abuse |
|
|
Simtrax
|
  |
| Joined: 11 Sep 2013 |
| Total Posts: 6 |
|
|
| 15 Sep 2013 02:21 PM |
It would invole some math skills.
Here a basic flow chart.
if xp >= current level * 200 then levelup()
end
That is just how it would be done. |
|
|
| Report Abuse |
|
|
Simtrax
|
  |
| Joined: 11 Sep 2013 |
| Total Posts: 6 |
|
| |
|
|
| 15 Sep 2013 02:24 PM |
| @Sim, yeah, I have something similar to that already, but how would I use a for i= blah blah so it's easier to do. |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2013 02:46 PM |
Something like
function levelup() left = left * 1.7 --It multiplies by 1.7 every time you level up --leveling up stuff end
function leveltest() xp = script.Parent.AlchemyXP.Value level = script.Parent.Value left = script.Parent.XPRequire.Value for i=1,100 do if level == i then --For the firs time, it would be 1 if xp >= left then levelup() end end end end |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2013 02:47 PM |
| plz dont use for loop for something like this |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
| |
|
|
| 15 Sep 2013 02:50 PM |
| Excuse you, I was giving my advice. What are you exactly doing in this thread? I don't see any helpful comments from you. Hypocrite. |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2013 02:52 PM |
| @Screw, don't expect manners from a VAK of any sort. |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2013 02:54 PM |
I'm not sure how I'd convert this
if xp >= current level * 200 then levelup()
Into something I can use. xp is the amount of XP they have before they level up. For example, they can have 600 Xp and they need 1000 to level up. And once they reach 1000, it resets to 0.
level explains itself
I added another thing,
left is how much xp you need to level up. For example, when xp == left then level = level + 1 |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2013 03:05 PM |
"xp is the amount of XP they have before they level up"
So as they gain more exp, xp decreases? |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2013 03:11 PM |
exp.Changed:connect(function() if exp > ( lvl ^2 ) *10 then lvl = lvl + 1 end end)
this will give an increment on the exp required between each level
you can print the difference like so
for 1st 100 levels
for i = 1,100,1 do print(((lvl^2)*10) - (((lvl-1)^2)*10)) wait(0.1) end
if you print the level boundaries you can change the equation to match your needs |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 15 Sep 2013 04:22 PM |
Kill, i find that idiotic of you to say.
I told him to get out because he can't just come to a thread and tell the OP to make a formula for it. Pfft. Thats just like answering make a script if someone asked how to script. Idiotic answer. |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 15 Sep 2013 04:23 PM |
| Now stop being a judging hypocrit. |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 15 Sep 2013 04:23 PM |
| hypocrite* and i wasn't the one being hypocrital. |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2013 04:23 PM |
exp.Changed:connect(function() if exp > ( lvl ^2 ) *10 then lvl = lvl + 1 end end)
Doesn't this just mean that the xp required to level up is just 10x the number of whatever the level is? Otheer than that it looks as if it would work. I'll try it tomorrow. |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2013 04:30 PM |
the ^2 means the level squared making a bigger gap between levels.
exp needed for level 2 = 40 exp needed for level 3 = 90 --50 diff exp needed for level 4 = 160 -- 70 diff (+20) exp needed for level 5 = 250 -- 90 diff (+20) |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2013 04:50 PM |
@Fed
How would I do this in a more efficient way?
He asked how. I told him how. Your argument on how I didn't help much is invalid because I didn't even have to give him that little hint as I am not obligated to help. Being a hypocrite means you criticize someone for something you do as well. I called you out as a hypocrite because you told me to get out when you weren't helping the op at all.
Basically, I read the op's question and gave him the answer. If you disagree then ignore it, you did not have to butt in and call me out. That's immature is what it is. |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2013 10:48 AM |
Ahh, that makes sense now, PREST.
What's the *10 do then?
exp.Changed:connect(function() if exp > ( lvl ^2 ) *10 then lvl = lvl + 1 end end) |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2013 02:36 PM |
Bump, can anyone tell me what the *10 does? I know it multiplies by 10 but what is it for?
exp.Changed:connect(function() if exp > ( lvl ^2 ) *10 then lvl = lvl + 1 end end) |
|
|
| Report Abuse |
|
|
| |
|