Advertisement
Pebsie

Mob decision network code (LOVE)

Aug 31st, 2013
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.60 KB | None | 0 0
  1. (on the message receive function)
  2. local seed = msg
  3. for i, pairs in mob(ents.mobs) do
  4.    mob:move(seed..mob.id)
  5. end
  6. (in the mob entity)
  7. function self:load(x, y)
  8.     --load shit here
  9.     local moveDirection = 1
  10.     local moveDistance = 0
  11. end
  12. function self:update(dt)
  13.     local x, y = self:getPos()
  14.     if moveDistance > 0 then
  15.         --move in the direction specified
  16.         moveDistance = moveDistance -1
  17.     end
  18.     self:setPos(x, y)
  19. end
  20. function self:move(seed)
  21.     local isDoing = math.random(1, 2, seed)
  22.     if isDoing == 1 then
  23.         moveDirection = math.random(1, 360, seed)
  24.         moveDistance = math.random(1, 100, seed)
  25.     end
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement