Advertisement
Bolodefchoco_LUAXML

[Game] Presents

Mar 24th, 2017
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.98 KB | None | 0 0
  1. presents = {
  2.     gifts = {},
  3.     winners = {},
  4.     isRunning = false,
  5.     choice = {15,true},
  6.     block = {5,false},
  7.     newMap = {10,false},
  8.     currentGift = 1,
  9.     total = 1,
  10.     init = function()
  11.         for k,v in next,{"AutoShaman","AutoNewGame","AutoTimeLeft","AutoScore","AfkDeath","MortCommand","DebugCommand","PhysicalConsumables"} do
  12.             tfm.exec["disable"..v]()
  13.         end
  14.         tfm.exec.setRoomMaxPlayers(25)
  15.         presents.map()
  16.     end,
  17.     kill = function()
  18.         local gift = presents.gifts[presents.currentGift] - 2099
  19.         for k,v in next,tfm.get.room.playerList do
  20.             if not v.isDead then
  21.                 if v.x >= (gift * 120) and v.x <= (gift * 120 + 80) and v.y > 267 then
  22.                     tfm.exec.setPlayerScore(k,1,true)
  23.                 else
  24.                     tfm.exec.killPlayer(k)
  25.                 end
  26.             end
  27.         end
  28.     end,
  29.     map = function()
  30.         presents.isRunning = true
  31.         presents.gifts = {
  32.             [1] = table.random({2104,2102,2100,2101,2103,2100,2104,2102,2103,2101,2104,2102,2100,2101,2103,2100,2104,2102,2103,2101,2104,2102,2100,2101,2103,2100,2104,2102,2103,2101}),
  33.             [2] = table.random({2102,2100,2101,2103,2100,2104,2102,2103,2101,2104,2102,2100,2101,2103,2100,2104,2102,2103,2101,2104,2102,2100,2101,2103,2100,2104,2102,2103,2101,2104}),
  34.             [3] = table.random({2100,2101,2103,2100,2104,2102,2103,2101,2104,2102,2100,2101,2103,2100,2104,2102,2103,2101,2104,2102,2100,2101,2103,2100,2104,2102,2103,2101,2104,2102})
  35.         }
  36.         tfm.exec.newGame('<C><P DS="m;250,120,400,120,550,120" D="x_transformice/x_inventaire/'..presents.gifts[1]..'.jpg,230,60;x_transformice/x_inventaire/'..presents.gifts[2]..'.jpg,380,60;x_transformice/x_inventaire/'..presents.gifts[3]..'.jpg,530,60;x_transformice/x_inventaire/2100.jpg,140,320;x_transformice/x_inventaire/2101.jpg,260,320;x_transformice/x_inventaire/2102.jpg,380,320;x_transformice/x_inventaire/2103.jpg,500,320;x_transformice/x_inventaire/2104.jpg,620,320" /><Z><S><S P="1,0.0001,20,0.2,90,1,0,0" H="700" L="15" X="400" c="3" Y="161" T="4" /><S X="100" P="0,0,20,0.2,0,0,0,0" L="40" H="135" c="3" Y="335" T="4" /><S H="135" P="0,0,20,0.2,0,0,0,0" L="40" X="220" c="3" Y="335" T="4" /><S X="340" P="0,0,20,0.2,0,0,0,0" L="40" H="135" c="3" Y="335" T="4" /><S H="135" P="0,0,20,0.2,0,0,0,0" L="40" X="460" c="3" Y="335" T="4" /><S X="580" P="0,0,20,0.2,0,0,0,0" L="40" H="135" c="3" Y="335" T="4" /><S H="40" P="0,0,0.3,0.2,0,0,0,0" L="40" X="100" c="3" Y="160" T="0" /><S X="700" P="0,0,0.3,0.2,0,0,0,0" L="40" H="40" c="3" Y="160" T="0" /><S X="550" P="0,0,0.3,0.2,0,0,0,0" L="40" H="40" c="3" Y="160" T="0" /><S X="400" P="0,0,0.3,0.2,0,0,0,0" L="40" H="40" c="3" Y="160" T="0" /><S X="250" P="0,0,0.3,0.2,0,0,0,0" L="40" H="40" c="3" Y="160" T="0" /><S H="20" P="0,0,0.3,0.2,0,0,0,0" L="800" X="400" Y="10" T="0" /><S H="135" P="0,0,20,0.2,0,0,0,0" L="40" X="700" c="3" Y="335" T="4" /><S X="400" P="0,0,0.3,0.2,0,0,0,0" L="800" H="100" c="3" Y="415" T="0" /><S P="0,0,0.3,0.2,0,0,0,0" H="10" L="50" o="324650" X="745" c="3" Y="138" T="13" /><S X="55" P="0,0,0.3,0.2,0,0,0,0" L="50" o="324650" H="10" c="3" Y="138" T="13" /><S P="0,0,0.3,0.2,0,0,0,0" H="140" L="100" o="324650" X="55" c="3" Y="72" T="12" /><S X="745" P="0,0,0.3,0.2,0,0,0,0" L="100" o="324650" H="140" c="3" Y="72" T="12" /><S P="0,0,0,0,0,0,0,0" H="102" L="581" o="6a7495" X="401" c="4" v="3001" Y="78" T="12" /></S><D /><O /><L><JR M2="10" M1="0" /></L></Z></C>')
  37.     end,
  38.     victory = function(none)
  39.         if presents.choice[2] then
  40.             local winner = "%s %s%s!"
  41.             if none or system.players() == 0 then
  42.                 winner = winner:format("","","Nobody won")
  43.                 tfm.exec.chatMessage("<J>Nobody won")
  44.             else
  45.                 winner = winner:format(table.concat(system.players(true),", "),"%s","won")
  46.                 for k,v in next,system.players(true) do
  47.                     tfm.exec.chatMessage("<G>"..v.." <J>won!")
  48.                     local found = {false,0}
  49.                     for i,j in next,presents.winners do
  50.                         if j[1] == v then
  51.                             found = {true,i}
  52.                             break
  53.                         end
  54.                     end
  55.                     if found[1] then
  56.                         presents.winners[found[2]][2] = presents.winners[found[2]][2] + 1
  57.                     else
  58.                         presents.winners[#presents.winners + 1] = {v,1}
  59.                     end
  60.                 end
  61.             end
  62.             ui.addTextArea(0,"<B><p align='center'><font size='22' color='#1'>".. winner:format(""),nil,0,222,800,h,1,1,0,true)
  63.             ui.addTextArea(1,"<B><p align='center'><font size='22'><V>".. winner:format("<J>"),nil,0,220,800,h,1,1,0,true)
  64.             presents.newMap[2] = true
  65.         end
  66.     end,
  67.     eventNewPlayer = function(n)
  68.         tfm.exec.chatMessage("<J>Welcome to <VP><B>#presents</B><J>! Choose a gap according to the gift represented and good luck! You will win if your three-gifts-sequence is correct!\n\n<CE>Developed by Bolodefchoco and projected by Ruamorangos",n)
  69.         if presents.isRunning then
  70.             ui.addTextArea(2,"<font size='20'>You will appear in the next sortition!",n,216,65,365,35,1,1,1,true)
  71.             tfm.exec.chatMessage("<VP>You will appear in the next sortition!",n)
  72.         else
  73.             tfm.exec.respawnPlayer(n)
  74.         end
  75.     end,
  76.     eventNewGame = function()
  77.         if presents.isRunning then
  78.             for i,x in next,{250,400,550} do
  79.                 tfm.exec.addPhysicObject(i,x,75,{
  80.                     type = 12,
  81.                     height = 90,
  82.                     width = 90,
  83.                     miceCollision = false,
  84.                     groundCollision = false,
  85.                     color = 0x6A7495
  86.                 })
  87.             end
  88.             for i = 0,1 do
  89.                 ui.removeTextArea(i)
  90.             end
  91.             presents.choice = {15,true}
  92.             presents.block = {5,false}
  93.             presents.newMap = {10,false}
  94.             presents.currentGift = 1
  95.         end
  96.         tfm.exec.setGameTime(1e7)
  97.         ui.removeTextArea(2,nil)
  98.     end,
  99.     eventLoop = function(currentTime)
  100.         local mapName = "<N>Rivals : <V>"..system.players()
  101.         if currentTime > 4 and presents.isRunning then
  102.             if presents.choice[2] then
  103.                 mapName = "<N>Rivals : <V>"..system.players().."   <G>|   <J>Choose a gift in less than <PT>"..math.floor(presents.choice[1]).."<J> seconds!"
  104.                 presents.choice[1] = presents.choice[1] - .5
  105.                 if presents.choice[1] <= 0 then
  106.                     presents.choice = {15,false}
  107.                     presents.block[2] = true
  108.                 end
  109.             end
  110.             if presents.block[2] then
  111.                 mapName = "<N>Rivals : <V>"..system.players().."   <G>|   <R>Those who are out of the correct gift will be dead!"
  112.                 presents.block[1] = presents.block[1] - .5
  113.                 tfm.exec.addPhysicObject(4,400,270,{
  114.                     type = 4,
  115.                     height = 10,
  116.                     width = 640,
  117.                     miceCollision = true,
  118.                     groundCollision = false
  119.                 })
  120.                 tfm.exec.removePhysicObject(presents.currentGift)
  121.                 if presents.block[1] == 2 then
  122.                     presents.kill()
  123.                 end
  124.                 if presents.block[1] <= 0 then
  125.                     presents.currentGift = presents.currentGift + 1
  126.                     presents.block = {5,false}
  127.                     presents.choice[2] = true
  128.                     if presents.currentGift == 4 then
  129.                         presents.victory()
  130.                         presents.choice[2] = false
  131.                     end
  132.                 end
  133.             else
  134.                 tfm.exec.removePhysicObject(4)
  135.             end
  136.             if presents.newMap[2] then
  137.                 mapName = "<PS>New sortition in <PT>"..math.floor(presents.newMap[1]).."<PS> seconds!"
  138.                 presents.newMap[1] = presents.newMap[1] - .5
  139.                 if presents.newMap[1] <= 0 then
  140.                     presents.map()
  141.                 end
  142.             end
  143.             if system.players() == 0 then
  144.                 presents.victory(true)
  145.                 presents.newMap[2] = true
  146.                 presents.choice[2] = false
  147.             end
  148.         end
  149.         ui.setMapName(mapName.."<")
  150.     end
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement