NoorTFM

Floor Is Lava

Sep 24th, 2020
1,600
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[]
  2. #########################################
  3.        ✸Created By - Ctmce✸
  4.       ✸Module version: v1.0_beta✸
  5.     ✸Updated date: 10/26/2018✸
  6. #########################################
  7. Commands list:
  8. 1. !ms [MSG] = Send a message as a funcorp member.
  9. 2. !start = starts the game!
  10. 3. !stop = stops the game!
  11. 4. !g = will switch the ground(if current ground is lava , then it will switch it to dirt same with dirt to lava)!
  12. 5. !tp all = turn on the tp power(See Other powers list to know how to use it)!
  13. Other powers:
  14. 1. If tp power is on , then Mouse click anywhere in the map to teleport everyone aswell as you to the mouse position!
  15. 2. Hold Shift+Mouse click = spawn random objects in your mouse position!
  16. ]]
  17.  
  18. lava={}
  19. backgrounds = {"17369683742.jpg","173695d6d70.jpg","17369524d79.jpg","17369524d79.jpg","1736951e776.jpg","17305a13915.png","172fd0940c4.png","172fd0847d7.png","1712c2e573f.png","1711ecc824b.jpg","1711e9a5172.jpg","1711e9a072a.jpg","1711e8ce5f7.jpg","1711e8ca452.jpg","1711e8c0569.jpg","165245b5238.jpg","1700112d165.jpg","17001097f5a.jpg","170013d6683.jpg"}
  20. game = {
  21.     admins = {"Noooooooorr#0000","Turkitutu#0000","Massi#0015","Omaraldin#1619"},
  22.     time = 8,
  23.     started = false,
  24.     currentGround = "dirt",
  25.     dirtTimer = nil,
  26.     lavaTimer = nil,
  27.     dirtCD = 3000,
  28.     lavaCD = 10000,
  29.     tArea = 10,
  30.     objects = {1,2,3,4,6,7,10,39,59,60,62,68},
  31.     maps = {"7214563","7273409"},
  32.     objectsList = {},
  33.     ground = {}
  34. };
  35. players = {}
  36. local looper = 0
  37. local reapet = truelocal
  38. tpAll = false
  39. local sObjects = false
  40. game.ground.lava = {type = 3,x = 800,y = 387,r = 0.2,f = 0.3,w = 1600,h = 37,gc = true,mc = false}
  41. game.ground.dirt = {type = 6,x = 800,y = 387,r = 0.2,f = 0.3,w = 1600,h = 37,gc = true,mc = true}
  42. translation = {
  43.     en = {welcome="Welcome to FunCorp! Beware! THE FLOOR IS LAVA!!!",
  44.         floorislava="THE FLOOR IS LAVA!",
  45.         win="%s has won the game"},
  46.     ar = {welcome="!أهلا بكم في الفانكورب! لقد تحولت الأرض الى حمم بركانية،كن حذرا",
  47.         floorislava="!الأرض أصبحت حمم بركانية",
  48.         win="!في الجولة %s فاز"},
  49.     ru = {welcome="Добро пожаловать в FunCorp! Осторожно! ПОЛ - ЭТО ЛАВА!!!",
  50.         floorislava="ПОЛ - ЭТО ЛАВА!",
  51.         win="%s выиграл(а) этот раунд."},
  52.     fr = {welcome="Bienvenue sur FunCorp! Attention ! Le sol est en lave!!!",
  53.         floorislava="Le sol est en lave!!!",
  54.         win="%s a gagné la ronde"},
  55.     tr = {welcome="Funcorp'a Hoşgeldiniz! Dikkat! BU ZEMİN BİR LAV!",
  56.         floorislava="BU ZEMİN BİR LAV!",
  57.         win="%s oyunu kazandı."},
  58. }
  59.    
  60.  
  61. function tran(n, id)
  62.     if translation[tfm.get.room.playerList[n].community] then
  63.       return translation[tfm.get.room.playerList[n].community][id]
  64.     else
  65.       return translation["en"][id]
  66.     end
  67. end
  68.  
  69. function main()
  70.     tfm.exec.disableAutoNewGame(true)
  71.     tfm.exec.disableAutoTimeLeft(true)
  72.     tfm.exec.disableAutoShaman(true)
  73.     tfm.exec.disableAutoScore(true)
  74.     system.disableChatCommandDisplay(nil,true)
  75.     tfm.exec.disablePhysicalConsumables(true)
  76.  
  77.     changeMap()
  78.     table.foreach(
  79.         tfm.get.room.playerList,
  80.         function(name)
  81.             eventNewPlayer(name)
  82.         end
  83.     )
  84. end
  85.  
  86. function changeMap()
  87.     tfm.exec.newGame(game.maps[math.random(1,#game.maps)])
  88. end
  89.  
  90. local setScore = function(name) tfm.exec.setPlayerScore(name, players[name].score, false) end
  91. local refreshTimers = function(ground) if ground == "dirt" then game.dirtTimer = 3 elseif ground == "lava" then game.lavaTimer = 10 else game.lavaTimer = 10 game.dirtTimer = 3 end end
  92.  
  93. function removeObjects()
  94.     for _,i in next,game.objectsList
  95.     do
  96.         tfm.exec.removeObject(i)
  97.     end
  98.     game.objectsList = {}
  99. end
  100.  
  101. local resetProp = function() game.time = 60 game.tArea = 10 game.objectsList = {} game.currentGround = "dirt" refreshTimers() end
  102. local removeAreas = function() for _,area in next,{1,2,10} do ui.removeTextArea(area,nil) end end
  103.  
  104. function alivePlrCount()
  105.     local c = 0
  106.     for n,p in pairs(tfm.get.room.playerList) do
  107.         if not p.isDead then
  108.             c = c + 1
  109.         end
  110.     end
  111.     return c
  112. end
  113.  
  114. local isAdmin = function(name) for _,n in next,game.admins do if n == name then return true end end return false end
  115.  
  116. function spawnObjects(x,y)
  117.     if game.started == true then
  118.         local oC = math.ceil((game.time / 10 > 1 and game.time / 10 or 1))
  119.         local g = false
  120.         local a = nil
  121.         if o == 62 then
  122.             a = 90 g = true
  123.         end
  124.         if x ~= nil and y ~= nil then
  125.             local o = game.objects[math.random(1,#game.objects)]
  126.             if o == 62 then
  127.                 a = 90
  128.                 g = true
  129.             else
  130.                 a = nil
  131.                 g = nil
  132.             end
  133.             local sO = tfm.exec.addShamanObject(o, x, y, (a and a or 0),0,0, (g or false)) table.insert(game.objectsList,sO)
  134.         else
  135.             for i=1,oC,1 do
  136.                 local o = game.objects[math.random(1,#game.objects)]
  137.                 if o ==  62  then
  138.                     a = 90
  139.                     g = true
  140.                 else
  141.                     a = nil
  142.                     g = nil
  143.                 end
  144.                 local sO = tfm.exec.addShamanObject(o, math.random(100,1500), 360, (a and a or 0),0,0, (g or false)) table.insert(game.objectsList,sO)
  145.             end
  146.         end
  147.     end
  148. end  
  149.                
  150. function groundSwitch()
  151.     if game.started == true then
  152.         if game.currentGround == "dirt" then
  153.             local gP = game.ground.lava
  154.             if not lava then lava = tfm.exec.addImage("173697132e1.png", "!1", 0, 350, nil) end
  155.             tfm.exec.addPhysicObject(1, gP.x, gP.y, {type = gP.type,width = gP.w,height = gP.h,foreground = false,friction = gP.f, restitution = gP.r, angle = 0, miceCollision = gP.mc, groundCollision = gP.gc})
  156.             for n, player in next, tfm.get.room.playerList do
  157.                 ui.addTextArea(1, "<p align='center'><font size='40' color='#FF0000'>"..tran(n,"floorislava").."</font></p>", n, 140, 125, 520, 119, 0x324650, 0x000000, 0, true)
  158.             end
  159.             if not lava then lava = tfm.exec.addImage("173697132e1.png", "!1", 0, 350, nil) end
  160.                 refreshTimers(game.currentGround)
  161.             game.currentGround = "lava"
  162.         elseif game.currentGround == "lava" then
  163.             local gP = game.ground.dirt
  164.             for _,id in next,game.objectsList do
  165.                 tfm.exec.removeObject(id)
  166.             end
  167.             if lava then tfm.exec.removeImage(lava) lava = nil end
  168.             tfm.exec.addPhysicObject(1, gP.x, gP.y, {type = gP.type,width = gP.w,height = gP.h,foreground = false,friction = gP.f, restitution = gP.r, angle = 0, miceCollision = gP.mc, groundCollision = gP.gc})
  169.             refreshTimers(game.currentGround) game.currentGround = "dirt"
  170.         end
  171.     end
  172. end
  173.  
  174. function giveWin(name)
  175.     tfm.exec.giveCheese(name)
  176.     tfm.exec.playerVictory(name)
  177.     players[name].score = players[name].score + 1
  178.     setScore(name)
  179. end
  180.  
  181. function setGround(g)
  182.     if game.started == false then
  183.         game.currentGround = g
  184.         local gP = game.ground[g]
  185.         tfm.exec.addPhysicObject(1, gP.x, gP.y, {type = gP.type,width = gP.w,height = gP.h,foreground = false,friction = gP.f, restitution = gP.r, angle = 0, miceCollision = gP.mc, groundCollision = gP.gc})
  186.     else
  187.         game.currentGround = g
  188.         local gP = game.ground[g]
  189.         tfm.exec.addPhysicObject(1, gP.x, gP.y, {type = gP.type,width = gP.w,height = gP.h,foreground = false,friction = gP.f, restitution = gP.r, angle = 0, miceCollision = gP.mc, groundCollision = gP.gc})
  190.         refreshTimers(game.currentGround)
  191.     end
  192. end
  193.  
  194. function eventNewGame()
  195.     if game.started == true then
  196.         Background = backgrounds[math.random(#backgrounds)]
  197.         tfm.exec.addImage(Background, "_0", 0, 0, n)
  198.         resetProp()
  199.         system.removeTimer(meep)
  200.         meep = nil
  201.         reapet = true
  202.         tfm.exec.setGameTime(game.time, true)
  203.         setGround("dirt")
  204.         meep = system.newTimer(function() table.foreach(tfm.get.room.playerList,function(name) tfm.exec.giveMeep(name) end) end,35000,false)
  205.     else
  206.         resetProp()
  207.         setGround("dirt")
  208.     end
  209. end
  210.  
  211. function eventNewPlayer(name)
  212.     if Background then tfm.exec.addImage(Background, "_0", 0, 0, name) end
  213.     if players[name] then
  214.         players[name].score = 0
  215.         setScore(name)
  216.     else
  217.         players[name] = {score = 0}
  218.         setScore(name)
  219.     end
  220.     tfm.exec.chatMessage("<font color='#FF7F0F'>"..tran(name,"welcome").."\n",name)
  221.    
  222.     if isAdmin(name) then
  223.         system.bindMouse(name, true)
  224.         system.bindKeyboard(name, 16, false, true)
  225.         system.bindKeyboard(name, 16, true, true)
  226.     end
  227. end
  228.  
  229. function eventPlayerDied(name)
  230.     if game.started == true then
  231.         if alivePlrCount() <= 1 then
  232.             reapet = false removeAreas()
  233.             for name,p in next,tfm.get.room.playerList do
  234.                 if not p.isDead then
  235.                     for n, player in next, tfm.get.room.playerList do
  236.                         ui.addTextArea(2, "<p align='center'><font size='30' color='#FFFF00'>"..string.format(tran(n,"win"),name).."</font></p>", n, 50, 250, 700, 500, 0x324650, 0x000000, 0, true)
  237.                         ui.addTextArea(1, "<p align='center'><font size='50' color='#FF0000'>"..tran(n,"floorislava").." </font></p>", n, 50, 125, 700, 119, 0x324650, 0x000000, 0, true)
  238.                     end
  239.                     giveWin(name)
  240.                 end
  241.             end
  242.             system.newTimer(function() removeAreas() changeMap() end, 5000, false)
  243.         end
  244.     end
  245. end
  246.    
  247. function eventChatCommand(name, command)
  248.     local arg={}
  249.     for argument in command:gmatch('[^%s]+') do
  250.         table.insert(arg,argument)
  251.     end
  252.     if isAdmin(name) == true then
  253.         if arg[1] == "ms" and arg[2] ~= nil then
  254.             local t = command:find('%s')
  255.             local msg = command:sub(t+1)
  256.             tfm.exec.chatMessage("<Fc>• [" ..name .."]:</Fc><CE> " ..msg .."</CE>")
  257.         end
  258.         if arg[1] == "tp" and arg[2] == "all" then
  259.             tfm.exec.chatMessage("<font color='#F95705'>• [FuncorpBot]:</font><bv> You turned ON tp power! <b>Mouse click</b> anywhere on the screen to teleport everyone!</bv>",name)
  260.             tpAll = true
  261.         end
  262.         if arg[1] == "start" then
  263.             if not game.started then
  264.                 game.started = true
  265.                 changeMap()
  266.             end
  267.         elseif arg[1] == "stop" then
  268.             if game.started == true then
  269.                 game.started = false
  270.                 removeAreas()
  271.                 changeMap()
  272.             end
  273.         elseif arg[1] == "g" then
  274.             removeAreas()
  275.             spawnObjects()
  276.             groundSwitch()
  277.         end
  278.     end
  279. end
  280.        
  281. function eventKeyboard(name, key, Keydown, x, y)
  282. if isAdmin(name) then
  283.     if key == 16 then
  284.         if Keydown then
  285.             sObjects = true
  286.         else
  287.             sObjects = false
  288.         end
  289.     end
  290. end
  291. end
  292.  
  293. function
  294. eventMouse(name, x, y)
  295. if isAdmin(name) then
  296.     if sObjects == true then
  297.         spawnObjects(x,y)
  298.     end
  299.     if tpAll == true then
  300.         for n,p in pairs(tfm.get.room.playerList) do
  301.             tfm.exec.movePlayer(n,x,y,false,0,0,false)
  302.         end
  303.         tpAll = false
  304.     end
  305. end
  306. end
  307.  
  308. function eventLoop(cT, tR)
  309. if game.started == true and reapet == true then
  310.     tR = tR / 1000
  311.     game.time = tR
  312.     looper = looper + 0.5
  313.     if looper == 1 then
  314.         if game.currentGround == "lava" then
  315.             if game.dirtTimer > 0  then
  316.                 game.dirtTimer = game.dirtTimer - 1 elseif
  317.                 game.dirtTimer <= 0 then
  318.                     groundSwitch()
  319.                     ui.removeTextArea(1, nil)
  320.                 end
  321.             end
  322.             if game.currentGround == "dirt" then
  323.                 if game.lavaTimer > 0 then
  324.                     if game.lavaTimer == 4 then
  325.                         spawnObjects()
  326.                     end
  327.                     ui.addTextArea(10, "<p align='center'><font color='0xffffff' face='soopafresh'><font size='90'>" ..game.lavaTimer .."</font></p>", nil, 340, 125, 120, 119, 0x324650, 0x000000, 0, true)
  328.                     game.lavaTimer = game.lavaTimer - 1
  329.                 elseif
  330.                 game.lavaTimer <= 0 then
  331.                     ui.removeTextArea(10,nil)groundSwitch()
  332.                 end
  333.             end
  334.             looper = 0
  335.         end
  336.     end
  337. end
  338.  
  339. main()
  340.  
RAW Paste Data