ZeroBrane Lua IDE Setup

From Pragma
Jump to: navigation, search


ZeroBrane Studio is a Lua IDE, which allows you to debug Lua code. You can set break-points, go through code step-by-step etc. You can watch an example of it in action here.
ZeroBrane also has an auto-complete feature:
Zerobrane autocomplete.gif

Initial Setup

To use ZeroBrane with Pragma, you have to follow these steps:

  • Download ZeroBrane Studio from and install it into a directory of your choice, then start it.
  • Select "Project/Project Directory/Choose..." from the ZeroBrane menu bar, and nagivate to your pragma installation, and select it. Do not choose a sub-directory, otherwise the debugger may not find some Lua-files.
  • Download the "SDK"-collection from the Pragma steam workshop: (You have to be logged in and you have to have Pragma in your steam library, otherwise the workshop won't be accessable.)
  • Start Pragma at least once after the SDK has been fully downloaded.
  • Copy all files and directories from "pragma/addons/dev_content_1548466564/ZeroBrane" to the ZeroBrane installation directory
  • Select "Edit/Preferences/Settings: System" from the menu bar in ZeroBrane, and add the following line to the end of the file:
include "pragma.lua"
  • Restart ZeroBrane after saving the file.
  • Select "Project/Lua Interpreter/Pragma" from the menu bar

With that, you should now be able to use the auto-complete feature. Setting up the debugger requires some additional steps.

Debugger Setup

  • Run "Project/Start Debugger Server" from the menu. You will have to do this every time after starting ZeroBrane and before starting a game in Pragma.
  • Add "-luaext" to the launch parameters of Pragma. Doing so should add a red "[D]" next to the version on the bottom right when starting Pragma.
  • Launch Pragma, but don't load a map yet.
  • Set the console variable "sh_lua_remote_debugging" to "1" if you want to debug serverside, or "2" if you want to debug clientside ("0" to disable debugging). You have to make this choice before loading a level.
  • Open a Lua-file. Any Lua-file will do, but it has to be contained somewhere in the Pragma installation. If you don't have at least 1 Lua file from the project opened, the debugger will not work.
  • Load a map. The "Output" window of ZeroBrane should say something along the lines of "Debugging session started", which means the programs are connected successfully. If so, Pragma should have paused in the background, and you should be able to see these icons in the menu bar of ZeroBrane:

Click on the second icon (Alternatively press F5) to resume Pragma.

  • You can now open up Lua-files in ZeroBrane and start Debugging!

Important: Make sure to remove the "-luaext" launch parameter after you've finished debugging! The parameter enables several Lua-modules which can be abused by malicious addons, or if you're playing on an untrusted server! These modules are required for remote debugging only!

ZeroBrane Highlighting

By default the pragma-configuration for ZeroBrane will highlight all global variables with a red background. The purpose of this is to make it easier to find spelling errors of local variables, however some users may find this undesirable. To disable the red background, open "cfg/pragma.lua" and comment or remove the following line:

styles.indicator.varglobal = {st = wxstc.wxSTC_INDIC_ROUNDBOX, fg = {255,100,100}}