Vector/Vector4: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ Category:Incomplete The Vector4 class is a class introduced in 1.4 ===Methods=== *create *normalize *[[Vector4.dot|dot]...")
 
No edit summary
 
(6 intermediate revisions by 3 users not shown)
Line 3: Line 3:
The Vector4 class is a class introduced in 1.4
The Vector4 class is a class introduced in 1.4


===Methods===
==Methods==
*[[Vector4.create|create]]
===create===
*[[Vector4.normalize|normalize]]
This is default constructor for the Vector4 class and returns a Vector4 object.
*[[Vector4.dot|dot]]


*[[Vector4.getLength|getLength]]
====Syntax====
*[[Vector4.getSquaredLength|getSquaredLength]]
<syntaxhighlight lang="lua">vector4 Vector4 ( float x = 0, float y = 0, float z = 0, float w = 0 )</syntaxhighlight>
*[[Vector4.getNormalized|getNormalized]]
*[[Vector4.getX|getX]]
*[[Vector4.getY|getY]]
*[[Vector4.getZ|getZ]]
*[[Vector4.getW|getW]]


*[[Vector4.setX|setX]]
* '''x''','''y''','''z''' and '''w''' coordinates for the vector. If not specified, they default to 0.
*[[Vector4.setY|setY]]
* Instead of these four coordinates, a single Vector4 object may be inserted to clone it.
*[[Vector4.setZ|setZ]]
*[[Vector4.setW|setW]]


===Variables===
====Example====
*[[Vector4.x|x]]
This example adds a command called "/garage", allowing you to get any garage bounding box.
*[[Vector4.y|y]]
<section name="Client" class="client" show="true">
*[[Vector4.z|z]]
<syntaxhighlight lang="lua">
*[[Vector4.w|w]]
function garageBoundingBox ( command, garageID)
*[[Vector4.normalized|normalized]]
  if not garageID then
*[[Vector4.length|length]]
      outputChatBox("[Usage] /garage <id>")
*[[Vector4.squaredLength|squaredLength]]
      return
  end
  if tonumber(garageID) then
      if tonumber(garageID) > 0 and tonumber(garageID) < 50 then
        local boundingBox = Vector4(getGarageBoundingBox (garageID))
        outputChatBox("West: "..boundingBox.x..", East: " ..boundingBox.y..", South: "..boundingBox.z.." North: "..boundingBox.w)
      else
        outputChatBox("Garage ID must be between 1 and 49")
      end
  end
end
addCommandHandler ("garage",garageBoundingBox)
</syntaxhighlight>
</section>
 
===dot===
===normalize===
 
===getX and setX===
===getY and setY===
===getZ and setZ===
===getW and setW===
===getNormalized===
===getSquaredLength===
===getLength===

Latest revision as of 18:54, 17 March 2018

The Vector4 class is a class introduced in 1.4

Methods

create

This is default constructor for the Vector4 class and returns a Vector4 object.

Syntax

vector4 Vector4 ( float x = 0, float y = 0, float z = 0, float w = 0 )
  • x,y,z and w coordinates for the vector. If not specified, they default to 0.
  • Instead of these four coordinates, a single Vector4 object may be inserted to clone it.

Example

This example adds a command called "/garage", allowing you to get any garage bounding box.

Click to collapse [-]
Client
function garageBoundingBox ( command, garageID)
   if not garageID then
      outputChatBox("[Usage] /garage <id>")
      return
   end
	
   if tonumber(garageID) then 
      if tonumber(garageID) > 0 and tonumber(garageID) < 50 then
         local boundingBox = Vector4(getGarageBoundingBox (garageID)) 
         outputChatBox("West: "..boundingBox.x..", East: " ..boundingBox.y..", South: "..boundingBox.z.." North: "..boundingBox.w)
      else
         outputChatBox("Garage ID must be between 1 and 49")
      end 
   end 
end 
addCommandHandler ("garage",garageBoundingBox)

dot

normalize

getX and setX

getY and setY

getZ and setZ

getW and setW

getNormalized

getSquaredLength

getLength