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 » Scripting Helpers
Home Search
 

Re: Arguments

Previous Thread :: Next Thread 
Jlobblet is not online. Jlobblet
Joined: 05 Sep 2010
Total Posts: 587
11 Aug 2012 10:53 AM
I'm guessing it's possible without the extra lines of code, but

Is it possible to have an argument in a function, which isoptional? IE you don't have to call it?
Such as:

function abc(d=true)
print(d)
end

And it will be:

abc() --> true
abc(false) -->false

Or would you need to do:

function abc(d)
if d == nil then d = true end
print(d)
end

?

~if not ok then return end
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
11 Aug 2012 10:56 AM
Why don't you test this out yourself? Roblox made a studio for testing and making games you know...

Report Abuse
Jlobblet is not online. Jlobblet
Joined: 05 Sep 2010
Total Posts: 587
11 Aug 2012 10:57 AM
As I know then 2nd works, but do not know the way to set a default WITHOUT the extra line. That is the enquiry.

~if not ok then return end
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
11 Aug 2012 11:01 AM
function abc(d)
print d == true and "yep or "no"
end

Report Abuse
Jlobblet is not online. Jlobblet
Joined: 05 Sep 2010
Total Posts: 587
11 Aug 2012 11:03 AM
And operator, I kicked myself.

~if not ok then return end
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
11 Aug 2012 11:06 AM
That's the beast way to do it man ^_^
Report Abuse
Jlobblet is not online. Jlobblet
Joined: 05 Sep 2010
Total Posts: 587
11 Aug 2012 11:09 AM
Adapting it to any agument, generally:

function abc(d)
return (d ~= nil and "d ~= nil" or "d == nil")
end

~if not ok then return end
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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