generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Hidden equation in script

Previous Thread :: Next Thread 
LOLDarth is not online. LOLDarth
Joined: 19 Jun 2012
Total Posts: 59
23 Jun 2012 06:02 PM
asdfghjkl if x = 100, then x^3 is supposed to = 1000000
so in this script, x = currlevel and it returns x^3 which should be 100x100x100 = 1000000 BUT there seems to be a hidden equation in the script so it doesn't equal to 1000000.. I'm not so great at math so I can't really find it on my own.

local Player = script.Parent.Parent.Parent.Parent.Parent
local XP = Player.orangejuice.XP
local Level = Player.orangejuice.Level
local bar = script.Parent.BAR

GetExpNeeded = function(CurrLevel)
local x = CurrLevel
return x^3
end

GetTotalLevelXP = function(Level)
local total = 0
for i = Level-1, 1, -1 do
total = total + GetExpNeeded(i)
end
return total
end

CalcExpPercent = function(CurrLevel, CurrXp)
if (CurrLevel==1) then
local ratio = CurrXp/GetExpNeeded(CurrLevel)
return ratio>1 and 1 or ratio
else
local ratio = (CurrXp-GetTotalLevelXP(CurrLevel))/GetExpNeeded(CurrLevel)
--print(ratio,"=",(CurrXp-GetTotalLevelXP(CurrLevel)),":",GetExpNeeded(CurrLevel))
return ratio>1 and 1 or ratio
end
end

Level.Changed:connect(function()
bar.Parent.Lvl.Text = "Leveled Up! ("..Level.Value..")"
for i = 1, 5 do
bar.Parent.BorderColor3 = Color3.new(1, 0, 0)
bar.Parent.Lvl.TextColor3 = Color3.new(1, 0, 0)
wait(0.2)
bar.Parent.BorderColor3 = BrickColor.new(1).Color
bar.Parent.Lvl.TextColor3 = BrickColor.new(1).Color
wait(0.2)
end
local xScale = CalcExpPercent(Level.Value, XP.Value)
bar.Position = UDim2.new(-1+xScale, 2, 0, 2)
bar.Parent.BorderColor3 = Color3.new(1, 204/255,0)
bar.Parent.Lvl.TextColor3 = BrickColor.new(1).Color
bar.Parent.Lvl.Text = "Level "..Level.Value
if Level.Value >= 100 then
script:remove()
end
end)

XP.Changed:connect(function()
local xScale = CalcExpPercent(Level.Value, XP.Value)
bar.Position = UDim2.new(-1+xScale, 2, 0, 2)
if (xScale==1) then
Level.Value = Level.Value + 1
end
end)


local scale = CalcExpPercent(Level.Value, XP.Value)
bar.Position = UDim2.new(-1+scale, 2, 0, 2)
bar.Parent.BorderColor3 = Color3.new(1, 204/255,0)
bar.Parent.Lvl.TextColor3 = BrickColor.new(1).Color
bar.Parent.Lvl.Text = "Level "..Level.Value
Report Abuse
LOLDarth is not online. LOLDarth
Joined: 19 Jun 2012
Total Posts: 59
23 Jun 2012 06:54 PM
I would appreciate a fix now... I have nothing else to do.
Report Abuse
LOLDarth is not online. LOLDarth
Joined: 19 Jun 2012
Total Posts: 59
23 Jun 2012 07:40 PM
... bump
Report Abuse
FlappydavidINC is not online. FlappydavidINC
Joined: 20 May 2011
Total Posts: 694
23 Jun 2012 08:13 PM
Where'd you get this free model from?
Report Abuse
LOLDarth is not online. LOLDarth
Joined: 19 Jun 2012
Total Posts: 59
23 Jun 2012 08:37 PM
AgentFirefox
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
23 Jun 2012 08:41 PM
@Flappy - Burned. :P

@LOLDarth - Wouldn't it make more sense to ask him?

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning." - Rick Cook
Report Abuse
LOLDarth is not online. LOLDarth
Joined: 19 Jun 2012
Total Posts: 59
23 Jun 2012 08:42 PM
:P fine... but last time I checked this forum was called "Scripting Helpers."
Which, in the description clearly says: "Need to edit an existing script?"
And I need help editing an existing script.
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
23 Jun 2012 08:45 PM
@LOLDarth - True, but this forum is generally used as a last resort. And seeing as he made the script, I would figure it more reliable to ask him.

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning." - Rick Cook
Report Abuse
LOLDarth is not online. LOLDarth
Joined: 19 Jun 2012
Total Posts: 59
23 Jun 2012 08:52 PM
I figured it out. :P
The script was doing x^3 + currexp
Report Abuse
FlappydavidINC is not online. FlappydavidINC
Joined: 20 May 2011
Total Posts: 694
23 Jun 2012 09:02 PM
Electric, burned. :P.

Sound familiar? XD.
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
23 Jun 2012 09:05 PM
I didn't get burned. I'm looking at you right now, and I see burned ashes that were burned from the ashes that were you.

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning." - Rick Cook
Report Abuse
FlappydavidINC is not online. FlappydavidINC
Joined: 20 May 2011
Total Posts: 694
23 Jun 2012 09:07 PM
Okay.. XD.
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
23 Jun 2012 09:08 PM
:)

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning." - Rick Cook
Report Abuse
FlappydavidINC is not online. FlappydavidINC
Joined: 20 May 2011
Total Posts: 694
23 Jun 2012 09:19 PM
I think you're on weed, XD.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image