of     3   
chevron_rightchevron_rightchevron_right

ChocoIateOverdose
#181779586Saturday, January 16, 2016 6:03 PM GMT

How do I do try/catch here? I cant find it on the wiki, but I find it hard to believe roblox lua doesnt have this...
wonderful72pike
#181779718Saturday, January 16, 2016 6:05 PM GMT

pcall(f) - "f" is a function running in protected mode, it will then return a boolean telling you if your function had an error or not. This is equivalent to try/catch. error(msg) - This is equivalent to throw, it lets you make your own error message.
ChocoIateOverdose
#181780813Saturday, January 16, 2016 6:20 PM GMT

Thanks
JarodOfOrbiter
#181781695Saturday, January 16, 2016 6:31 PM GMT

Actually, pcall returns a boolean showing whether it succeeded or not. And then, if it did, it will return the data returned by the function as second, third, etc arguments. If it didn't, it will return the error as a second argument.
warspyking
#181782225Saturday, January 16, 2016 6:38 PM GMT

I'm not recommending this at all, but this is the closest I've managed to actual try/catch/finally syntax, without the loss of syntax highlighting (if I didn't care about highlighting I'd just go use loadstring and use [[]] quotes to completely eliminate the requirement of functions): function try(tryt) return {catch = function(catcht) xpcall(tryt[1], catcht[1]) return {finally = function(finallyt) finallyt[1]() end } end, finally = function() pcall(tryt[1]) return function(finallyt) finallyt[1]() end end } end try { function() print(i.i) end } .catch { function(err) warn(err) end } .finally { function() print("try statement finished") end }
LongKillKreations
#181782291Saturday, January 16, 2016 6:39 PM GMT

nice warspy
cntkillme
#181792808Saturday, January 16, 2016 8:59 PM GMT

Disgusting
warspyking
#181795025Saturday, January 16, 2016 9:29 PM GMT

And why is that, cnt?
ChocoIateOverdose
#181827495Sunday, January 17, 2016 5:17 AM GMT

he waz talking about his t-shirt
cntkillme
#181828888Sunday, January 17, 2016 5:40 AM GMT

No I was talking about war's code. And war if you really don't know why your script is disgusting then I suggest relearning Lua.
bosswalrus
#181829818Sunday, January 17, 2016 5:57 AM GMT

What does try and catch do
Hedr0n
#181829931Sunday, January 17, 2016 5:59 AM GMT

I don't even think cnt knows what he is talking about
bosswalrus
#181829970Sunday, January 17, 2016 6:00 AM GMT

Cnt knows what he is talking about.
Hedr0n
#181830033Sunday, January 17, 2016 6:02 AM GMT

Yes I know I posted that for a reason
warspyking
#181890710Monday, January 18, 2016 1:17 AM GMT

@cnt You ought to learn that people code for different reasons. You like low-level things and you code for.. Well Idek, but I prefer to code for fun. Yes I make practical stuff. Yes I made useful stuff. But mostly, I do things for fun and for the sake of curiosity. If you can't appreciate that, then you need to learn to be a bit more open-minded and learn to respect other's opinions and hobbies, even if you don't necessarily agree with them.
cpmoderator12345
#181891128Monday, January 18, 2016 1:21 AM GMT

ew functions defined inside functions you underestimate the power of the dank side
cntkillme
#181891259Monday, January 18, 2016 1:23 AM GMT

"learn to respect other's opinions and hobbies" My hobby is making fun of your crap, so why don't you respect my hobby? Or are you special and unique and too sensitive to realize that I said your code sucks, not that it was useless (albeit it's useless because xpcall is sufficient).
cody123454321
#181893087Monday, January 18, 2016 1:46 AM GMT

try { function() print(i.i) end } .catch { function(err) warn(err) end } .finally { function() print("try statement finished") end } I like this style better, as there is no need for tables being passed. try ( function() print(i.i) end ) .catch ( function(err) warn(err) end ) .finally ( function() print("try statement finished") end )
matt089720
#181893107Monday, January 18, 2016 1:46 AM GMT

cnt i would like to see u do better meow
cntkillme
#181893491Monday, January 18, 2016 1:51 AM GMT

xpcall There, I did better with 10x less overhead and 10x more efficiency.
warspyking
#181893621Monday, January 18, 2016 1:52 AM GMT

First of all, in all honesty, I don't think that's a very healthy hobby. Secondly, this is still rather childish. Most of the stuff that gets posted here is terrible, yet for some reason, you're still here. You need to accept the fact we're not all like you. Just because I code something that sucks, as you call it, doesn't mean you have to publicly call it out it just for kicks. It's a rather immature thing to do.
ScriptingIntoTerror
#181893895Monday, January 18, 2016 1:55 AM GMT

cnt, War can script circles around you. Go find another habit, picking on someone superior than you is childish and just makes you look weak. ~Terror
warspyking
#181893907Monday, January 18, 2016 1:55 AM GMT

'cnt i would like to see u do better ' I KNOW he could do better. I'm not claiming my code is GOOD. The only problem I have is him, after time and time again, insulting my code. He does this continuously, despite the fact it's not meant for his approval. It's childish, and immature. My code doesn't have to be up to YOUR standards cnt.
bosswalrus
#181893974Monday, January 18, 2016 1:56 AM GMT

"cnt, War can script circles around you." No.
DrHaximus
#181894008Monday, January 18, 2016 1:56 AM GMT

"cnt, War can script circles around you. Go find another habit, picking on someone superior than you is childish and just makes you look weak." nice 34 posts, newfriend. don't assert your opinion on topics you don't know anything about :^)

    of     3   
chevron_rightchevron_rightchevron_right