Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local middleclass = loadstring(exports.shared:modules('shared.middleclass'))()
- local NPCBase = middleclass.class('NPCBase')
- NPCBase.alive = {}
- function NPCBase:initialize(params)
- self.params = params;
- end
- function NPCBase:setHealth(n)
- self.params.health = n;
- end
- function table.findIn(t, In, value)
- if type( t ) ~= 'table' then
- error( 'Bad argument #1, got ' .. type( t ), 2 )
- end
- if In == nil then
- error( 'Bad argument #2, got nil', 2 )
- end
- for i, data in pairs( t ) do
- if data[In] == value then
- return i, data
- end
- end
- return false
- end
- function NPCBase:destroy()
- local i, data = table.findIn(NPCBase.alive, 'table', self.id)
- return table.remove(NPCBase.alive, i)
- end
- for i = 1, 1000000 do
- local bot = NPCBase:new({id=i;type="zombie";health=100;skin=0});
- table.insert(NPCBase.alive, bot)
- bot:destroy()
- end
- collectgarbage()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement