Global/Vector

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m (remove Name and Parent)
Line 1: Line 1:
 
{{Func
 
{{Func
 
|Description=Creates a {{Type|Vector}} object.
 
|Description=Creates a {{Type|Vector}} object.
 +
{{Note|This function creates a new unique object. It's a good practice to localize your colors.}}
 
|Realm=Shared and Menu
 
|Realm=Shared and Menu
 
|IsClass=No
 
|IsClass=No

Revision as of 22:52, 11 January 2020

 Vector( )

Contents

Description

Creates a Vector object.

NOTE

This function creates a new unique object. It's a good practice to localize your colors.

Arguments

number x=0

The x component of the vector.
If this is a Vector, this function will return a copy of the given vector.
If this is a string, this function will try to parse the string as a vector. If it fails, it returns a 0 vector.

(See examples)

Arguments

number y=0

The y component of the vector.

Arguments

number z=0

The z component of the vector.

Returns

Vector

The created vector object.

Examples

Example

Creates a vector and prints the value to the console.

print( Vector( 1, 2, 3 ) )
print( Vector( "4 5 6" ) )
local test = Vector( 7, 8, 9 )
print( Vector( test ) )

print( Vector( "4 5 test" ) )
print( Vector() )

Output:

1.000000 2.000000 3.000000
4.000000 5.000000 6.000000
7.000000 8.000000 9.000000

0.000000 0.000000 0.000000
0.000000 0.000000 0.000000
Personal tools
Navigation