Skip to content

Commit

Permalink
wip: lua_ls stuff and found problems
Browse files Browse the repository at this point in the history
  • Loading branch information
Histalek committed Oct 16, 2023
1 parent 0270844 commit 7141215
Show file tree
Hide file tree
Showing 328 changed files with 12,595 additions and 10,537 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@ Temporary Items
todo.txt
addon.json
*.gma
.luarc.json

ttt2.jpg
29 changes: 29 additions & 0 deletions .luarc.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
"diagnostics.disable": [
"duplicate-set-field",
"unused-local",
"lowercase-global"
],
"diagnostics.globals": [
"GM",
"BaseClass",
"CLGAMEMODESUBMENU"
],
"format.enable": false,
"runtime.special": {
"include": "require",
"includeCS": "require"
},
"runtime.version": "Lua 5.1",
"runtime.nonstandardSymbol": [
"!",
"!=",
"&&",
"||",
"//",
"/**/",
"continue"
],
"workspace.checkThirdParty": false
}
39 changes: 14 additions & 25 deletions gamemodes/terrortown/entities/entities/base_ammo_ttt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
-- @desc Ammo override base
-- @section BaseAmmo

if SERVER then
AddCSLuaFile()
end
if SERVER then AddCSLuaFile() end

local util = util
local hook = hook
Expand All @@ -22,9 +20,7 @@ ENT.Model = Model("models/items/boxsrounds.mdl")
---
-- bw compat
-- @realm shared
function ENT:RealInit()

end
function ENT:RealInit() end

---
-- Some subclasses want to do stuff before/after initing (eg. setting color)
Expand Down Expand Up @@ -53,16 +49,12 @@ end
-- @return boolean
-- @realm shared
function ENT:PlayerCanPickup(ply)
if ply == self:GetOwner() then
return false
end
if ply == self:GetOwner() then return false end

---
-- @realm shared
local result = hook.Run("TTTCanPickupAmmo", ply, self)
if result then
return result
end
if result then return result end

local phys = self:GetPhysicsObject()
local spos = phys:IsValid() and phys:GetPos() or self:OBBCenter()
Expand All @@ -71,8 +63,8 @@ function ENT:PlayerCanPickup(ply)
local tr = util.TraceLine({
start = spos,
endpos = epos,
filter = {ply, self},
mask = MASK_SOLID
filter = { ply, self },
mask = MASK_SOLID,
})

-- can pickup if trace was not stopped
Expand All @@ -95,9 +87,7 @@ function ENT:CheckForWeapon(ply)
for i = 1, #weps do
local v = weps[i]

if v.AmmoEnt == cls then
tbl[#tbl + 1] = WEPSGetClass(v)
end
if v.AmmoEnt == cls then tbl[#tbl + 1] = WEPSGetClass(v) end
end

self.CachedWeapons = tbl
Expand All @@ -110,9 +100,7 @@ function ENT:CheckForWeapon(ply)
-- Touch, which is called many a time, so we use the cache here to avoid
-- looping through every weapon the player has to check their AmmoEnt.
for i = 1, #cached do
if plyHasWeapon(ply, cached[i]) then
return true
end
if plyHasWeapon(ply, cached[i]) then return true end
end

return false
Expand All @@ -123,13 +111,16 @@ end
-- @param Entity ply The touching entity that is probably a player
-- @realm shared
function ENT:Touch(ply)
if CLIENT
if
CLIENT
or self.tickRemoval
or not ply:IsValid()
or not ply:IsPlayer()
or not self:CheckForWeapon(ply)
or not self:PlayerCanPickup(ply)
then return end
then
return
end

local ammo = ply:GetAmmoCount(self.AmmoType)

Expand Down Expand Up @@ -174,7 +165,5 @@ if SERVER then
-- @return boolean Return false to cancel the pickup event
-- @hook
-- @realm server
function GAMEMODE:TTTCanPickupAmmo(ply, ent)

end
function GAMEMODE:TTTCanPickupAmmo(ply, ent) end
end
4 changes: 1 addition & 3 deletions gamemodes/terrortown/entities/entities/item_ammo_357_ttt.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
if SERVER then
AddCSLuaFile()
end
if SERVER then AddCSLuaFile() end

ENT.Type = "anim"
ENT.Base = "base_ammo_ttt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
if SERVER then
AddCSLuaFile()
end
if SERVER then AddCSLuaFile() end

ENT.Type = "anim"
ENT.Base = "base_ammo_ttt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
if SERVER then
AddCSLuaFile()
end
if SERVER then AddCSLuaFile() end

ENT.Type = "anim"
ENT.Base = "base_ammo_ttt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
if SERVER then
AddCSLuaFile()
end
if SERVER then AddCSLuaFile() end

ENT.Type = "anim"
ENT.Base = "base_ammo_ttt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
if SERVER then
AddCSLuaFile()
end
if SERVER then AddCSLuaFile() end

ENT.Type = "anim"
ENT.Base = "base_ammo_ttt"
Expand Down

0 comments on commit 7141215

Please sign in to comment.