Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. init start
  2. -- local SCRIPT_VERSION = '1.0.2'
  3. local idletime = {from = 180000, to = 600000}
  4.  
  5. -- Do not change anything below
  6. local alldirs = {'n', 'e', 'w', 's'}
  7. local lastmove = 0
  8. idletime.current = math.random(idletime.from, idletime.to)
  9. init end
  10.  
  11. auto(200)
  12.  
  13. local isidle = ($standtime >= idletime.current and ($timems - lastmove) >= idletime.current)
  14. foreach newmessage m do
  15. if m.type == MSG_RED and m.content:match('disconnected') then
  16. isidle = true
  17. end
  18. end
  19.  
  20. if $connected and isidle then
  21. local selfdir = $self.dir
  22.  
  23. local dirs = {}
  24. for _, j in ipairs(alldirs) do
  25. if j ~= selfdir then
  26. table.insert(dirs, j)
  27. end
  28. end
  29.  
  30. turn(dirs[math.random(1, #dirs)])
  31. turn(selfdir)
  32.  
  33. idletime.current = math.random(idletime.from, idletime.to)
  34. lastmove = $timems
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement