+
Setting up the ZeroBrane Studio IDE
+
+ This article will explain how to set up ZeroBrane Studio, an IDE for writing Lua code, so that you can develop MCServer plugins with the comfort of an IDE.
+
+
About ZeroBrane Studio
+
+
To quickly introduce ZeroBrane Studio, it is an IDE for writing Lua code. It has the basic features expected of an IDE - it allows you to manage groups of files as a project, you can edit multiple files in a tabbed editor, the code is syntax-highlighted. Code completion, symbol browsing, and more. It also features a Lua debugger that allows you to debug your Lua code within any application that uses Lua and can load Lua packages. It is written using the multiplatform WxWidgets toolkit, and runs on multiple platforms, including Windows, Linux and MacOS.
+
Here's a screenshot of a default ZBS window with the debugger stepping through the code (scaled down):
+
+
As you can see, you can set breakpoints in the code, inspect variables' values, view the Lua call-stacks.
+
ZBS is open-source, the sources are on GitHub: https://github.com/pkulchenko/ZeroBraneStudio. The project's homepage is at http://studio.zerobrane.com/.
+
+
First-time setup
+
Since ZBS is a universal Lua IDE, you need to first set it up so that it is ready for MCS plugin development. For that, you need to download one file, mcserver.lua from the ZBS's plugin repository. Place that file in the "packages" folder inside your ZBS's folder. Note that there are other useful plugins in the repository and you may want to have a look there later on to further customize your ZBS. To install them, simply save them into the same folder.
+
After you download the mcserver.lua file, you need to restart ZBS in order for the plugin to load. If there are no errors, you should see two new items in the Project -> Lua Interpreter submenu: "MCServer - debug mode" and "MCServer - release mode". The only difference between the two is which filename they use to launch MCServer - mcserver_debug(.exe) for the debug option and "mcserver(.exe)" for the release option. If you built your own MCServer executable and you built it in debug mode, you should select the debug mode option. In all other cases, including if you downloaded the already-compiled MCServer executable from the internet, you should select the release mode option.
+
For a first time user, it might be a bit overwhelming that there are no GUI settings in the ZBS, yet the IDE is very configurable. There are two files that you edit in order to change settings, either system-wide (all users of the computer share those settings) or user-wide (the settings are only for a specific user of the computer). Those files are regular Lua sources and you can quickly locate them and edit them from within the IDE itself, select Edit -> Preferences -> Settings: XYZ from the menu, with XYZ being either System or User.
+
There is a documentation on most of the settings on ZBS's webpage, have a look at http://studio.zerobrane.com/documentation.html, especially the Preferences section. Personally I recommend setting editor.usetabs to true and possibly adjusting the editor.tabwidth, turn off the editor.smartindent feature and for debugging the option debugger.alloweditting should be set to true unless you feel like punishing yourself.
+
+
Project management
+
ZBS works with projects, it considers all files and subfolder in a specific folder to be a project. There's no need for a special project file nor for adding individual files to the workspace, all files are added automatically. To open a MCS plugin as the project, click the triple-dot button in the Project pane, or select Project -> Project directory -> Choose... from the menu. Browse and select the MCS plugin's folder. ZBS will load all the files in the plugin's folder and you can start editting code.
+
Note that although ZBS allows you to work with subfolders in your plugins (and you should, especially with larger plugins), the current mcserver ZBS plugin will not be able to start debugging unless you have a file open in the editor that is at the root level of the MCS plugin's folder.
+
+
Debugging
+
You are now ready to debug your code. Before doing that, though, don't forget to save your project files. If you haven't done so already, enable your plugin in the settings.ini file. If you want the program to break at a certain line, it is best to set the breakpoint before starting the program. Set the cursor on the line and hit F9 (or use menu Project -> Toggle Breakpoint) to toggle a breakpoint on that line. Finally, hit F5, or select menu Project -> Start Debugging to launch MCServer under the debugger. The MCServer window comes up and loads your plugin. If the window doesn't come up, inspect the Output pane in ZBS, there are usually two reasons for failure:
+ - Your code in the currently open file has a hard syntax error. These are reported as "Compilation error" in the Output pane, double-click the line to go to the error
+ - ZBS cannot find the MCServer executable. Make sure you are editting a file two levels down the folder hierarchy from the MCS executable and that the MCS executable is named properly (mcserver[.exe] or mcserver_debug[.exe]). Also make sure you have selected the right Interpreter (menu Project -> Lua Interpreter).
+
+
Once running, if the execution hits a breakpoint, the ZBS window will come up and a green arrow is displayed next to the breakpoint line. You can step through the code using F10 (Step Into) and Shift+F10 (Step Over). You can also use the Watch window to inspect variable values, or simply hover your mouse over a variable to display its value in the tooltip. Use the Remote console pane to execute commands directly *inside* the MCServer's plugin context.
+
You can also use the Project -> Break menu item to break into the debugger as soon as possible. You can also set breakpoints while the MCS plugin is running. Note that due to the way in which the debugger is implemented, MCS may execute some more Lua code before the break / breakpoint comes into effect. If MCS is not executing any Lua code in your plugin, it will not break until the plugin code kicks in again. This may result in missed breakpoints and delays before the Break command becomes effective. Therefore it's best to set breakpoints before running the program, or while the program is waiting in another breakpoint.
+
+
+
diff --git a/MCServer/Plugins/APIDump/Static/zbs_logo.png b/MCServer/Plugins/APIDump/Static/zbs_logo.png
new file mode 100644
index 000000000..c8d6d6278
Binary files /dev/null and b/MCServer/Plugins/APIDump/Static/zbs_logo.png differ
diff --git a/MCServer/Plugins/APIDump/Static/zbs_workspace.png b/MCServer/Plugins/APIDump/Static/zbs_workspace.png
new file mode 100644
index 000000000..9ce17e35a
Binary files /dev/null and b/MCServer/Plugins/APIDump/Static/zbs_workspace.png differ
--
cgit v1.2.3
From f38a009b3cc5caf25d11496fda5caf75531127d0 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Mon, 31 Mar 2014 18:25:00 +0200
Subject: APIDump: Renamed the ZBS API dump file to mcserver_api.lua.
This is to avoid confusion with ZBS, where two "mcserver.lua" files were present.
---
MCServer/Plugins/APIDump/main_APIDump.lua | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'MCServer')
diff --git a/MCServer/Plugins/APIDump/main_APIDump.lua b/MCServer/Plugins/APIDump/main_APIDump.lua
index 7455c3cd2..52199740b 100644
--- a/MCServer/Plugins/APIDump/main_APIDump.lua
+++ b/MCServer/Plugins/APIDump/main_APIDump.lua
@@ -1408,9 +1408,9 @@ end
--- Dumps the entire API table into a file in the ZBS format
local function DumpAPIZBS(a_API)
LOG("Dumping ZBS API description...")
- local f, err = io.open("mcserver.lua", "w")
+ local f, err = io.open("mcserver_api.lua", "w")
if (f == nil) then
- LOG("Cannot open mcserver.lua for writing, ZBS API will not be dumped. " .. err)
+ LOG("Cannot open mcserver_lua.lua for writing, ZBS API will not be dumped. " .. err)
return
end
--
cgit v1.2.3
From 55d0db1606f947c1b232e6329345fe7493805dcc Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Mon, 31 Mar 2014 18:34:27 +0200
Subject: APIDump: Added code completion support file to ZBS tutorial.
---
MCServer/Plugins/APIDump/SettingUpZeroBrane.html | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'MCServer')
diff --git a/MCServer/Plugins/APIDump/SettingUpZeroBrane.html b/MCServer/Plugins/APIDump/SettingUpZeroBrane.html
index 0fb89e49d..4ebbcb6e6 100644
--- a/MCServer/Plugins/APIDump/SettingUpZeroBrane.html
+++ b/MCServer/Plugins/APIDump/SettingUpZeroBrane.html
@@ -25,7 +25,8 @@
First-time setup
Since ZBS is a universal Lua IDE, you need to first set it up so that it is ready for MCS plugin development. For that, you need to download one file, mcserver.lua from the ZBS's plugin repository. Place that file in the "packages" folder inside your ZBS's folder. Note that there are other useful plugins in the repository and you may want to have a look there later on to further customize your ZBS. To install them, simply save them into the same folder.
- After you download the mcserver.lua file, you need to restart ZBS in order for the plugin to load. If there are no errors, you should see two new items in the Project -> Lua Interpreter submenu: "MCServer - debug mode" and "MCServer - release mode". The only difference between the two is which filename they use to launch MCServer - mcserver_debug(.exe) for the debug option and "mcserver(.exe)" for the release option. If you built your own MCServer executable and you built it in debug mode, you should select the debug mode option. In all other cases, including if you downloaded the already-compiled MCServer executable from the internet, you should select the release mode option.
+ Next you should install the code-completion support specific for MCServer. You should repeat this step from time to time, because the API evolves in time so new functions and classes are added to it quite often. You should have an APIDump plugin in your MCServer installation. Enable the APIDump plugin in the server settings, it's very cheap to keep it enabled and it doesn't cost any performance during normal gameplay. To generate the code-completion support file, enter the api
command into the server console. This will create a new file, "mcserver_api.lua", next to the MCS executable. Move that file into the "api/lua" subfolder inside your ZBS's folder.
+ After you download the mcserver.lua file and install the completion support, you need to restart ZBS in order for the plugin to load. If there are no errors, you should see two new items in the Project -> Lua Interpreter submenu: "MCServer - debug mode" and "MCServer - release mode". The only difference between the two is which filename they use to launch MCServer - mcserver_debug(.exe) for the debug option and "mcserver(.exe)" for the release option. If you built your own MCServer executable and you built it in debug mode, you should select the debug mode option. In all other cases, including if you downloaded the already-compiled MCServer executable from the internet, you should select the release mode option.
For a first time user, it might be a bit overwhelming that there are no GUI settings in the ZBS, yet the IDE is very configurable. There are two files that you edit in order to change settings, either system-wide (all users of the computer share those settings) or user-wide (the settings are only for a specific user of the computer). Those files are regular Lua sources and you can quickly locate them and edit them from within the IDE itself, select Edit -> Preferences -> Settings: XYZ from the menu, with XYZ being either System or User.
There is a documentation on most of the settings on ZBS's webpage, have a look at http://studio.zerobrane.com/documentation.html, especially the Preferences section. Personally I recommend setting editor.usetabs to true and possibly adjusting the editor.tabwidth, turn off the editor.smartindent feature and for debugging the option debugger.alloweditting should be set to true unless you feel like punishing yourself.
--
cgit v1.2.3
From f7df8e133b66aafcf35f0590a0ac525a7d2f9278 Mon Sep 17 00:00:00 2001
From: STRWarrior
Date: Mon, 31 Mar 2014 19:58:19 +0200
Subject: Documented msDifference
---
MCServer/Plugins/APIDump/APIDesc.lua | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
(limited to 'MCServer')
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index 6f8a14421..532b4b665 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -230,22 +230,22 @@ g_APIDesc =
- area block | result |
+ area block | result |
- this | Src | msOverwrite | msFillAir | msImprint |
+ this | Src | msOverwrite | msFillAir | msImprint | msDifference |
- air | air | air | air | air |
+ air | air | air | air | air | air |
- A | air | air | A | A |
+ A | air | air | A | A | air |
- air | B | B | B | B |
+ air | B | B | B | B | B |
- A | B | B | A | B |
+ A | B | B | A | B | B |
@@ -255,6 +255,8 @@ g_APIDesc =
msOverwrite completely overwrites all blocks with the Src's blocks
msFillAir overwrites only those blocks that were air
msImprint overwrites with only those blocks that are non-air
+ msSpongePrint Sponge overwrites nothing, everything else overwrites anything
+ msDifference changes all the blocks wich are the same to air. Otherwise the source block gets placed.
--
cgit v1.2.3
From a8bc27f8728a0c1f222871cbd3f5534646e59085 Mon Sep 17 00:00:00 2001
From: STRWarrior
Date: Mon, 31 Mar 2014 20:05:48 +0200
Subject: Fixed typo
---
MCServer/Plugins/APIDump/APIDesc.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'MCServer')
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index 532b4b665..1b020501c 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -256,7 +256,7 @@ g_APIDesc =
msFillAir overwrites only those blocks that were air
msImprint overwrites with only those blocks that are non-air
msSpongePrint Sponge overwrites nothing, everything else overwrites anything
- msDifference changes all the blocks wich are the same to air. Otherwise the source block gets placed.
+ msDifference changes all the blocks which are the same to air. Otherwise the source block gets placed.
--
cgit v1.2.3
From b19022fc7ea4cb6bd1bc6f4b212478e65b5fa5a1 Mon Sep 17 00:00:00 2001
From: STRWarrior
Date: Mon, 31 Mar 2014 20:13:08 +0200
Subject: Added extra table which should make it more clear what msDifference
does.
---
MCServer/Plugins/APIDump/APIDesc.lua | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
(limited to 'MCServer')
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index 1b020501c..657ac6aa6 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -247,6 +247,9 @@ g_APIDesc =
A | B | B | A | B | B |
+
+ A | A | A | A | B | air |
+