Strategy
After failing to make WhoLib functioning, I decided to write comments for it. Also format it first to make it easier to read. Hope this strategy helps me to understand the underlying logic of it.
Also settled down the intellisense which can offer good assistance.
I'm not sure if there is anyone who encountered the similar problem with me: when using LibStub to load libraries, the vscode plugin Lua Language Server won't recognize the loaded lib.
I made a trick for this, by introducing a library which sets a global variable with the value always being false. We can use it to link the relationship between libraries.
For example:
-- LibGlobalTrick.lua
ExposeGlobal = false
-- Lib_A.lua
local lib = LibStub:NewLibrary("Lib_A", 1)
if ExposeGlobal then
Lib_A = lib
end
-- Lib_B.lua
local lib_a
if ExposeGlobal then
lib_a = Lib_A
else
lib_a = LibStub:GetLibrary("Lib_A")
end
After this linking, Lua Language Server is able to recognize lib_a in Lib_B.lua.
留言
張貼留言