Bolodefchoco_LUAXML

[Game] Thief

Nov 27th, 2016
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.99 KB | None | 0 0
  1. --Creator: Bolodefchoco
  2. --Made in: 27/11/2016
  3. --Last update: 27/11/2016
  4. --[[ Notes:
  5.     Does:
  6.         Remake do LadrĂ£o de Queijos da vanilla
  7. ]]--
  8.  
  9. for i,f in next,{"Shaman","NewGame","Score","TimeLeft"} do
  10.     tfm.exec["disableAuto"..f]()
  11. end
  12.  
  13. math.pythag = function(x1,y1,x2,y2,range)
  14.     return ((x1-x2)^2+(y1-y2)^2<range^2)
  15. end
  16.  
  17. system.xy = function(xml)
  18.     local param = xml:match("<P (.-)/>")
  19.     local hole = {param:match("thief.hole=\"(%d+),(%d+)\"")}
  20.     local thief = {param:match("thief=\"(%d+),(%d+)\"")}
  21.     return hole,thief
  22. end
  23.  
  24. hole,thief = {0,0,0},{0,0,0,0}
  25. newMap = false
  26. eventNewGame = function()
  27.     newMap = true
  28.  
  29.     tfm.exec.removeImage(hole[1])
  30.     system.bindKeyboard(thief[1],32,true,false)
  31.  
  32.     local h,t = system.xy(tfm.get.room.xmlMapInfo.xml)
  33.  
  34.     hole = {tfm.exec.addImage("158abb69eb6.png","?1",h[1]-20.5,h[2]-15),table.unpack(h)}
  35.  
  36.     local thiefName,players = {"",-1e10},0
  37.     for k,v in next,tfm.get.room.playerList do
  38.         players = players + 1
  39.         if v.score > thiefName[2] then
  40.             thiefName = {k,v.score}
  41.         end
  42.     end
  43.  
  44.     thief = {thiefName[1],math.ceil((players/2)),3,0}
  45.     tfm.exec.setNameColor(thief[1],0xBABD2F)
  46.     tfm.exec.movePlayer(thief[1],t[1],t[2])
  47.     tfm.exec.giveCheese(thief[1])
  48.     system.bindKeyboard(thief[1],32,true,true)
  49.  
  50.     ui.setMapName("<J>#Thief   <G>|   <N>Thief : <V>"..thief[1])
  51.     tfm.exec.setGameTime(80)
  52. end
  53.  
  54. eventLoop = function(time)
  55.     _G.time = (time/1000)
  56.     if time >= 4 and newMap then
  57.         for k,v in next,tfm.get.room.playerList do
  58.             if k ~= thief[1] then
  59.                 if not v.hasCheese and not tfm.get.room.playerList[thief[1]].isDead then
  60.                     if math.pythag(v.x,v.y,tfm.get.room.playerList[thief[1]].x,tfm.get.room.playerList[thief[1]].y,25) then
  61.                         tfm.exec.giveCheese(k)
  62.                         thief[2] = thief[2] - 1
  63.                         if thief[2] <= 0 then
  64.                             tfm.exec.killPlayer(thief[1])
  65.                             tfm.exec.setPlayerScore(thief[1],0)
  66.                             tfm.exec.setGameTime(15)
  67.                         end
  68.                     end
  69.                 else
  70.                     if not v.isDead and math.pythag(v.x,v.y,hole[2],hole[3],30) then
  71.                         tfm.exec.playerVictory(k)
  72.                         tfm.exec.setPlayerScore(k,5,true)
  73.                     end
  74.                 end
  75.             end
  76.         end
  77.     end
  78. end
  79.  
  80. eventPlayerDied = function(n)
  81.     if tfm.get.room.playerList[thief[1]].isDead and n ~= thief[1] then
  82.         tfm.exec.setPlayerScore(n,1,true)
  83.     else
  84.         if tfm.get.room.playerList[n].score > 0 then
  85.             tfm.exec.setPlayerScore(n,-1,true)
  86.         end
  87.     end
  88. end
  89.  
  90. eventKeyboard = function(n,k,d,x,y)
  91.     if time >= 4 and not tfm.get.room.playerList[thief[1]].isDead and n == thief[1] and thief[3] > 0 and os.time() > thief[4] then
  92.         tfm.exec.explosion(x,y,50,60)
  93.         tfm.exec.displayParticle(12,x,y)
  94.         thief[3] = thief[3] - 1
  95.         thief[4] = os.time() + 7000
  96.     end
  97. end
  98.  
  99. tfm.exec.newGame('<C><P thief="286,280" thief.hole="117,70" /><Z><S><S L="804" H="98" X="401" Y="434" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="59" H="92" X="286" Y="340" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="84" H="189" X="574" Y="291" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="72" H="249" X="118" Y="194" T="0" P="0,0,0.3,0.2,0,0,0,0" /></S><D><DS Y="372" X="116" /></D><O /></Z></C>')
Advertisement
Add Comment
Please, Sign In to add comment