Inspect: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(created page for Inspect)
 
Line 21: Line 21:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
local Table = {     
local Table = {     
     ["position"] = {position = {getElementPosition(localPlayer)},rotation = {getElementRotation( localPlayer )}},
     ["matrix"] = {position = {getElementPosition(localPlayer)},rotation = {getElementRotation( localPlayer )}},
     ["localplayer"] = getPlayerName(localPlayer),
     ["localplayer"] = getPlayerName(localPlayer),
}
}
Line 35: Line 35:
{
{
   localplayer = "Loki",
   localplayer = "Loki",
   position = {
   matrix= {
     position = { 2496.3908691406, -1669.853515625, 13.335947036743 },
     position = { 2496.3908691406, -1669.853515625, 13.335947036743 },
     rotation = { -0, 0, 155.4147644043 }
     rotation = { -0, 0, 155.4147644043 }
Line 42: Line 42:
</pre>
</pre>
</section>
</section>
==See Also==
==See Also==
{{Utility functions}}
{{Utility functions}}

Revision as of 18:41, 15 December 2016

This function returns human-readable representations of tables and MTA datatypes as a string.

Syntax

string inspect ( mixed var )             

Required Arguments

  • var: A variable of any datatype.

Returns

Always returns a string.

Example

Click to collapse [-]
Client

This example draws the contents of a table and its data type:

local Table = {    
    ["matrix"] = {position = {getElementPosition(localPlayer)},rotation = {getElementRotation( localPlayer )}},
    ["localplayer"] = getPlayerName(localPlayer),
}

addEventHandler("onClientRender",root,
    function( )
        dxDrawText(inspect(Table),10,250)
    end
)

An example of what it should draw:

{
  localplayer = "Loki",
  matrix= {
    position = { 2496.3908691406, -1669.853515625, 13.335947036743 },
    rotation = { -0, 0, 155.4147644043 }
  }
}

See Also