Difference between revisions of "Debug"

(I <3 <code>)
m (also missing word.)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
From [http://www.lua.org/manual/5.1/manual.html#pdf-debug.debug Lua Reference Manual]:
+
From the [http://www.lua.org/manual/5.1/manual.html#pdf-debug.debug Lua Reference Manual]:
<blockquote cite="http://pgl.yoyo.org/luai/i/debug.debug">Enters an interactive mode with the user, running each string that the user enters. Using simple commands and other debug facilities, the user can inspect global and local variables, change their values, evaluate expressions, and so on. A line containing only the word <code>cont</code> finishes this function, so that the caller continues its execution.
+
<blockquote cite="http://pgl.yoyo.org/luai/i/debug.debug">Enters an interactive mode with the user, running each [[string]] that the user enters. Using simple commands and other debug facilities, the user can inspect [[global]] and [[local]]  variables, change their values, evaluate expressions, and so on. A line containing only the word <code>cont</code> finishes this function, so that the caller continues its execution.
  
 
Note that commands for <code>debug.debug</code> are not lexically nested within any function, and so have no direct access to local variables.</blockquote>
 
Note that commands for <code>debug.debug</code> are not lexically nested within any function, and so have no direct access to local variables.</blockquote>
Line 13: Line 13:
 
</source>
 
</source>
  
Caveat: The debug mode can only be activated if there is a terminal bound to LÖVE. On Windows, launching LÖVE from the command prompt is not sufficient. Instead, run LÖVE in console mode with the command line argument "<code>--console</code>" or the configuration file option "<code>t.console = true</code>".
+
Caveat: The debug mode can only be activated if there is a terminal bound to LÖVE. On Windows, launching LÖVE from the command prompt is not sufficient. Instead, run LÖVE in console mode with the command line argument "<code>--console</code>" or the [[love.conf|configuration file]] option "<code>t.console = true</code>".
  
 
[[Category:Snippets]]
 
[[Category:Snippets]]
 +
{{#set:LOVE Version=any}}
 +
{{#set:Description=Lua debug interface through the console.}}

Latest revision as of 17:29, 11 November 2016

From the Lua Reference Manual:

Enters an interactive mode with the user, running each string that the user enters. Using simple commands and other debug facilities, the user can inspect global and local variables, change their values, evaluate expressions, and so on. A line containing only the word cont finishes this function, so that the caller continues its execution. Note that commands for debug.debug are not lexically nested within any function, and so have no direct access to local variables.

function love.keypressed(key, u)
   --Debug
   if key == "rctrl" then --set to whatever key you want to use
      debug.debug()
   end
end

Caveat: The debug mode can only be activated if there is a terminal bound to LÖVE. On Windows, launching LÖVE from the command prompt is not sufficient. Instead, run LÖVE in console mode with the command line argument "--console" or the configuration file option "t.console = true".