I want to link my IDE vs code to the project Zomboid game for writing mods, and help with autocomplete and syntax highlighting.
Turning to the Internet , I was advised to download Lua Language Server , create a file called setup lua in the root of the game . With such content
package.path = package.path .. ";./media/lua/?.lua;./media/lua/?/init.lua"
package.cpath = package.cpath .. ";./clibs/?.dll;./clibs/?.so"
dofile("C:/Program Files (x86)/Steam/steamapps/common/ProjectZomboid/mods/Fractions/media/lua/client/ISUI/FractionUserPanelUI.lua")
require "ISUI/ISPanel"
require "ISUI/ISButton"
require "ISUI/ISComboBox"
require "ISUI/ISCollapsableWindow"
require "ISUI/ISPanelJoypad"
require "ISUI/ISLabel"
require "ISUI/ISContextMenu"
require "ISUI/getPlayerHud"
require "ISUI/Events"
require "ISUI/getFileReader"
require "ISUI/getCore"
require "ISUI/UIFont"
require "ISUI/UIManager"
require "ISUI/getPlayer"
require "ISUI/ISInventoryPaneContextMenu"
require "ISUI/getTextManager"
And in the very fashion to make a binding
dofile "C:/Program Files(x86)/Steam/steamapps/common/ProjectZomboid/setup.lua"
Unfortunately, this does not work, and I found another way out, it is to create a folder in the project with the name.vs code and the settings file.json with such content:
"files.encoding": "windows1251",
"files.autoGuessEncoding": true,
"Lua.workspace.library": {
"./lua": true
},
"Lua.workspace.libraryWithSubmodules": {
"./mods": {
"module1": true,
"module2": true,
"module3": true
},
"./lua": true
},
"Lua.diagnostics.globals": [
"getWorld"
]
}
It doesn't help either, what could be the problem?
You have to find out how to handle /
or \
depending on the OS the Interpreter runs.
For example, a single Backslash inside double Quotes producing an Escape Sequence Error and therefore it has to be escaped with another Backslash.
Like...
wpath = "C:\\Temp\\Lua"
Single Backslash (and Whitespace like Space) is possible with...
wpath = [[C:\Temp\Lua]]
Also i like to wrote: Use .
instead of /
or \
in require()
require "ISUI.ISPanel"
That should work OS independently.