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: Difference between functions, operators, and conditionals?

Previous Thread :: Next Thread 
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
19 Dec 2016 01:10 PM
What is the technical difference between an operator, such as #, a function such as function DoSomething(), a conditional like if/and/or.

Also, is "not" a function or an operator?

What is "then"? just one half to the "if-then" conditional.


Report Abuse
Antcient555678 is not online. Antcient555678
Joined: 07 Nov 2011
Total Posts: 679
19 Dec 2016 01:13 PM
then is just the end of an if or elseif statement

not is an operator


Report Abuse
Antcient555678 is not online. Antcient555678
Joined: 07 Nov 2011
Total Posts: 679
19 Dec 2016 01:15 PM
an operator is this
<
>
+
-
/
*
==
~=
>=
<=

a function does something

"and" and "or" aren't conditionals, they're an operator of a conditional, and that answers
"Also, is "not" a function or operator?", not is an operator.

Then is the end of an if or elseif statement.


Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
19 Dec 2016 01:16 PM
lua
.
org
/pil/contents
.
html


Report Abuse
Antcient555678 is not online. Antcient555678
Joined: 07 Nov 2011
Total Posts: 679
19 Dec 2016 01:18 PM
also, two more operators are ^ and %


Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
19 Dec 2016 01:23 PM
How is "or" not a conditional?

What is "and"? Just a constructor neglected by nomenclature?


Report Abuse
Antcient555678 is not online. Antcient555678
Joined: 07 Nov 2011
Total Posts: 679
19 Dec 2016 01:27 PM
or is part of a conditional
and is also part of a conditional

like so

part = game.Workspace.Baseplate

if part.Transparency == 1 and part.BrickColor == "Bright green" then
print('Both conditions are true.')
end

if part.Transparency == 1 or part.BrickColor == "Bright green" then
print('One condition is true.')
end

And = all conditions that are being checked for must be what the script is looking for

Or = only one of the conditions that is being checked for must be what is the script is looking for


Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
19 Dec 2016 01:30 PM
What about if it's not attached to an if?

Such as

part = workspace:FindFirstChild("Part1") or workspace:FindFirstChild("Part2")


Report Abuse
Xstarlight is not online. Xstarlight
Joined: 18 Oct 2012
Total Posts: 870
19 Dec 2016 01:32 PM
That variable is "Part 1" unless "Part 1" does not exist then it is replace with "Part 2"
#code part = workspace:FindFirstChild("Part1") or workspace:FindFirstChild("Part2")
print("part")

will either print part 1 or part 2


https://www.roblox.com/games/462902053/Project-Maze-Prototype https://forum.roblox.com/Forum/ShowPost.aspx?PostID=204784127
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
19 Dec 2016 01:34 PM
I know what it does

I'm just saying, how is that not a conditional in and of itself?


Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
19 Dec 2016 01:47 PM
ffs soybeen use your brain and just look at documentation.

The logical operators are and, or, and not. Like control structures, all logical operators consider false and nil as false and anything else as true. The operator and returns its first argument if it is false; otherwise, it returns its second argument. The operator or returns its first argument if it is not false; otherwise, it returns its second argument:
print(4 and 5) --> 5
print(nil and 13) --> nil
print(false and 13) --> false
print(4 or 5) --> 4
print(false or 5) --> 5
Both and and or use short-cut evaluation, that is, they evaluate their second operand only when necessary.
A useful Lua idiom is x = x or v, which is equivalent to

if not x then x = v end
i.e., it sets x to a default value v when x is not set (provided that x is not set to false).
Another useful idiom is (a and b) or c (or simply a and b or c, because and has a higher precedence than or), which is equivalent to the C expression

a ? b : c
provided that b is not false. For instance, we can select the maximum of two numbers x and y with a statement like
max = (x > y) and x or y
When x > y, the first expression of the and is true, so the and results in its second expression (x) (which is also true, because it is a number), and then the or expression results in the value of its first expression, x. When x > y is false, the and expression is false and so the or results in its second expression, y.
The operator not always returns true or false:

print(not nil) --> true
print(not false) --> true
print(not 0) --> false
print(not not nil) --> false


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