Advertisement
Guest User

maptest.cop

a guest
Dec 9th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.39 KB | None | 0 0
  1. o12(o5({1,2},{1,2}))
  2. map = o1('mapa')
  3. event = o1('event')
  4. serialization = o1('serialization')
  5. component = o1('component')
  6. modem = ovalue(component.modem)
  7. o2(modem.open, 1)
  8. args = o3(...)
  9.   function illegalPlayer(pname) end
  10.   function invalidMove(pname, oldPos, newPos) end
  11. o2(component.glasses.removeAll)
  12.   function pyth(x,y) return o4((x ^ 2) + (y ^ 2)) end
  13.   validMoves = {}
  14.   validMoves[{10,14}] = {{10,15}}
  15.   validMoves[{10,15}] = {{10,14}, {10,16}}
  16.   validMoves[{10,16}] = {{10,15}}
  17. scale = o7(args[1])
  18. scale = o6(scale, 2)
  19. map.SCALE = ovalue(scale)
  20. size = o7(args[2])
  21. size = o6(size, 30)
  22. o2(map.start, 0, 0, size)
  23. team = ovalue({})
  24.   team["natan12_"]=map.addAlly(10,15)
  25. walls = ovalue({})
  26. o8(walls, map.addWallV(9,14,3))
  27. o8(walls, map.addWallV(11,14,3))
  28. o8(walls, map.addWallH(9,17,3))
  29. o8(walls, map.addWallH(9,13,3))
  30. save = ovalue('args[3]=="save')
  31. save = ovalue((save)and(map.snapshot))
  32. o10(save, o9, map.snapshot, '/mnt/230/map-snapshot.png')
  33. print = ovalue(o12)
  34.   function whl(f) local exit = false local e = function() exit = true end while not exit do f(e) end end
  35.  function omain(...) rcv = o15(event) s = ovalue(rcv[3]) m = ovalue(rcv[6]) t = o14(m) function oillegalP(...) oprint(t.p, 'Illegal player', s)     illegalPlayer(t.p) end
  36.  invalidplayer = ovalue((t.p)and(not(team[t.p]))) o10(invalidplayer, oillegalP) function oupdate(...) posX,posY = ovalue(team[t.p].getPosition()) pos = ovalue({posX/map.SCALE,posY/map.SCALE}) newPos = ovalue({t.x,t.y}) valid = ovalue(false)     if o5(pos, newPos) then valid = true end function oantihack(...) _args = o3(...) _k = ovalue(_args[1]) _v = ovalue(_args[2]) _exit = ovalue(_args[3]) function oantihack_internal(...) __args = o3(...) __v = ovalue(__args[2]) __exit = ovalue(__args[3])       if o5(newPos, __v) then valid = true _exit() __exit() end end
  37.       if o5(_k, pos) then fpairs(_v, oantihack_internal) end end
  38.      if not valid then fpairs(validMoves, oantihack) end function oinvalidM(...)      print(t.p, "Invalid move: ", pos[1]..","..pos[2].." to "..newPos[1]..","..newPos[2], "Distance = "..pyth(newPos[1]-pos[1], newPos[2]-pos[2]))      invalidMove(t.p, pos, newPos) end
  39.      if not valid then oinvalidM() end     if valid then team[t.p].setPosition(newPos[1]*map.SCALE, newPos[2]*map.SCALE) end end
  40.  o10(t.p, oupdate) end
  41. o12(o9(whl,omain))
  42. o2(map.remove, map.map)
  43. o2(map.remove, map.frame)
  44.   function remove(_,v) map.remove(v) end
  45. o11(walls, remove)
  46. o11(team, remove)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement