Page 2 of 2

Re: Debugging using ZeroBrane Studio

Posted: Sun Jun 18, 2017 3:58 pm
by randomnovice
Thanks,

Probably I'm not supposed to...? But I have. Here's my edited version of love.run() which is calling love.load() near the start?

Code: Select all

function love.run()
	-- Randomness!
	if love.math then love.math.setRandomSeed(os.time()) end
 
	-- Load things in
	love.load()
	  
	-- Big loop for everything
	while true do
		resetvariables()
		music:setLooping(true)
		music:play()

		-- Main game loop until a hero dies
		repeat
			-- Process events
			if love.event then
				love.event.pump()
				for name, a,b,c,d,e,f in love.event.poll() do
					if name == "quit" then
						if not love.quit or not love.quit() then
							return a
						end
					end
					love.handlers[name](a,b,c,d,e,f)
				end
			end
 
			-- Update
			love.update() 

			-- Draw
			love.graphics.clear(love.graphics.getBackgroundColor())
			love.graphics.origin()
			love.draw()
			love.graphics.present()
			
			-- Do I need this?			 
			love.timer.sleep(0.001)

      -- Call the A.I. if the game is not finishing
			if TURN == 2 and finishing == 0 then
				AI()
			end
		until finished == true

		mode = "Title"		-- "Title", "Select Hero", "Select Cards", "Overview"
		mode_old = "Title"	-- Switch back with escape twice
	end
end
(..and the reason for having a custom love.run() function was having this loop at the "base" level)

EDIT: Okay, quite simple in the end then. Just changed love.load() to love.load(arg).
Don't know where arg is defined... but gonna go with what I think works..!

EDIT2: Thanks for the tip Nixola, fairly new to forums so still picking up ettiquete. Would happily delete the below but I think that's not allowed for a normal user.

Re: Debugging using ZeroBrane Studio

Posted: Sun Jun 18, 2017 4:05 pm
by randomnovice
(..and the reason for having a custom love.run() function was having this loop at the "base" level)

Re: Debugging using ZeroBrane Studio

Posted: Sun Jun 18, 2017 4:10 pm
by randomnovice
Okay, quite simple in the end then. Just changed love.load() to love.load(arg).

Don't know where arg is defined... but gonna go with what I think works..!

Re: Debugging using ZeroBrane Studio

Posted: Sun Jun 18, 2017 4:15 pm
by Nixola
Please, do not triple post like that. You can edit your own posts at any time.

Re: Debugging using ZeroBrane Studio

Posted: Mon Jun 19, 2017 2:05 pm
by easy82
Yeah, sorry I should have been more specific. :)

You're right, this is exaclty how I used debugging in ZeroBrane:
zorg wrote: Sun Jun 18, 2017 3:54 pm function love.load(arg)
if arg[#arg] == "-debug" then require("mobdebug").start() end
end
I did not have to alter love.run() though, I use the built-in one.
randomnovice wrote: Sun Jun 18, 2017 4:10 pm Okay, quite simple in the end then. Just changed love.load() to love.load(arg).

Don't know where arg is defined... but gonna go with what I think works..!
ZeroBrane will execute your program with "-debug" argument when you start debugging.