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 » Scripters
Home Search
 

Re: Infinite Loop?

Previous Thread :: Next Thread 
computerchris is not online. computerchris
Joined: 02 May 2009
Total Posts: 665
23 Jan 2015 08:21 PM
Hey guys, I'm playing around with the generic RPG styled leveling system. What I trying to accomplish is if the player gets a massive gain in xp, they could possibly break it and still have enough xp left over after the level up to level up again.

I keep getting this: maximum event re-entrancy depth exceeded

And the XP keeps going into the negatives.

Script:

local needRecalc = false

function updateXP(plr, level, xp, nxp)
needRecalc = false
if xp.Value >= nxp.Value then
xp.Value = xp.Value - nxp.Value
if needRecalc == false and xp.Value >= nxp.Value then
needRecalc = true
end
level.Value = level.Value + 1
end
end

function updateLvl(plr, level, xp, nxp, gold)
gold.Value = math.floor(gold.Value + ((level.Value*300)/40))
if level.Value == 1337 then
nxp.Value = 1337
elseif level.Value == 273 then
nxp.Value = 273
else
nxp.Value = math.sqrt(math.floor((level.Value*273)+1))*2.73
end
updateTag(plr, plr.Name, level, xp, nxp, gold)
if needRecalc then
updateXP(plr, level, xp, nxp)
end
end
Report Abuse
cross700 is not online. cross700
Joined: 20 Oct 2012
Total Posts: 258
23 Jan 2015 08:23 PM
IDK! XD
Report Abuse
computerchris is not online. computerchris
Joined: 02 May 2009
Total Posts: 665
23 Jan 2015 08:27 PM
Anyone with a logical answer in the right direction?
Report Abuse
CrescentJade is not online. CrescentJade
Joined: 07 Jul 2010
Total Posts: 5494
23 Jan 2015 08:27 PM
Wait you wanna remove all of the xp they gain after every level up? Thats terrible.. but i guess if you want just make it so the exp cant go over max exp. and when it hits it its set to 0 for 1 second.
Report Abuse
computerchris is not online. computerchris
Joined: 02 May 2009
Total Posts: 665
23 Jan 2015 08:32 PM
Nonono.. I wanna make it to where there's no excess xp..

For example...

Level 1:

XP: 1
NXP: 45

Player gains 3000 xp

XP: 3001
NXP: 45

Follow the latter after leveling

Level 2

XP: 2956
NXP: 64


Then it waits for XP to change again.. :/ So the player then has excess.. :(
Report Abuse
computerchris is not online. computerchris
Joined: 02 May 2009
Total Posts: 665
23 Jan 2015 08:39 PM
Bump? :D I'm not trying to be impatient, just really curious.
Report Abuse
morash is not online. morash
Joined: 22 May 2010
Total Posts: 5834
23 Jan 2015 08:40 PM
Loops or some strange calculation. The first one is easiest.
Report Abuse
computerchris is not online. computerchris
Joined: 02 May 2009
Total Posts: 665
23 Jan 2015 08:42 PM
Tried loops, still gets a massive negative, like somewhere alone 40k+

Calculations... Just... No.. That's what a vast majority of that is.
Report Abuse
morash is not online. morash
Joined: 22 May 2010
Total Posts: 5834
23 Jan 2015 08:43 PM
Then your doing your loop wrong.
Report Abuse
computerchris is not online. computerchris
Joined: 02 May 2009
Total Posts: 665
23 Jan 2015 08:45 PM
This should work right?

function updateStats(plr, level, xp, nxp, gold)
repeat
xp.Value = xp.Value - nxp.Value
level.Value = level.Value + 1
gold.Value = math.floor(gold.Value + ((level.Value*300)/40))
if level.Value == 1337 then
nxp.Value = 1337
elseif level.Value == 273 then
nxp.Value = 273
else
nxp.Value = math.sqrt(math.floor((level.Value*273)+1))*2.73
end
DataStore:UpdateAsync("Level", level.Value)
DataStore:UpdateAsync("Gold", gold.Value)

updateTag(plr, plr.Name, level, xp, nxp, gold)

wait(0.3)
until xp.Value < nxp.Value
end
Report Abuse
CrescentJade is not online. CrescentJade
Joined: 07 Jul 2010
Total Posts: 5494
24 Jan 2015 10:45 AM
Theoretically yes but what if an exploiter changed the nxp.Value to 0. Hint, don't use Values objects using datapersistance for the values it doesnt have a max save limit per minute and has same disadvantages as using Value objects, especially since i dont see you saving them with DataStore in this script.
Report Abuse
computerchris is not online. computerchris
Joined: 02 May 2009
Total Posts: 665
24 Jan 2015 05:03 PM
Then you obviously don't know datastore

DataStore:UpdateAsync("Level", level.Value)
DataStore:UpdateAsync("Gold", gold.Value)
Report Abuse
CrescentJade is not online. CrescentJade
Joined: 07 Jul 2010
Total Posts: 5494
24 Jan 2015 07:36 PM
I'm laughing at that. I'm talking about the exp. Unless you're mental or you just can't read then stop trying. If you can't accomplish this without help then don't disrespect the people trying to help you.

And yes I do know datastore, obviously more than you.

So you don't answer back with some idiotic assumption:

local store = game:GetService("DataStoreService"):GetDataStore("Guilds")

local Guildjoin = script.Parent.Guildjoin
local Guildname = script.Parent.GuildName
local Guildmemb = script.Parent.Parent.Parent.Parent.Parent
local Guild
local cancel = script.Parent.Cancel
plr = script.Parent.Parent.Parent.Parent.Parent
on = false

Guildjoin.MouseButton1Down:connect(function()
if not on then on = true
if store:GetAsync(Guildname.Text) ~= nil then
if store:GetAsync(Guildname.Text)[4][Guildmemb.Name] == nil then
Guild = store:GetAsync(Guildname.Text)
if Guild[3] < 6 then
Guild[3] = Guild[3] + 1
table.insert(Guild[4],{Guildmemb.Name, Guild[3]})
store:SetAsync(Guildname.Text,{Guild[1],Guild[2],Guild[3],Guild[4],Guild[3]})
plr.GuildNAME.Value = Guildname.Text
script.Parent.Parent.Parent.GuildList.GuildMembers.Disabled = true
wait()
script.Parent.Parent.Parent.GuildList.GuildMembers.Disabled = false
script.Parent.Visible = false
script.Parent.Parent.Visible = false
script.Parent.Parent.Parent.GuildList.Visible = true
else
end
else
end
end
end
end)

cancel.MouseButton1Click:connect(function()
script.Parent.Visible = false
script.Parent.Parent.BackgroundTransparency = 0
script.Parent.Parent.Create.Visible = true
script.Parent.Parent.Join.Visible = true
end)

Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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