-
Notifications
You must be signed in to change notification settings - Fork 23
Debug Library
The debug library is a useful tool for getting to local variables and altering them without having to copy and paste gamecode.
Shine.GetUpValue( Function, Name[, Recursive ] )
Gets the upvalue with the name Name
from Function
. If Recursive
is true, then the function's function upvalues will also be searched for it.
Returns:
- The upvalue if found, or nil otherwise.
- The index at which the upvalue was found.
- If the upvalue was found in a function that is not the input function, then it will be returned here.
Shine.GetUpValues( Function )
Returns a table of name->value pairs containing all upvalues in the given function.
Shine.SetUpValue( Function, Name, NewValue[, Recursive ] )
Sets the upvalue with the name Name
in Function
to the value NewValue
. If Recursive
is true, then it will search the function upvalues of Function
and replace a matching upvalue in those too.
Returns the replaced upvalue, or nil if it was not found.
Shine.SetUpValues( Function, Values[, Recursive ] )
Sets all upvalues in Function
provided as name->value pairs in Values
to the values given. If Recursive
is true, then the same is done for function upvalues of Function
.
Shine.MimicFunction( Function, UpValueName, Replacement[, DifferingValues, Recursive ] )
Takes the upvalue with name UpValueName
from Function
and replaces it with Replacement
. Your replacement function will receive all upvalues from the original function.
If you provide DifferingValues
, then it will also have any upvalues in DifferingValues
, replacing the original values. Recursion will replace upvalues in function upvalues of the replacement function with those in DifferingValues
.
Returns the table of upvalues that the replacement function now has.
Shine.IsType( Value, TypeName )
Returns true if Value
has type TypeName
, false otherwise.
Shine.Assert( Condition, Message, ... )
Same as Lua's assert
, except calls string.format
on Message
passing ...
to it.