User Tools

Site Tools


debugging-mods

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
debugging-mods [2021/10/22 10:00] – external edit 127.0.0.1debugging-mods [2021/10/24 12:25] maxime
Line 7: Line 7:
 The first step in debugging a mod is to setup the chosen debugger in the VM. This cannot be done by the mod scripts themselves as it requires escaping the sandbox they operate in; the required setup must be placed in a special ''moddev'' folder in the game's user files ''(%USERPROFILE%\Documents\Polymorph Games\Foundation)''. The first step in debugging a mod is to setup the chosen debugger in the VM. This cannot be done by the mod scripts themselves as it requires escaping the sandbox they operate in; the required setup must be placed in a special ''moddev'' folder in the game's user files ''(%USERPROFILE%\Documents\Polymorph Games\Foundation)''.
  
-When the game starts and creates the lua VM, all scripts in this folder are loaded without any of the restrictions imposed on regular mod files. While this allows changing the lua environment to make mod development easier (such as by inserting a debugger), it also allows potentially unsafe scripts to run. **Mods should not require files in this folder in order to run properly.**+When the game starts and creates the lua VM, all scripts in this folder are loaded without any of the restrictions imposed on regular mod files. While this allows changing the lua environment to make mod development easier (such as by inserting a debugger), it also allows potentially unsafe scripts to run. **Mods should not use this folder for anything other than debugging, and should not require files in this folder in order to run properly.**
  
 ===== Visual Studio Code ===== ===== Visual Studio Code =====
Line 13: Line 13:
 Debugging mods in Visual Studio Code can be done with the [[https://marketplace.visualstudio.com/items?itemName=tomblind.local-lua-debugger-vscode|Local Lua Debugger]] extension. A minimal debuggee script to enable communication with the game instance is shown below. Debugging mods in Visual Studio Code can be done with the [[https://marketplace.visualstudio.com/items?itemName=tomblind.local-lua-debugger-vscode|Local Lua Debugger]] extension. A minimal debuggee script to enable communication with the game instance is shown below.
  
-<file lua>+<file lua vs_code_debug.lua>
 require("lldebugger").start() require("lldebugger").start()
 </file> </file>
Line 42: Line 42:
 While ZeroBrane Studio includes a version of luasocket, the IDE (and the libraries it includes) is only provided in 32-bit. Thus, a 64-bit version of the DLL is provided with the Foundation installation, to be able to connect to the debugger server. In addition, the lua environment has to be configured with a short debuggee script. While ZeroBrane Studio includes a version of luasocket, the IDE (and the libraries it includes) is only provided in 32-bit. Thus, a 64-bit version of the DLL is provided with the Foundation installation, to be able to connect to the debugger server. In addition, the lua environment has to be configured with a short debuggee script.
  
-<file lua>+<file lua zbs_debug.lua>
 local zbs = "<path/to/zerobrane>" local zbs = "<path/to/zerobrane>"
 package.path = package.path .. ";" .. zbs .. "/lualibs/?/?.lua;" .. zbs .. "/lualibs/?.lua" package.path = package.path .. ";" .. zbs .. "/lualibs/?/?.lua;" .. zbs .. "/lualibs/?.lua"
-package.cpath = package.cpath .. ";mods/libs/?.dll" -- DLL is in the folder [Foundation installation]/mods/libs/socket+package.cpath = package.cpath .. ";mods/libs/?.dll" -- DLL is in the folder <path/to/foundation.exe>/mods/libs/socket
 require("mobdebug").start() require("mobdebug").start()
 </file> </file>
debugging-mods.txt · Last modified: 2021/10/25 13:00 by maxime

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki