Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fd9c99f
luapanda
SaloEater Jun 11, 2025
7d77953
revert luajit lib for luaext
SaloEater Jun 11, 2025
06f0165
fix script buffer names
SaloEater Jun 11, 2025
3ce9773
merge latest master
SaloEater Jun 11, 2025
f90c818
imgui menu (not working), debug error, debug reconnect on level chang…
SaloEater Jun 11, 2025
f0bd8f8
cleanup
SaloEater Jun 12, 2025
daddbc2
vscode config
SaloEater Jun 12, 2025
3a0cf10
readme
SaloEater Jun 12, 2025
8725007
use correct lua lib
SaloEater Jun 12, 2025
45437b5
cleanup
SaloEater Jun 12, 2025
c0aebfc
revert lua lib
SaloEater Jun 12, 2025
f43e194
readme
SaloEater Jun 12, 2025
31d0300
mention lua files in readme
SaloEater Jun 12, 2025
719d204
Actually, we don't need use_luajit_one define
SaloEater Jun 12, 2025
c80406c
restore code
SaloEater Jun 15, 2025
7534c82
add lua files to solution
SaloEater Jun 15, 2025
16b26bc
change pot to sep correctly
SaloEater Jun 15, 2025
3d0a60e
remove everything else except luapanda itself
SaloEater Jun 16, 2025
9c41016
finish cleaning up the code
SaloEater Jun 16, 2025
7318881
Update `gamedata` directory tree in VS solution
ProfLander Jun 18, 2025
089135f
put lua debug stuff behind `lua_debug 1` console command instead of -…
themrdemonized Jun 18, 2025
4913397
Merge branch 'luapanda' into lua-script-engine
SaloEater Jun 19, 2025
3e031c6
libs
SaloEater Jun 19, 2025
0b0cf88
move lua libraries to scripts
SaloEater Jun 19, 2025
581dfd5
fixes
SaloEater Jun 19, 2025
30634e8
reduce console command to argument
SaloEater Jun 19, 2025
f01e5f4
reduce console command to argument, continuation
SaloEater Jun 19, 2025
b4b31bb
Merge remote-tracking branch 'prof/lua-script-engine' into lua-script…
SaloEater Jun 19, 2025
968371c
fixes
SaloEater Jun 19, 2025
d3ba1e8
change command name
SaloEater Jun 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,16 @@ The original engine is used in S.T.A.L.K.E.R. Call of Pripyat game released by G
* The step of zoom adjustment is more precise. Also, it's possible to adjust the step of zoom with the console command zoom_step_count [1.0, 10.0], this option is also applicable to the binoculars.
* In the new version all implementations from fakelens.script have moved directly to the engine. fakelens.script remained as a layer between the engine and scopeRadii.script

* Debug scripts with VSCode and LuaPanda, made by IXRay Platform
* Add `-luapanda` arguments when launching your game
* To use it, you need to install VSCode and LuaPanda extension: https://marketplace.visualstudio.com/items?itemName=stuartwang.luapanda
* Open your `gamedata/scripts` folder in VSCode
* Copy `.vscode` folder from the archive into your `gamedata/scripts` folder: https://github.com/themrdemonized/xray-monolith/tree/all-in-one-vs2022-wpo/gamedata/scripts/.vscode
* Return to VSCode, go to `Run and Debug` section and start debugging or press F5 key
* Open in-game console with `~` key and type `run_string attach_debugger()`. If you do everything correctly and engine is working properly too, you will get an entry breakpoint at `global.lua` file in VSCode.
* You have to re-enable the debugger every time you start a new game or load a save, so you have to type `run_string attach_debugger()` in console again.
* Debugger is working dynamically, so you can add/remove files from your VSCode folder and it will automatically update the list of files available for debugging.

* All settings can be edited from the game options in "Modded Exes" tab
![image](http://puu.sh/JC40Y/9315119150.jpg)

Expand Down
19 changes: 19 additions & 0 deletions gamedata/scripts/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

{
"version": "0.2.0",
"configurations": [
{
"type": "lua",
"request": "launch",
"name": "LuaPanda",
"description": "IX-Ray Lua Debug",
"cwd": "${workspaceFolder}",
"luaFileExtension": "script",
"connectionPort": 8818,
"stopOnEntry": true,
"useCHook": true,
"autoPathMode": true,
"updateTips": true
}
]
}
5 changes: 5 additions & 0 deletions gamedata/scripts/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"Lua.diagnostics.disable": [
"undefined-global"
]
}
8 changes: 8 additions & 0 deletions gamedata/scripts/_g_patches.script
Original file line number Diff line number Diff line change
Expand Up @@ -666,3 +666,11 @@ _G.IsLauncher = function(o, c)
}
return c and launcher[c] or false
end

log = _G.log
_G.log = function(str)
log(str)
if DebuggerMode then
LuaPanda.printToVSCode(str,1,2)
end
end
3 changes: 3 additions & 0 deletions gamedata/scripts/boot/debug.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if string.find(command_line(), "-luapanda") then
require("luapanda")
end
3 changes: 3 additions & 0 deletions gamedata/scripts/boot/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ require("boot.paths")
-- Setup package.loaders machinery
require("boot.loader")

-- Setup luapanda
require("boot.debug")

-- Setup engine interface
require("boot.function_object")

Expand Down
4 changes: 3 additions & 1 deletion gamedata/scripts/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ _LUA_G = _G
--- Emplace an error-checked lua compiler with customizable environment
_LOADSTRING = loadstring
function loadstring(src, namespace_name, script_name)
print("* [lua] loading " .. namespace_name)
if namespace_name then
print("* [lua] loading " .. namespace_name)
end

local f, err = _LOADSTRING(src, namespace_name)
if not f then
Expand Down
44 changes: 44 additions & 0 deletions gamedata/scripts/packages/lib/luapanda/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
require("luapanda.lua_panda")
--// General
jit.opt.start(2)

string.gfind = string.gmatch
math.mod = math.fmod

--// LuaPandas
DebuggerMode = false

log('LuaPanda: Loading...')

function debug_jit_off()
if DebuggerMode then
if jit then jit.off() end
end
end

function debug_jit_on()
if DebuggerMode then
if jit then jit.on() end
end
end

function attach_debugger()
if DebuggerMode then
log('LuaPanda: Disabling jit...')
debug_jit_off()
log('LuaPanda: Reconnecting')
LuaPanda.reConnect()
log('LuaPanda: reconnected')
debug_jit_on()
log('LuaPanda: Started')
else
log('LuaPanda: Disabling jit...')
debug_jit_off()
log('LuaPanda: Connecting')
LuaPanda.start("127.0.0.1", 8818)
log('LuaPanda: Connected')
DebuggerMode = true
debug_jit_on()
log('LuaPanda: Started')
end
end
Loading