Advertisement
Fooksie

checkpoint.lua

Jul 30th, 2013
640
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.86 KB | None | 0 0
  1. checkpoint={}
  2. function eventNewGame()
  3.     checkpoint={}
  4.     end
  5. function eventNewPlayer(name)
  6.     tfm.exec.bindKeyboard(name,69,true,true)
  7.     tfm.exec.bindKeyboard(name,70,true,true)
  8.     tfm.exec.bindKeyboard(name,65,true,true)
  9.     end
  10. for name,player in pairs(tfm.get.room.playerList) do
  11.     eventNewPlayer(name)
  12.     end
  13. function eventPlayerWon(name)
  14.     checkpoint[name]=nil
  15.     tfm.exec.respawnPlayer(name)
  16.     end
  17. function eventPlayerDied(name)
  18.     tfm.exec.respawnPlayer(name)
  19.     if checkpoint[name] then
  20.         tfm.exec.movePlayer(name,checkpoint[name].x,checkpoint[name].y,false,1,1,false)
  21.         if checkpoint[name].cheese then
  22.             tfm.exec.giveCheese(name)
  23.             end
  24.         end
  25.     end
  26. function eventKeyboard(name,key,down,x,y)
  27.     if key==69 then
  28.         tfm.exec.chatMessage("<VP>Checkpoint set (<N>"..x.." "..y.."<VP>)",name)
  29.         checkpoint[name]={
  30.             cheese=tfm.get.room.playerList[name].hasCheese,
  31.             x=x,
  32.             y=y
  33.             }
  34.     elseif key==70 then
  35.         if checkpoint[name] and tfm.get.room.playerList[name].hasCheese and not checkpoint[name].cheese then
  36.             tfm.exec.killPlayer(name)
  37.         else
  38.             eventPlayerDied(name)
  39.             end
  40.     elseif key==65 then
  41.         tfm.exec.chatMessage("<VP>Checkpoint cleared",name)
  42.         checkpoint[name]=nil
  43.         end
  44.     end
  45. function eventChatCommand(name,message)
  46.     local args={}
  47.     for arg in message:gmatch("[^%s]+") do
  48.         table.insert(args,arg)
  49.         end
  50.     if args[1]=="goto" then
  51.         local player=tfm.get.room.playerList[args[2]]
  52.         local offset=false
  53.         if player then
  54.             args[4]=args[3]
  55.             args[2]=player.x
  56.             args[3]=player.y
  57.             end
  58.         if args[4]=="offset" then
  59.             offset=true
  60.         elseif args[4]=="checkpoint" then
  61.             eventKeyboard(name,69,true,args[2],args[3])
  62.             end
  63.         tfm.exec.movePlayer(name,args[2],args[3],offset,1,1,false)
  64.     elseif args[1]=="time" then
  65.         tfm.exec.setGameTime(60*6)
  66.     elseif args[1]=="cheese" then
  67.         tfm.exec.giveCheese(name)
  68.         end
  69.     end
  70. tfm.exec.chatMessage("<VP>Running checkpoint.lua")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement