Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New is* E2 functions #3220

Merged
merged 3 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions lua/entities/gmod_wire_expression2/core/entity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,16 @@ e2function number entity:isNPC()
if this:IsNPC() then return 1 else return 0 end
end

e2function number entity:isNextBot()
if not IsValid(this) then return self:throw("Invalid entity!", 0) end
if this:IsNextBot() then return 1 else return 0 end
end

e2function number entity:isRagdoll()
if not IsValid(this) then return self:throw("Invalid entity!", 0) end
if this:IsRagdoll() then return 1 else return 0 end
end

e2function number entity:isVehicle()
if not IsValid(this) then return self:throw("Invalid entity!", 0) end
if this:IsVehicle() then return 1 else return 0 end
Expand Down Expand Up @@ -587,6 +597,18 @@ e2function number entity:isAsleep()
if phys:IsAsleep() then return 1 else return 0 end
end

e2function number entity:isGravityEnabled()
if not validPhysics(this) then return self:throw("Invalid entity!", 0) end
local phys = this:GetPhysicsObject()
if phys:IsGravityEnabled() then return 1 else return 0 end
end

e2function number entity:isPenetrating()
if not validPhysics(this) then return self:throw("Invalid entity!", 0) end
local phys = this:GetPhysicsObject()
if phys:IsPenetrating() then return 1 else return 0 end
end

--[[******************************************************************************]]

__e2setcost(30) -- temporary
Expand Down
12 changes: 12 additions & 0 deletions lua/entities/gmod_wire_expression2/core/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,18 @@
return this:FlashlightIsOn() and 1 or 0
end

e2function number entity:isSpeaking()
if not IsValid(this) then return self:throw("Invalid entity!", 0) end
if not this:IsPlayer() then return self:throw("Expected a Player but got Entity", 0) end
return this:IsSpeaking() and 1 or 0
end

e2function number entity:isBot()
if not IsValid(this) then return self:throw("Invalid entity!", 0) end
if not this:IsPlayer() then return self:throw("Expected a Player but got Entity", 0) end
return this:IsBot() and 1 or 0
end

--------------------------------------------------------------------------------

e2function number entity:frags()
Expand Down Expand Up @@ -543,7 +555,7 @@

else

e2function array entity:friends()

Check warning on line 558 in lua/entities/gmod_wire_expression2/core/player.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: this
return {}
end

Expand Down
6 changes: 1 addition & 5 deletions lua/entities/gmod_wire_expression2/core/weapon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ end
e2function array entity:weapons()
if not IsValid(this) then return {} end
if not this:IsPlayer() then return {} end
local ret = {}
for k,v in pairs(this:GetWeapons()) do
ret[#ret + 1] = v
end
return ret
return this:GetWeapons()
end

[nodiscard]
Expand Down
7 changes: 7 additions & 0 deletions lua/wire/client/e2descriptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,12 @@ E2Helper.Descriptions["isPlayer(e:)"] = "Is the entity a player?"
E2Helper.Descriptions["isOnFire(e:)"] = "Is the entity on fire?"
E2Helper.Descriptions["isWeapon(e:)"] = "Is the entity a weapon?"
E2Helper.Descriptions["isNPC(e:)"] = "Is the entity a NPC?"
E2Helper.Descriptions["isNextBot(e:)"] = "Is the entity a NextBot?"
E2Helper.Descriptions["isRagdoll(e:)"] = "Is the entity a ragdoll?"
E2Helper.Descriptions["isFrozen(e:)"] = "Is the entity frozen?"
E2Helper.Descriptions["isAsleep(e:)"] = "Is the entity asleep?"
E2Helper.Descriptions["isPenetrating(e:)"] = "Is the entity penetrating another entity?"
E2Helper.Descriptions["isGravityEnabled(e:)"] = "Is gravity enabled for the entity?"
E2Helper.Descriptions["isVehicle(e:)"] = "Is the entity a vehicle?"
E2Helper.Descriptions["inVehicle(e:)"] = "Is the player in a vehicle?"
E2Helper.Descriptions["isWorld(e:)"] = "Is the entity the world?"
Expand All @@ -296,6 +301,8 @@ E2Helper.Descriptions["isSuperAdmin(e:)"] = "Is the player a super admin?"
E2Helper.Descriptions["isAlive(e:)"] = "Is the player or NPC alive?"
E2Helper.Descriptions["isCrouch(e:)"] = "Is the player crouching?"
E2Helper.Descriptions["isFlashlightOn(e:)"] = "Returns 1 if the player has flashlight on, 0 otherwise"
E2Helper.Descriptions["isSpeaking(e:)"] = "Returns 1 if the player speaks, 0 otherwise"
E2Helper.Descriptions["isBot(e:)"] = "Returns 1 if the player is a bot, 0 otherwise"
E2Helper.Descriptions["isTyping(e:)"] = "Is the player typing a message in chat?"
E2Helper.Descriptions["isValid(e:)"] = "Returns 1 if the entity is valid, 0 otherwise"
E2Helper.Descriptions["isValidPhysics(e:)"] = "Returns 1 if the entity has valid physics (players don't)"
Expand Down
Loading