Closed J-Shep closed 9 years ago
Sounds great J-Shep.
Does this depend on #342
Does this depend on #342
No, except that I wouldn't include the Lua debugger in the default CorsixTH perspective until it could be used with CorsixTH's Lua code at runtime.
I want to get #342 done and I want to make Eclipse recognise CorsixTH class functions before I start working on making a Eclipse Lua debugger work with CorsixTH. Or someone else could start working on this enhancement while I work on making Eclipse recognise CorsixTH Lua classes.
@droidmonkey Hi, when you have time please help us by posting a message in this discussion with an explanation of how GE:S mode scripts can be controlled by PyDev's Python debugger.
...I wouldn't include the Lua debugger in the default CorsixTH perspective until it could be used with CorsixTH's Lua code at runtime.
Actually I will just include it even if CorsixTH isn't ready to be used with it.
python debugging through pydev is rather simple. I incorporated the pydev debugging script into the python code and when you enter the command in the terminal to initiate the debugging it simply calls the function in that pydev code that connects to the waiting listen server.
python debugging through pydev is rather simple. I incorporated the pydev debugging script into the python code and when you enter the command in the terminal to initiate the debugging it simply calls the function in that pydev code that connects to the waiting listen server.
@droidmonkey Thanks for explaining how this works.
Take a look here (C++): https://github.com/goldeneye-source/ges-code/blob/ges/game/server/ges/py/ge_pymanager.cpp#L235
And here (Python): https://github.com/goldeneye-source/ges-python/blob/master/lib/ge_debugger.py#L19
@droidmonkey Thanks I will.
I would be willing to have a go at implementing this in the near future...
So someone else could work on this way/another way of making a Lua debugger for CorsixTH because the sooner CorsixTH has a Lua debugger the sooner it can reduce the time developers have to spend debugging problems.
The Lua Development Tools plugin's debugger could be attached to CorsixTH:
Attach Debug You want to monitor an application running in a specific context that makes it impossible to be launched by LDT (for instance a Lua VM embedded in a larger C/C++ application). In that case, your application can connect to the IDE at startup and then be monitored.
This way of debugging is called attached debug, uses DBGp and is composed of two parties.
- DBGp Server: In our case it is LDT waiting for an application to connect.
- DBGp Client: In our case, it is the debugger.lua file executed in your debugged application which sends information about its run to LDT.
This way is more flexible, but you are on your own to manage the whole runtime configuration (LUA_PATH, debugger bootstrap, ...).
See this wiki page for instructions: https://wiki.eclipse.org/Koneki/LDT/Developer_Area/User_Guides/User_Guide_1.2#Attach_Debug
I will try to get this debugger working with CorsixTH asap.
CorsixTH's Lua scripts can already be debugged with the Decoda Lua IDE's debugger (I've not tried using it):
CorsixTH.lua:
-- If being debugged in Decoda, turn off JIT compilation (as it cannot debug
-- machine code). Note that this file cannot be debugged, but all other files
-- can be. See http://www.unknownworlds.com/decoda/ for Decoda info.
if decoda_output then
_DECODA = true
if jit then
jit.off()
decoda_output "JIT compilation disabled"
end
else
_DECODA = false
end
I will try to make the Eclipse LDT plugin's debugger work with CorsixTH because I personally think Eclipse will be a better IDE than Decoda for CorsixTH Lua scripting once it can outline class methods (#417) and can debug CorsixTH Lua scripts at runtime.
I will now make this my priority CorsixTH programming task and when it's finished I intend to resume my work on trying to design & then implement a LAN multiplayer system (#386).
I've almost finished working on this.
When I run my PC's Lua interpreter with the Windows command prompt it finds the LuaSocket module but when CorsixTH runs it doesn't.
With the command line I run debug_script.lua with this command:
lua debug_script.lua
debug_script.lua:
local success, socket = pcall(require, "socket")
if not success then
-- LuaSocket is not available, just return
print "LuaSocket is not available."
return
else
print "FOUND"
end
My LUA_PATH:
C:\Program Files (x86)\Lua\5.1\lua\?.luac;C:\Program Files (x86)\Lua\5.1\lua\?.lua
socket.lua is in:
C:\Program Files (x86)\Lua\5.1\lua\
What do you see in your package.path from within CorsixTH?
@TheCycoONE The paths are the same.
@TheCycoONE I will try to fix this problem by reinstalling everything tomorrow.
Oh, lua sockets is a dll, so it would use package.cpath, you could check that. Other than that I don't know.
Oh, lua sockets is a dll, so it would use package.cpath, you could check that. Other than that I don't know.
@TheCycoONE Thanks : the problem was that my PC didn't have a LUA_CPATH environment variable and instead of using the default CPATH CorsixTH was using a different path which was missing the directory containing the required "core.dll".
I have Eclipse debugging CorsixTH's Lua scripts at runtime :)
I will submit a very simple pull request later: connecting CorsixTH's runtime interpreter to the LDT plugin's DBGp server simply requires this statement to be executed for debugger.lua:
dofile('debugger')()
I'm sorry I didn't make a pull request with this simple change days/a week ago because I only started working on this enhancement properly yesterday. If this had been merged days/a week ago developers debugging 0.40 blocking problems could have been using Eclipse's debugger to help them quickly find and fix problems.
Although this is an enhancement and not a bug fix, I personally think this simple enhancement should be merged with 0.40 to help debug it before and after its released.
Since developers usually run on latest and can easily add that line themselves anyway there is no reason to delay 0.4 further to get it in imo.
0.40 should be released on Monday, if this had come in earlier (in the beta phase) I would have agreed. Now I hope it helps make 0.50 the most bug free version yet. :+1:
I would be willing to have a go at implementing this in the near future, though I currently don't know how to implement this. I know of two Eclipse plugins which add support for Lua scripting and the "Lua Development Tools" plugin I use implements a Lua debugger.
I've scripted a gameplay mode for an open source game called "Goldeneye:Source" which allows the execution of its Python mode scripts to be controlled by the Eclipse Python debugger provided by Eclipse's PyDev plugin.
I could find out how this game's developers have implemented runtime support for debugging scripts with Eclipse.