jit/util.funck

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Added secret behavior)
(Clarification)
Line 2: Line 2:
 
|Description=Gets a constant at a certain index in a function.
 
|Description=Gets a constant at a certain index in a function.
 
{{Warning|This function isn't officially documented on LuJIT wiki, use it at your own risk.}}
 
{{Warning|This function isn't officially documented on LuJIT wiki, use it at your own risk.}}
{{Warning|If looking for number constants, it goes from 0 to n not from -1 to -n}}
+
{{Warning|Numbers constants goes from 0 (included) to n-1, n being the value of nconsts in {{LibraryFunction|jit|util.funcinfo}} in other words, the consts goes from (nconsts-1) to -n}}
 
{{Note|This function only works for Lua defined functions.}}
 
{{Note|This function only works for Lua defined functions.}}
 
|Realm=Shared and Menu
 
|Realm=Shared and Menu

Revision as of 15:03, 22 October 2019

 jit.util.funck( )

Contents

Description

Gets a constant at a certain index in a function.

WARNING

This function isn't officially documented on LuJIT wiki, use it at your own risk.

WARNING

Numbers constants goes from 0 (included) to n-1, n being the value of nconsts in jit.util.funcinfo in other words, the consts goes from (nconsts-1) to -n

NOTE

This function only works for Lua defined functions.

Arguments

function func

Function to get constant from

Arguments

number index

Constant index (counting down from the top of the function at -1)

Returns

any

the constant found

Examples

Example

This code demonstrates how to get a constant in a function.

function bob()
    print("hi")
end

print(jit.util.funck(bob, -1))
print(jit.util.funck(bob, -2))

Output:

"print" "hi"
Personal tools
Navigation