GMZGZXPNSSTUNESB5H63T7RIQQSWILVJYSMJMWOVPL2S7PLYZILAC -- TODO: bounds checkinglocal from = arena:getCell(pos)arena:setCell(pos + dirFromString(direction), self, function()arena:setCell(pos, from)end)arena:setCell(pos, Cell{owner=self.owner})
if arena:hasCell(pos + dirFromString(direction)) thenlocal from = arena:getCell(pos)arena:add(pos + dirFromString(direction), self, function()arena:add(pos, from)end)arena:remove(pos, self)arena:add(pos, Cell{owner=self.owner})end
-- TODO: don't round-- TODO: bounds checkinglocal oldEnergy = self.energylocal cell = Cell{owner=self.owner, core=fun, energy=self.energy * energy}arena:setCell(pos + dirFromString(direction), cell, function()self.energy = oldEnergyend)self.energy = self.energy * (1 - energy)
-- TODO: don't round, limit energy, type checkingif arena:hasCell(pos + dirFromString(direction)) thenenergy = energy or 0.5local oldEnergy = self.energylocal cell = Cell{owner=self.owner, core=fun, energy=self.energy * energy}arena:add(pos + dirFromString(direction), cell, function()self.energy = oldEnergyend)self.energy = self.energy * (1 - energy)end
-- TODO: bounds checkingtable.insert(arena:getCell(pos + dirFromString(direction)).data, data)
if arena:hasCell(pos) thentable.insert(arena:getCell(pos + dirFromString(direction)).data, data)end
table.insert(self.cells[pos.x][pos.y].cells, to)
table.insert(self.cells[pos.x][pos.y].cells, cell)endfunction intermediate:remove(pos, cell)local cells = self.cells[pos.x][pos.y].cellsfor index, checkCell in ipairs(cells) doif cell == checkCell thentable.remove(cells, index)breakendend