diff --git a/.gitignore b/.gitignore index 839d15c012..cf05f7ee95 100644 --- a/.gitignore +++ b/.gitignore @@ -55,5 +55,6 @@ Temporary Items todo.txt addon.json *.gma +.luarc.json ttt2.jpg diff --git a/.luarc.json.example b/.luarc.json.example new file mode 100644 index 0000000000..a2e6f2da2a --- /dev/null +++ b/.luarc.json.example @@ -0,0 +1,31 @@ +{ + "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", + "diagnostics.disable": [ + "duplicate-set-field", + "unused-local", + "lowercase-global" + ], + "diagnostics.globals": [ + "GM", + "TRAITOR", + "DETECTIVE", + "BaseClass", + "CLGAMEMODESUBMENU" + ], + "format.enable": false, + "runtime.special": { + "include": "require", + "includeCS": "require" + }, + "runtime.version": "Lua 5.1", + "runtime.nonstandardSymbol": [ + "!", + "!=", + "&&", + "||", + "//", + "/**/", + "continue" + ], + "workspace.checkThirdParty": false +} diff --git a/gamemodes/terrortown/entities/entities/ttt_c4/shared.lua b/gamemodes/terrortown/entities/entities/ttt_c4/shared.lua index 0f8635fdf9..f485d39836 100644 --- a/gamemodes/terrortown/entities/entities/ttt_c4/shared.lua +++ b/gamemodes/terrortown/entities/entities/ttt_c4/shared.lua @@ -76,12 +76,12 @@ AccessorFunc(ENT, "timer_length", "TimerLength", FORCE_NUMBER) --- -- @accessor number -- @realm shared -AccessorFuncDT(ENT, "explode_time", "ExplodeTime") +AccessorFunc(ENT, "explode_time", "ExplodeTime", FORCE_NUMBER) --- -- @accessor boolean -- @realm shared -AccessorFuncDT(ENT, "armed", "Armed", FORCE_BOOL) +AccessorFunc(ENT, "armed", "Armed", FORCE_BOOL) ENT.timeBeep = 0 ENT.safeWires = nil diff --git a/gamemodes/terrortown/entities/entities/ttt_health_station.lua b/gamemodes/terrortown/entities/entities/ttt_health_station.lua index 5a8b4af02d..388ca2af31 100644 --- a/gamemodes/terrortown/entities/entities/ttt_health_station.lua +++ b/gamemodes/terrortown/entities/entities/ttt_health_station.lua @@ -28,7 +28,7 @@ ENT.HealFreq = 0.2 --- -- @accessor number -- @realm shared -AccessorFuncDT(ENT, "StoredHealth", "StoredHealth") +AccessorFunc(ENT, "StoredHealth", "StoredHealth", FORCE_NUMBER) --- -- @accessor Player diff --git a/gamemodes/terrortown/gamemode/shared/sh_door.lua b/gamemodes/terrortown/gamemode/shared/sh_door.lua index 4234c0613d..0bd68bbf5f 100644 --- a/gamemodes/terrortown/gamemode/shared/sh_door.lua +++ b/gamemodes/terrortown/gamemode/shared/sh_door.lua @@ -18,7 +18,7 @@ local function GetDataString(ply, data) dataTable[#dataTable + 1] = data end - return string.Implode("||", dataTable) + return table.concat(dataTable, "||") end --- diff --git a/gamemodes/terrortown/gamemode/shared/sh_equip_items.lua b/gamemodes/terrortown/gamemode/shared/sh_equip_items.lua index 82d1cb4c2b..702b1660a6 100644 --- a/gamemodes/terrortown/gamemode/shared/sh_equip_items.lua +++ b/gamemodes/terrortown/gamemode/shared/sh_equip_items.lua @@ -577,7 +577,7 @@ if SERVER then end, "ttt2changeshops") cvars.AddChangeCallback("ttt2_random_shop_items", function(name, old, new) - local tmp = tonumber(new) + local tmp = tonumber(new, 10) SetGlobalInt("ttt2_random_shop_items", tmp) @@ -601,7 +601,7 @@ if SERVER then end, "ttt2updatererollglobal") cvars.AddChangeCallback("ttt2_random_shop_reroll_cost", function(name, old, new) - SetGlobalInt("ttt2_random_shop_reroll_cost", tonumber(new)) + SetGlobalInt("ttt2_random_shop_reroll_cost", tonumber(new, 10)) end, "ttt2updatererollcostglobal") cvars.AddChangeCallback("ttt2_random_shop_reroll_per_buy", function(name, old, new) @@ -759,6 +759,7 @@ end -- @internal -- @realm shared function InitFallbackShops() + -- TODO do we really not use TEAM_* or ROLE_* for the shops? local tbl = {TRAITOR, DETECTIVE} for i = 1, #tbl do @@ -857,7 +858,7 @@ end -- @realm shared -- @local local function ValueToKey(tbl) - local tmp = tmp or {} + local tmp = {} for key, value in pairs(tbl) do tmp[value] = value @@ -890,6 +891,7 @@ end -- @realm shared function InitDefaultEquipment(eq) CleanUpDefaultCanBuyIndices(eq) + -- TODO same as above InitDefaultEquipmentForRole(TRAITOR, eq) InitDefaultEquipmentForRole(DETECTIVE, eq) end @@ -967,6 +969,7 @@ end -- @realm shared function ResetDefaultEquipment(eq) CleanUpDefaultCanBuyIndices(eq) + -- TODO same as above ResetDefaultEquipmentForRole(TRAITOR, eq) ResetDefaultEquipmentForRole(DETECTIVE, eq) end diff --git a/gamemodes/terrortown/gamemode/shared/sh_init.lua b/gamemodes/terrortown/gamemode/shared/sh_init.lua index b5fa6c803e..7a97217561 100644 --- a/gamemodes/terrortown/gamemode/shared/sh_init.lua +++ b/gamemodes/terrortown/gamemode/shared/sh_init.lua @@ -426,8 +426,8 @@ if CLIENT then if not tbl or #tbl < 2 then return end local _func = function(adata, bdata) - a = adata.id - b = bdata.id + local a = adata.id + local b = bdata.id if tonumber(a) and not tonumber(b) then return true diff --git a/gamemodes/terrortown/gamemode/shared/sh_rolelayering.lua b/gamemodes/terrortown/gamemode/shared/sh_rolelayering.lua index 4268efd37c..b13f73795d 100644 --- a/gamemodes/terrortown/gamemode/shared/sh_rolelayering.lua +++ b/gamemodes/terrortown/gamemode/shared/sh_rolelayering.lua @@ -165,7 +165,7 @@ if CLIENT then -- @realm client function rolelayering.RequestDataFromServer(role) net.Start("TTT2SyncRolelayerData") - net.WriteBit(0) -- Request data = 0, Send data = 1 + net.WriteBit(false) -- Request data = false, Send data = true net.WriteUInt(role or ROLE_NONE, ROLE_BITS) net.SendToServer() end @@ -180,7 +180,7 @@ if CLIENT then -- @realm client function rolelayering.SendDataToServer(role, layers) net.Start("TTT2SyncRolelayerData") - net.WriteBit(1) -- Request data = 0, Send data = 1 + net.WriteBit(true) -- Request data = false, Send data = true net.WriteUInt(role or ROLE_NONE, ROLE_BITS) diff --git a/lua/ttt2/libraries/none.lua b/lua/ttt2/libraries/none.lua index 3855779549..e24623eb99 100644 --- a/lua/ttt2/libraries/none.lua +++ b/lua/ttt2/libraries/none.lua @@ -22,23 +22,6 @@ function clr(color) return color.r, color.g, color.b, color.a end ---- --- This @{function} creates a getter and a setter @{function} based on the name and the prefix "Get" and "Set" --- @param table tbl the @{table} that should receive the Getter and Setter @{function} --- @param string varname the name the tbl @{table} should have as key value --- @param string name the name that should be concatenated to the prefix "Get" and "Set" --- @realm shared -function AccessorFuncDT(tbl, varname, name) - tbl["Get" .. name] = function(s) - return s.dt and s.dt[varname] - end - - tbl["Set" .. name] = function(s, v) - if s.dt then - s.dt[varname] = v - end - end -end --- -- Short helper for input.LookupBinding, returns capitalised key or a default