Author Topic: Debugging themes/modules/plugins  (Read 4476 times)

millercentral

  • Jr. Member
  • **
  • Posts: 13
    • View Profile
Debugging themes/modules/plugins
« on: December 14, 2016, 07:08:27 PM »
What is everybody's approach to script debugging? Is printing to the console the only option?

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: Debugging themes/modules/plugins
« Reply #1 on: December 15, 2016, 07:37:52 PM »
for error messages, yes... you can make a simple shortcut function to ease the \n pain:
Code: [Select]
function debug(msg) {
    ::print(msg + "\n")
}
debug("Here is one line")
debug("Here is another")

you can also add debug objects if you want something onscreen :)

Try this:
Code: [Select]
class Debugger
{
    obj = null
    reload_key = "custom1"
    constructor() {
         obj = ::fe.add_text("", 0, fe.layout.height - 40, fe.layout.width, 30)
         obj.set_rgb(200, 200, 0)
         ::fe.add_signal_handler(this, "on_signal")
    }
    function msg(msg) {
      obj.msg = msg
    }
    function on_signal(str) {
        if ( str == reload_key ) ::fe.signal("reload")
    }
}

local myText = fe.add_text("[Title]", 50, 50, 300, 30)
local debugger = Debugger()
debugger.msg("myText loc = x:" + myText.x + " y:" + myText.y + " w: " + myText.width + " h:" + myText.height)