Mitigate some issues with reserved words (#3236)

* Add entity:getClass

* Remove some common reserved words

* lint
This commit is contained in:
Denneisk 2025-01-06 13:43:28 +00:00 committed by GitHub
parent c4d0ca9855
commit 4262b11969
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View File

@ -474,7 +474,7 @@ else
function E2Lib.isOwner(self, entity) function E2Lib.isOwner(self, entity)
local owner = E2Lib.getOwner(self, entity) local owner = E2Lib.getOwner(self, entity)
if not IsValid(owner) then return false end if not IsValid(owner) then return false end
return E2Lib.isFriend(owner, self.player) return E2Lib.isFriend(owner, self.player)
end end
end end
@ -676,9 +676,7 @@ E2Lib.ReservedWord = {
["in"] = true, ["in"] = true,
instanceof = true, instanceof = true,
interface = true, interface = true,
match = true,
macro = true, macro = true,
mod = true,
module = true, module = true,
mut = true, mut = true,
namespace = true, namespace = true,
@ -701,7 +699,6 @@ E2Lib.ReservedWord = {
typeof = true, typeof = true,
undefined = true, undefined = true,
union = true, union = true,
use = true,
yield = true, yield = true,
var = true, var = true,
} }

View File

@ -104,11 +104,15 @@ e2function string entity:name()
return this:GetName() or "" return this:GetName() or ""
end end
e2function string entity:type() [nodiscard]
e2function string entity:getClass()
if not IsValid(this) then return self:throw("Invalid entity!", "") end if not IsValid(this) then return self:throw("Invalid entity!", "") end
return this:GetClass() return this:GetClass()
end end
[deprecated = "Use getClass"]
e2function string entity:type() = e2function string entity:getClass()
e2function string entity:model() e2function string entity:model()
if not IsValid(this) then return self:throw("Invalid entity!", "") end if not IsValid(this) then return self:throw("Invalid entity!", "") end
return this:GetModel() or "" return this:GetModel() or ""