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: Why do people suggest using PCall in Datapersistence?

Previous Thread :: Next Thread 
Quenty is not online. Quenty
Joined: 03 Sep 2009
Total Posts: 9316
29 Mar 2012 06:44 PM
Why do people say to use PCall in data persistence. I understand the request may not go through, but in that case, wouldn't your whole game be somewhat broken? And has anyone ever EXPERIENCE a time when a request doesn't go through?

Also, if we have to use pcall on DP (Data persistence), why not use it on other such methods like IsInGroup() or IsFriendsWith() or any other such methods that require a data lookup? And what if something TOTALLY random happens, like a players character doesn't load or something....

What if we assume that we can't rely on ANY value that we are getting outside of the script? Is it even worth creating an if statement if a vital part of the script isn't going to run because something random happens?

What do you think?
Report Abuse
LocalChum is not online. LocalChum
Joined: 04 Mar 2011
Total Posts: 6906
29 Mar 2012 06:53 PM
The data persistence functions can throw errors such as "Data not loaded yet; wait for DataReady". It's just a precaution, not a requirement.
Report Abuse
Quenty is not online. Quenty
Joined: 03 Sep 2009
Total Posts: 9316
29 Mar 2012 06:56 PM
Why don't they just return false.... :(
Report Abuse
NecroBumpist is not online. NecroBumpist
Joined: 12 Sep 2010
Total Posts: 4198
29 Mar 2012 07:16 PM
@Quenty,
BECAUSE ROBLOX SAYS SO!
Report Abuse
Quenty is not online. Quenty
Joined: 03 Sep 2009
Total Posts: 9316
29 Mar 2012 07:58 PM
>_<
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
29 Mar 2012 08:34 PM
Don't listen to the people who say that.

There is no case where using pcall should be used over something else. The only case where you should use pcall is when there is no option to do what you want to do. In this case, there is another option, which is to just not use pcall at all.

Just make sure you either used the WaitForDataReady function, either made sure the DataReady property is true. If so, then they won't error and using pcall would be plainly stupid.

Pcall was created only to catch errors. Using it should never be recommended. Just like you should only use deprecated stuff when there is absolutely no other option, you should do the same with pcall.

Considering some ROBLOX methods might throw errors without there being a way to prevent it (there is a way to prevent it for data persistence, you can just check if the DataReady property is true, so you have no excuse), pcall must be used in certain cases. Data persistence is not one of these.
Report Abuse
jeditkacheff is not online. jeditkacheff
Joined: 25 Mar 2010
Total Posts: 231
30 Mar 2012 05:40 PM
What if Data Persistence fails because there is a server outage? Or a database becomes corrupt? This is a rare event, but you might want to use a pcall to let a user know that saving is down, or if you don't want a script to crash (or at least an event listener).
Report Abuse
LPGhatguy is online. LPGhatguy
Forum Moderator
Joined: 27 Jun 2008
Total Posts: 4725
31 Mar 2012 12:28 AM
@jeditkacheff
When servers explode, you couldn't just *return* an error message? Do you need to break everything in that event, or force us to use pcall? Is that *really* necessary?
Report Abuse
Quenty is not online. Quenty
Joined: 03 Sep 2009
Total Posts: 9316
31 Mar 2012 01:28 AM
I'm guessing at the point of your server exploding, ROBLOX won't be up either. :)
Report Abuse
trappingnoobs is not online. trappingnoobs
Joined: 05 Oct 2008
Total Posts: 19100
31 Mar 2012 03:37 AM
I'm also guessing that if the servers are down then it's gonna be more than just someone's level.
Report Abuse
NINJAKID09 is not online. NINJAKID09
Joined: 27 Aug 2009
Total Posts: 14392
31 Mar 2012 05:39 AM
Because people are too stupid to use:

Player:WaitForDataReady()

and

if Player.DataReady then
-- code
end
Report Abuse
trappingnoobs is not online. trappingnoobs
Joined: 05 Oct 2008
Total Posts: 19100
31 Mar 2012 05:49 AM
"
Player:WaitForDataReady()

and

if Player.DataReady then
-- code
end"

Using both is stupider than not using either
Report Abuse
pighead10 is not online. pighead10
Joined: 03 May 2009
Total Posts: 10341
31 Mar 2012 07:38 AM
Because, simply put, data persistence can break. Even if DataReady is true, it can still break, as we found out when beta testing it, and I doubt everything has been fixed.
Report Abuse
jeditkacheff is not online. jeditkacheff
Joined: 25 Mar 2010
Total Posts: 231
03 Apr 2012 01:15 PM
dp servers are different than the game server
Report Abuse
trappingnoobs is not online. trappingnoobs
Joined: 05 Oct 2008
Total Posts: 19100
03 Apr 2012 01:40 PM
"dp servers are different than the game server"

Yeah but if they go down, the game's not gonna work right either way, so just let it error.
Report Abuse
dennisvdz is not online. dennisvdz
Joined: 14 Dec 2008
Total Posts: 3710
03 Apr 2012 01:42 PM
I've had often enough stuff in my game not saving because of a random DP error, caught by the pcall. If I wouldn't use pcall the event would've been disconnected etc.
Report Abuse
jode6543 is not online. jode6543
Joined: 16 Jun 2009
Total Posts: 5363
03 Apr 2012 01:50 PM
I only use it because I have an OCD for making sure nothing errors unexpectedly. I should probably stop using pcall for DP, but meh. It doesn't matter horrifically, in most cases.
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
03 Apr 2012 02:29 PM
[ Content Deleted ]
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
04 Apr 2012 11:50 PM
"What if Data Persistence fails because there is a server outage? Or a database becomes corrupt?"

Then it's not your fault, so it shouldn't return an error and ROBLOX should take care of it somehow. It shouldn't need to be handled by your code, ROBLOX should handle it. Don't ask me how, though, as I really have no idea.

"Because, simply put, data persistence can break. Even if DataReady is true, it can still break, as we found out when beta testing it, and I doubt everything has been fixed."

Actually, you should still not use pcall, because, if a such thing happens, you're not responsible, it's not your fault, and you're not supposed to take care of it. You're supposed to let ROBLOX take care of it.

Scripters shouldn't have to worry about power outage and that kind of stuff. These things should be handled by the application, not by the scripters's scripts!

"Yeah but if they go down, the game's not gonna work right either way, so just let it error."

Exactly.

@Oysi

I disagree. There are things that should be handled by your code and things that should be handled by ROBLOX. Data persistence is one of the things that should be handled by ROBLOX. I even think they should make all the DP functions wait until the data is ready.

Your script is trying to get a certain value. It doesn't care if it hasn't loaded or if there was a power outage, it just wants the value. IT JUST WANTS THE FREAKING VALUE. It doesn't want to know if ROBLOX's servers are down or something, IT WANTS THE VALUE!!!
Report Abuse
pighead10 is not online. pighead10
Joined: 03 May 2009
Total Posts: 10341
06 Apr 2012 07:29 AM
"Actually, you should still not use pcall, because, if a such thing happens, you're not responsible, it's not your fault, and you're not supposed to take care of it. You're supposed to let ROBLOX take care of it."

But roblox doesn't take care of it, so you need to use pcall ;P
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
06 Apr 2012 07:45 AM
[ Content Deleted ]
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