|
| 23 Jan 2012 05:38 PM |
What would be an alternative to "if workspace:FindFirstChild("Part") == nil"? Would it be if not workspace:FindFirstChild("Part")?
† KMXD † |
|
|
| Report Abuse |
|
|
MXrcr20
|
  |
| Joined: 01 Oct 2008 |
| Total Posts: 2644 |
|
|
| 23 Jan 2012 05:40 PM |
Just take off the "== nil" at the end of it.
== nil just looks to see if it's not there. |
|
|
| Report Abuse |
|
|
UFAIL2
|
  |
| Joined: 14 Aug 2010 |
| Total Posts: 6905 |
|
|
| 23 Jan 2012 05:42 PM |
| If not would work, I'm assuming. |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2012 05:44 PM |
@MX I need it though. :/
@UFail I will try it then.
† KMXD † |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2012 05:47 PM |
Ozzy wrote a thing about truthy values. I don't have the link, but it goes like this.
if string~="abc" then -- a truthy value so you would also be able to do if not string=="abc" then
you can also do this
if bool then --same as "if bool==true then", b/c its a truthy value or if not bool then --same as "if bool==false then" '' |
|
|
| Report Abuse |
|
|
UFAIL2
|
  |
| Joined: 14 Aug 2010 |
| Total Posts: 6905 |
|
|
| 23 Jan 2012 05:49 PM |
@epic
http://wiki.roblox.com/index.php/Operators#Logical
Right page, correct? |
|
|
| Report Abuse |
|
|
Cyrok
|
  |
| Joined: 11 Jan 2012 |
| Total Posts: 630 |
|
|
| 23 Jan 2012 05:53 PM |
Knightmare had it right the first time, guys.
"if not workspace:FindFirstChild("Part") then"
Is the same as saying:
if game.Workspace:FindFirstChild("Part") == nil
{ I have an OCD when it comes to non-camelCase variables/custom functions. } |
|
|
| Report Abuse |
|
|
| |
|
|
| 23 Jan 2012 06:06 PM |
@UFAIL2; Yes, that is it.
@Cyrok; I know, I was just trying to further explain. Btw, are you an alt of someone? You know way too much about scripting to have joined this year. |
|
|
| Report Abuse |
|
|
UFAIL2
|
  |
| Joined: 14 Aug 2010 |
| Total Posts: 6905 |
|
|
| 23 Jan 2012 06:08 PM |
@epic
You can learn Lua before playing Roblox. |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2012 06:08 PM |
Not entirely. if not workspace:FindFirstChild("Part") then is the same as saying: if workspace:FindFirstChild("Part") == nil or workpsace:FindFirstChild("Part") == false then
but it's much faster for the computer :D |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2012 06:19 PM |
@UFAIL2;
I realize, that but how many kids even knew about the word "Lua" before Roblox? |
|
|
| Report Abuse |
|
|
Cyrok
|
  |
| Joined: 11 Jan 2012 |
| Total Posts: 630 |
|
|
| 23 Jan 2012 06:50 PM |
@epicfail22
Portuguese kids did.
{ I have an OCD when it comes to non-camelCase variables/custom functions. } |
|
|
| Report Abuse |
|
|
UFAIL2
|
  |
| Joined: 14 Aug 2010 |
| Total Posts: 6905 |
|
| |
|
|
| 23 Jan 2012 08:27 PM |
| Ahahaha. Wait, is it an actual word in portuguese? I knew it's origin was portuguese. |
|
|
| Report Abuse |
|
|
UFAIL2
|
  |
| Joined: 14 Aug 2010 |
| Total Posts: 6905 |
|
|
| 23 Jan 2012 08:30 PM |
| 'Lua' means moon in Portuguese. |
|
|
| Report Abuse |
|
|
|
| 26 Jan 2012 07:04 PM |
| :D I learned something new! |
|
|
| Report Abuse |
|
|
|
| 26 Jan 2012 07:35 PM |
@MX
Actually, saying `~= nil` is checking if it isn't nil. Saying:
if Workspace:FindFirstChild("Part") then
That would run as long as it doesn't return false, nil, and I think 0... Not sure about the 0 though. Otherwise, it is recommended that you use comparisons, but not required.
「TheNewScripter」 |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 26 Jan 2012 07:38 PM |
In a condition, nil and false always return false. Everything else returns true. That's why you never need to use the boolean operators "==" and "~=" with few exceptions such as comparing objects.
print(1 and "a" or "b")-->a print(nil and "a" or "b")-->b |
|
|
| Report Abuse |
|
|