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: An Example of xpall please?

Previous Thread :: Next Thread 
Born2Script is not online. Born2Script
Joined: 23 Jul 2013
Total Posts: 2670
20 Jun 2015 06:08 PM
I know I have been asking a lot lately but I'm trying to do and learn something I have never done before

I know how pcall works but I want to catch the error, therefore, I remebered ready something about xpall. I can't find the wiki page, so can someone just give me an example?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
20 Jun 2015 06:10 PM
xpcall(function() ogm("Error not a real global") end, function(...) print("[ERR]", ...) end)
Report Abuse
ChiefDelta is not online. ChiefDelta
Joined: 05 Nov 2010
Total Posts: 13071
20 Jun 2015 06:10 PM
w-what

that doesnt....that doesnt e- what? what the hell is xpall?


do u mean ypcall?????
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
20 Jun 2015 06:14 PM
http://wiki.roblox.com/index.php?title=Xpcall#xpcall_.28f.2C_err.29


Basically what it does is it takes the error and passes it to a function you give it, then will return if it ran successfully and what your error function returned:

function Handler(error_string)
return "'"..error_string.."' was the error"
end

print(xpcall(function() print(1 .. 2) --[[Error was concatenating numbers]] end, Handler))






@above ypcall and pcall are the same thing -_-
Report Abuse
Usering is not online. Usering
Joined: 18 Aug 2012
Total Posts: 10281
20 Jun 2015 06:18 PM
"@above ypcall and pcall are the same thing -_-"

ypcall = yield pcall
pcall = pcall

'yield' in pcall means that it won't break if there's a wait() function in your pcall statement.

I'm not sure whats different between xpcall and pcall, since they both return the same stuff

local error,message = pcall(function()prnti("hi, lol") end)
if error then
print(message)
else
print("ran successfully")
end
Report Abuse
swmaniac is not online. swmaniac
Joined: 28 Jun 2008
Total Posts: 15773
20 Jun 2015 06:20 PM
As I recall, the difference is that xpcall allows you to set your own error handling function, rather than just returning the information like pcall does.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
20 Jun 2015 06:22 PM
Usering, pcall is able to yield ever since like 2-3 years ago? since Roblox changed it, so ypcall is useless now
Report Abuse
jode6543 is not online. jode6543
Joined: 16 Jun 2009
Total Posts: 5363
20 Jun 2015 06:25 PM
They never changed xpcall to allow for yielding, though, so keep that in mind.
Report Abuse
ChiefDelta is not online. ChiefDelta
Joined: 05 Nov 2010
Total Posts: 13071
20 Jun 2015 06:25 PM
"Usering, pcall is able to yield ever since like 2-3 years ago? since Roblox changed it, so ypcall is useless now"

if it can some Wiki articles are outdated
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
20 Jun 2015 06:26 PM
You're correct, some Wiki articles are outdated.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
20 Jun 2015 08:08 PM
A yielding xpcall:

function xpcall(func, handler)
local status, result = pcall(func)
if not status then
return status, handler(result)
else
return status, result
end
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