Jump to content

OOP matrices (without enabling OOP)


Buffalo

Recommended Posts

Posted

So it's possible to use OOP matrices and vectors without actually enabling OOP in meta file according to wiki.

How would following example look with these conditions without OOP enabled? (Curiosity)

local positionBelow = vehicle.position - vehicle.matrix.up 

  • Moderators
Posted

https://wiki.multitheftauto.com/wiki/GetElementMatrix

Take a look at the examples.

Wiki source:

This example creates some more matrix utility functions
  
function getMatrixLeft(m) 
    return m[1][1], m[1][2], m[1][3] 
end 
function getMatrixForward(m) 
    return m[2][1], m[2][2], m[2][3] 
end 
function getMatrixUp(m) 
    return m[3][1], m[3][2], m[3][3] 
end 
function getMatrixPosition(m) 
    return m[4][1], m[4][2], m[4][3] 
end 
  
local mat = getElementMatrix(element)  -- Get the matrix 
x,y,z = getMatrixLeft(mat)     -- Get the matrix left direction 
x,y,z = getMatrixForward(mat)  -- Get the matrix forward direction 
x,y,z = getMatrixUp(mat)       -- Get the matrix up direction 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...