Skip to content

Debug Library

Person8880 edited this page Jun 8, 2014 · 2 revisions

Overview

The debug library is a useful tool for getting to local variables and altering them without having to copy and paste gamecode.

Shine.GetUpValue

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:

  1. The upvalue if found, or nil otherwise.
  2. The index at which the upvalue was found.
  3. If the upvalue was found in a function that is not the input function, then it will be returned here.

Shine.GetUpValues

Shine.GetUpValues( Function )

Returns a table of name->value pairs containing all upvalues in the given function.

Shine.SetUpValue

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

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

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

Shine.IsType( Value, TypeName )

Returns true if Value has type TypeName, false otherwise.

Shine.Assert

Shine.Assert( Condition, Message, ... )

Same as Lua's assert, except calls string.format on Message passing ... to it.

Clone this wiki locally