Inspect: Difference between revisions
Jump to navigation
Jump to search
m (→Example) |
m (specify that return value _could_ change if we updated inspect) |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 7: | Line 7: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
string inspect ( mixed var ) | string inspect ( mixed var [, table options] ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''var:''' A variable of any datatype. | *'''var:''' A variable of any datatype. | ||
*'''options:''' A table of options. It is not mandatory, but when it is provided, it must be a table. For a list of options, see the [https://github.com/kikito/inspect.lua#options Inspect's GitHub page]. | |||
===Returns=== | ===Returns=== | ||
Always returns a string. | Always returns a string. The contents can change if we update the inspect library, so it is not expected to be consistent across Lua versions. | ||
==Example== | ==Example== | ||
Line 24: | Line 25: | ||
["localplayer"] = getPlayerName(localPlayer), | ["localplayer"] = getPlayerName(localPlayer), | ||
} | } | ||
local inspectedTblStr = inspect(Table) | |||
addEventHandler("onClientRender",root, | addEventHandler("onClientRender",root, | ||
function( ) | function( ) | ||
dxDrawText( | --> then draw the created string. | ||
--> Try to NOT use such functions under onClientRender, since it works with loops, and if we want to print a bigger table, it will drop some frames. | |||
dxDrawText(inspectedTblStr,10,250) | |||
end | end | ||
) | ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
This is an example of what it should look like: | |||
[[File:InspectReturn.png|frame|none]] | |||
</section> | </section> | ||
==See Also== | ==See Also== | ||
{{Utility functions}} | {{Utility functions}} |
Latest revision as of 22:04, 29 January 2020
This function returns human-readable representations of tables and MTA datatypes as a string.
Syntax
string inspect ( mixed var [, table options] )
Required Arguments
- var: A variable of any datatype.
- options: A table of options. It is not mandatory, but when it is provided, it must be a table. For a list of options, see the Inspect's GitHub page.
Returns
Always returns a string. The contents can change if we update the inspect library, so it is not expected to be consistent across Lua versions.
Example
Click to collapse [-]
ClientThis example draws the contents of a table and its data type:
local Table = { ["matrix"] = {position = {getElementPosition(localPlayer)},rotation = {getElementRotation( localPlayer )}}, ["localplayer"] = getPlayerName(localPlayer), } local inspectedTblStr = inspect(Table) addEventHandler("onClientRender",root, function( ) --> then draw the created string. --> Try to NOT use such functions under onClientRender, since it works with loops, and if we want to print a bigger table, it will drop some frames. dxDrawText(inspectedTblStr,10,250) end )
This is an example of what it should look like:
See Also
- addDebugHook
- base64Decode
- base64Encode
- debugSleep
- decodeString
- encodeString
- fromJSON
- generateKeyPair
- getColorFromString
- getDevelopmentMode
- getDistanceBetweenPoints2D
- getDistanceBetweenPoints3D
- getEasingValue
- getNetworkStats
- getNetworkUsageData
- getPerformanceStats
- getRealTime
- getTickCount
- getTimerDetails
- getTimers
- getFPSLimit
- getUserdataType
- getVersion
- gettok
- isTransferBoxVisible
- setTransferBoxVisible
- hash
- inspect
- interpolateBetween
- iprint
- isOOPEnabled
- isTimer
- killTimer
- md5
- passwordHash
- passwordVerify
- pregFind
- pregMatch
- pregReplace
- removeDebugHook
- resetTimer
- setDevelopmentMode
- setFPSLimit
- setTimer
- ref
- deref
- sha256
- split
- teaDecode
- teaEncode
- toJSON
- tocolor
- getProcessMemoryStats
- utfChar
- utfCode
- utfLen
- utfSeek
- utfSub
- bitAnd
- bitNot
- bitOr
- bitXor
- bitTest
- bitLRotate
- bitRRotate
- bitLShift
- bitRShift
- bitArShift
- bitExtract
- bitReplace