Update Set.lua

Improve GetLast and GetRandom
This commit is contained in:
Thomas
2022-12-08 14:33:50 +01:00
committed by GitHub
parent 047a108689
commit 2c75ea1a18

View File

@@ -387,8 +387,8 @@ do -- SET_BASE
-- @param #SET_BASE self
-- @return Core.Base#BASE
function SET_BASE:GetLast()
local ObjectName = self.Index[#self.Index]
local tablemax = table.maxn(self.Index)
local ObjectName = self.Index[tablemax]
local LastObject = self.Set[ObjectName]
self:T3( { LastObject } )
return LastObject
@@ -398,8 +398,8 @@ do -- SET_BASE
-- @param #SET_BASE self
-- @return Core.Base#BASE
function SET_BASE:GetRandom()
local RandomItem = self.Set[self.Index[math.random( #self.Index )]]
local tablemax = table.maxn(self.Index)
local RandomItem = self.Set[self.Index[math.random(1,tablemax)]]
self:T3( { RandomItem } )
return RandomItem
end