Forum

> > CS2D > Scripts > Loop error
Forums overviewCS2D overview Scripts overviewLog in to reply

English Loop error

2 replies
To the start Previous 1 Next To the start

old Loop error

KenVo
User Off Offline

Quote
What's wrong with this?
1
2
3
4
5
6
7
function table.remove_val(table, element)
	for i, v in pairs(table) do
		if v == element then
			table.remove(table,i)
		end
	end
end

old Re: Loop error

KenVo
User Off Offline

Quote
LOL I just figured it out now...silly mistake again
1
2
3
4
5
6
7
function table.remove_val(tbl, element)
     for i, v in pairs(tbl) do
          if v == element then
               table.remove(tbl,i)
          end
     end
end

can't use table.remove because it would thinks "remove" as an element
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview