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: Returning nil and Traditional Lua

Previous Thread :: Next Thread 
radar001 is not online. radar001
Joined: 04 Sep 2011
Total Posts: 718
23 Jun 2015 05:34 PM
Why does roblox lua return nil then err?
In traditional Lua this is a non-issue, as it can be evaded with a simple if statement, but what can loosely be called the Roblox lua "interpreter" complains every time a value come up nil.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
23 Jun 2015 05:37 PM
A lot of things return nil, err. Not only some Roblox stuff.
It's not an issue on Roblox Lua either.
Report Abuse
radar001 is not online. radar001
Joined: 04 Sep 2011
Total Posts: 718
23 Jun 2015 05:38 PM
@Cnt, it sure seems that way a lot of times though
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
23 Jun 2015 05:40 PM
Can you give an example, because I return nil, err a lot (bad habit, but whatever) when I want to tell the caller of the function that something went wrong and I had never had any sort of problem.
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
23 Jun 2015 05:41 PM
Uhh?

local var = nil is fine, if that's what you mean.
var + 1 or otherwise treating var like anything beside nil is of course not fine.

If that's not what you mean I'm going to ask you to try to explain yourself better.
Report Abuse
radar001 is not online. radar001
Joined: 04 Sep 2011
Total Posts: 718
23 Jun 2015 05:41 PM
So are all objs treated like files when they give a return value?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
23 Jun 2015 05:42 PM
I'm assuming you mean Roblox objects/instances, and the way that works is Roblox spits out an error if it's not a property or a child (properties are looked up first, hence the order). Basically the 2 reasons why FindFirstChild exists.
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
23 Jun 2015 05:44 PM
"So are all objs treated like files when they give a return value?"

Objs don't "return" anything (except functions). I'm not sure if you mean the Objs that you see in the explorer or all objects. Regardless, they all have "tostring" methods to them. Every time you print something that isn't a string there is an implicit call to tostring.
Report Abuse
radar001 is not online. radar001
Joined: 04 Sep 2011
Total Posts: 718
23 Jun 2015 05:46 PM
@Cnt, thanks

@Lord, they all return something though don't they? If it doesn't exist it returns nil and if it exists it returns a tostr of the data models name.
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
23 Jun 2015 05:48 PM
What
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
23 Jun 2015 05:48 PM
No, tostring returns something (it's a function). Like I said, when you print them, they are tostringed implicitly.
Report Abuse
radar001 is not online. radar001
Joined: 04 Sep 2011
Total Posts: 718
23 Jun 2015 05:49 PM
So its "ret val" is a ret val of another function?
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
23 Jun 2015 05:51 PM
Metamethods. Metamethods for days.
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