Jump to content

BrambleManager uses # operator on non-sequences


_zwb
  • DLC VERSION - IMPORTANT!: Hamlet Pending

In components/bramblemanager.lua, line 45-58:

	for i=1,self.bramblesToSpawn do
		if #tempselctionset > 0 then
			local choice = math.random(1,#tempselctionset)
			local point = tempselctionset[choice]
			table.insert(selected,point)
			
			for i=#tempselctionset,1,-1 do
				local testpoint = tempselctionset[i]
				if point:GetDistanceSqToInst(testpoint) < 40*40 then
					table.remove(tempselctionset,i)
				end				
			end
		end
	end

Here, the table "tempselectionset" is no longer a sequence because of the table.remove function call, so the length operator would not work properly.

 

Quote

The length operator is unreliable for lists with holes (nils). It only works for sequences, which we defined
as lists without holes. More precisely, a sequence is a table where the positive numeric keys comprise a
set {1,...,n} for some n. (Remember that any key with value nil is actually not in the table.) In particular,
a table with no numeric keys is a sequence with length zero.

-- Programming in Lua, Fourth Edition


Steps to Reproduce

The above




User Feedback


There are no comments to display.



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...