Hey Guys!
I was wondering if someone could help me out with the debug console that can be opened if it is true in the conf.lua file.
Am I able to view variable values in it? Could I change the variables from the console, then have them change the game?
How would I go about doing this?
Any help would be great.
Thanks
Outlaw11A
Debug Console
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Debug Console
you could view the variable in it with (ex: love.graphics.getMode() whould return screen size and such) and then set the variable again with (love.graphics.setMode(width,height,...)
as for input in the command prompt I would suggest a second thread so the game doesn't freeze when it's looking for input in the console window.
SCRATCH THIS
I read a little about how you should NOT use love.graphics while in a thread so I came up with a different idea
hope this helps
as for input in the command prompt I would suggest a second thread so the game doesn't freeze when it's looking for input in the console window.
SCRATCH THIS
Code: Select all
-- EXAMPLE THREAD SET THING
require "love.event" -- Makes sure it has access to love.event functionality as only love.thread is loaded in a new thread by default
local function cmd(s)
local foundSpaceAt = string.find(s, " ") -- Looks for a space
s = string.sub(s,1,foundSpaceAt)-- Take the first command out of the string
return string.lower(s) -- Would make qUiT quals to quit
end
repeat
local command = io.read()
if cmd(command) == "quit" then
love.event.push('q') -- Quits the game
end
until false
Code: Select all
--main.lua
local cmd = love.thread.newThread("commandThread","commands.lua") -- unsure if .lua need to be included
function love.load()
cmd:start()
end
function love.update(dt)
local command = cmd:get("command") -- Gets command from the thread
if command then -- It's nil if no new commands has appeared
if string.sub(command,1,4) == "quit" then -- the 4 is because there's 4 letters in quit
love.event.push('q') -- QUITS
end
end
end
Code: Select all
--commands.lua
repeat
local cmd = love.thread.getThread("commandThread") -- Gets the current thread
local command = io.read() -- Reads the user input
if command then cmd:set("command",command) end -- Sets the variable to be used in the main thread
until false
Last edited by Zer0 on Sun Mar 24, 2013 5:07 pm, edited 1 time in total.
If you can't fix it, Kill it with fire. ( Preferably before it lays eggs. )
Re: Debug Console
You can do something like this
That will freeze your game, and you can now interact with the console. You can change variables, and inspect local variables (there's info on how to do this here http://pgl.yoyo.org/luai/i/debug.debug). To continue playing the game, enter just "cont".
Code: Select all
function love.keypressed(key)
if key == "rctrl" then
debug.debug()
end
end
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Debug Console
I can't help but feel Zer0 is trying to recreate repler.
Re: Debug Console
WOW! Thanks for the help guys! Will defs look into this.
Who is online
Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Bing [Bot], Google [Bot] and 10 guests