Flash77
|
  |
| Joined: 14 Jun 2008 |
| Total Posts: 550 |
|
|
| 31 May 2012 05:40 PM |
| how come Vector3.new(nil,nil,nil) = Vector3.new(0,0,0) but nil doesnt equal 0? |
|
|
| Report Abuse |
|
|
|
| 31 May 2012 05:45 PM |
> print(tonumber(nil)) nil
~Read Between The Squiggles~ |
|
|
| Report Abuse |
|
|
Flash77
|
  |
| Joined: 14 Jun 2008 |
| Total Posts: 550 |
|
|
| 31 May 2012 05:47 PM |
> print(Vector3.new(nil,nil,nil) == Vector3.new(0,0,0)) true |
|
|
| Report Abuse |
|
|
|
| 31 May 2012 05:47 PM |
Odd...
~Read Between The Squiggles~ |
|
|
| Report Abuse |
|
|
|
| 31 May 2012 05:50 PM |
> print( nil + 1 ) 18:47:55 - print( nil + 1 ):1: attempt to perform arithmetic on a nil value 18:47:55 - Script "print( nil + 1 )", Line 1 18:47:55 - stack end
~Read Between The Squiggles~ |
|
|
| Report Abuse |
|
|
| |
|
Flash77
|
  |
| Joined: 14 Jun 2008 |
| Total Posts: 550 |
|
| |
|
Halted
|
  |
| Joined: 20 May 2012 |
| Total Posts: 11 |
|
|
| 31 May 2012 05:58 PM |
@Flash,
you spelled 'nil' wrong.
- Halted |
|
|
| Report Abuse |
|
|
Flash77
|
  |
| Joined: 14 Jun 2008 |
| Total Posts: 550 |
|
| |
|
agent767
|
  |
| Joined: 03 Nov 2008 |
| Total Posts: 4181 |
|
|
| 31 May 2012 06:23 PM |
| Trying to create a Vector3.new(nil,nil,nil) will automaticly set it to 0,0,0. |
|
|
| Report Abuse |
|
|
1Topcop
|
  |
| Joined: 09 Jun 2009 |
| Total Posts: 6635 |
|
|
| 31 May 2012 09:11 PM |
If a value in the vector isn't a number, it resets the value to 0. Ex.: > print(tostring(Vector3.new("Lol",nil,25))) 0, 0, 25 |
|
|
| Report Abuse |
|
|
|
| 31 May 2012 09:12 PM |
function dat(n) if n == nil then return 0 else return n end end
print(dat(nil)) --> 0 print(dat(0)) --> 0
It doesn't prove anything. It's just an escape statement.
The reason they do that is so that you can do
Vector3.new()
to refer to the additive identity vector. |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 31 May 2012 09:13 PM |
| Because Vector3.new(nil, nil, nil) is equivilent to Vector3.new(); calling the default new on Vector3 creates the same thing as Vector3.new(0, 0, 0) |
|
|
| Report Abuse |
|
|
1Topcop
|
  |
| Joined: 09 Jun 2009 |
| Total Posts: 6635 |
|
| |
|
|
| 31 May 2012 09:15 PM |
You can prove it by doing
print(nil == false) > false |
|
|
| Report Abuse |
|
|
| |
|
1Topcop
|
  |
| Joined: 09 Jun 2009 |
| Total Posts: 6635 |
|
| |
|