Skip to content

Commit

Permalink
feat: mark find* functions as nodiscard (#2666)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vurv78 authored Jul 10, 2023
1 parent 6b49572 commit 0ed150e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lua/entities/gmod_wire_expression2/core/find.lua
Original file line number Diff line number Diff line change
Expand Up @@ -348,16 +348,19 @@ hook.Add("Think","Wire_Expression2_Find_AddCount",addcount)
__e2setcost(2)

--- Returns the minimum delay between entity find events on a chip
[nodiscard]
e2function number findUpdateRate()
return findrate()
end

-- Returns the maximum number of finds per E2
[nodiscard]
e2function number findMax()
return maxfinds()
end

-- Returns the remaining available find calls
[nodiscard]
e2function number findCount()
return self.data.findcount
end
Expand Down Expand Up @@ -781,11 +784,13 @@ end
--[[************************************************************************]]--

--- Returns the indexed entity from the previous find event (valid parameters are 1 to the number of entities found)
[nodiscard]
e2function entity findResult(index)
return self.data.findlist[index]
end

--- Returns the closest entity to the given point from the previous find event
[nodiscard]
e2function entity findClosest(vector position)
local closest = nil
local dist = math.huge
Expand All @@ -805,6 +810,7 @@ e2function entity findClosest(vector position)
end

--- Formats the query as an array, R:entity(Index) to get a entity, R:string to get a description including the name and entity id.
[nodiscard]
e2function array findToArray()
local tmp = {}
for k,v in ipairs(self.data.findlist) do
Expand All @@ -815,6 +821,7 @@ e2function array findToArray()
end

--- Equivalent to findResult(1)
[nodiscard]
e2function entity find()
return self.data.findlist[1]
end
Expand Down

0 comments on commit 0ed150e

Please sign in to comment.