Advertisement
suxonov

Untitled

Feb 11th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.90 KB | None | 0 0
  1. local players = {}
  2. local maps = {'@6509524', '@6509938', '@6509942', '@6509617', '@6509625', '@324046', '@321307', '@321294', '@6509961', ''}
  3. local toDespawn = {}
  4. local version = 'Beta 4'
  5. tfm.exec.disableAutoScore(true)
  6. tfm.exec.disableAutoShaman(true)
  7. tfm.exec.disableAutoNewGame(true)
  8.  
  9.     Messages = {
  10.      greet = 'Welcome to <b>botmj</b>! Type !help for more information\nOriginal game by Maqqara and Modmj\nIf game crushed conctact to Aviener';
  11.      help = 'botmj is a game where you need to build your way to cheese by using a shaman objects\nCommands:\n!shop - show off a list of objects\n!^^ - some information';
  12.      info = 'Version: '..version..' ~';
  13.      shop = 'You are in a shop. Type <b>!buy</b> <i>code</i> to buy item\n!sp [<i>2 points</i>] - buy small plank\n!lp [<i>5 points</i>] - buy large plank\n!sb [<i>8 points</i>] - buy small box\n!bb [<i>11 points</i>] - buy large box';
  14.      congrats = 'Great job! You have successfully bought '
  15. }
  16.  
  17.  
  18. Module = {
  19.  
  20.  ['Start'] = function ()
  21.   tfm.exec.newGame(maps[math.random(#maps)])
  22.     started = false
  23.       for name,player in pairs(tfm.get.room.playerList) do
  24.     system.bindKeyboard(name, 40, true, true)
  25.     system.bindKeyboard(name, 83, true, true)
  26.     players[name] = {lvl = 0; count = 15; timestamp=os.time()}
  27.     end end;
  28.    
  29.     ['StartCountDown'] = function()
  30.     system.newTimer(function() tfm.exec.chatMessage('<font color="#98E2EB">[<b>Botmj</b>] <b>3</b></font>') end, 1000, false)
  31.     system.newTimer(function() tfm.exec.chatMessage('<font color="#98E2EB">[<b>Botmj</b>] <b>2</b></font>') end, 2000, false)
  32.     system.newTimer(function() tfm.exec.chatMessage('<font color="#98E2EB">[<b>Botmj</b>] <b>1</b></font>') end, 3000, false)
  33.     system.newTimer(function() tfm.exec.chatMessage('<font color="#98E2EB">[<b>Botmj</b>] <b>GO!</b></font>') end, 3250, false)
  34.     end;
  35.    
  36.     ['DeSpawn'] = function()
  37.     for i,obj in ipairs(toDespawn) do
  38.     if obj[1] <= os.time()-3000 then
  39.     tfm.exec.removeObject(obj[2])
  40.     table.remove(toDespawn,i)
  41.      end
  42.      end end;
  43.     }  
  44.  
  45.  
  46. Player = {
  47.  
  48.      ['SetasNew'] = function(name)
  49.          system.bindKeyboard(name, 40, true, true)
  50.          system.bindKeyboard(name, 83, true, true)
  51.          players[name] = {lvl = 0; count = 15; timestamp=os.time()}
  52.     end;
  53.    
  54.       ['Check'] = function(name, keyc)
  55.         if (key==40 or key==83) then
  56.           end
  57.           end;
  58.            
  59.        ['settNewRound'] = function ()
  60.             for name,player in pairs(tfm.get.room.playerList) do
  61.       players[name].count = 15
  62.       players[name].timestamp = os.time()
  63.       end end;
  64.      
  65.       ['CheckScore'] = function (name)
  66.          score = tfm.get.room.playerList[name].score
  67.        end
  68. }
  69.  
  70. ChatManager = {
  71.  
  72.         ['SendMessage'] = function (text, name)
  73.          tfm.exec.chatMessage('<font color="#e09a82">→[</font><font color="#d67e42"><b>Botmj</b></font><font color="#e09a82">] ' ..text..'</font>', name)
  74.         end; }
  75.          
  76. Spawn = {
  77.  
  78.    ['Anvil'] = function(name, x, y)
  79.         local id=tfm.exec.addShamanObject (10, x, y+10, 0, 0, 0, false)
  80.          players[name].timestamp=os.time()
  81.          table.insert(toDespawn,{os.time(),id})
  82.          end;
  83.          
  84.     ['SP'] = function(name, x, y)
  85.         local id=tfm.exec.addShamanObject (3, x, y+10, 0, 0, 0, false)
  86.          players[name].timestamp=os.time()
  87.          table.insert(toDespawn,{os.time(),id})
  88.          end;
  89.     ['LP'] = function(name, x,y)
  90.         local id=tfm.exec.addShamanObject (4, x, y+10, 0, 0, 0, false)
  91.           players[name].timestamp=os.time()
  92.          table.insert(toDespawn,{os.time(),id})
  93.     end;
  94.    
  95.     ['SB'] = function()
  96.          players[name].count = players[name].count - 1
  97.          local id=tfm.exec.addShamanObject (1, x, y+10, 0, 0, 0, false)
  98.          players[name].timestamp=os.time()
  99.          table.insert(toDespawn,{os.time(),id})
  100.     end;
  101.    
  102.     ['BB'] = function()
  103.          local id=tfm.exec.addShamanObject (2, x, y+10, 0, 0, 0, false)
  104.          players[name].timestamp=os.time()
  105.          table.insert(toDespawn,{os.time(),id})
  106.     end;
  107.     }
  108.  
  109. Module.Start()
  110.  
  111. function eventPlayerWon(name) tfm.exec.setPlayerScore(name, 1, true) players[name].count = 0 end
  112. function eventPlayerDied(name) players[name].count = 0 end
  113. function eventNewPlayer(name) Player.SetasNew(name) ChatManager.SendMessage(Messages.greet) end
  114. function eventChatCommand(name, cmd)
  115. score = tfm.get.room.playerList[name].score
  116. if cmd == 'help' then ChatManager.SendMessage(Messages.help)
  117. elseif cmd == '^^' then ChatManager.SendMessage(Messages.info)
  118. elseif cmd == 'sp' and score >=2 then players[name].lvl = 1 tfm.exec.setPlayerScore(name, -2, true) ChatManager.SendMessage(Messages.congrats..'small plank!', name)
  119. elseif cmd == 'lp' and score >=5 then players[name].lvl = 2 tfm.exec.setPlayerScore(name, -5, true) ChatManager.SendMessage(Messages.congrats..'large plank!', name)
  120. elseif cmd == 'sb' and score >=8 then players[name].lvl = 3 tfm.exec.setPlayerScore(name, -8, true)  ChatManager.SendMessage(Messages.congrats..'small box!', name)
  121. elseif cmd == 'bb' and score >=11 then players[name].lvl = 4 tfm.exec.setPlayerScore(name, -11, true)  ChatManager.SendMessage(Messages.congrats..'large box!', name) end end
  122.  
  123. function eventNewGame()
  124. started=false
  125. tfm.exec.setUIShamanName ('<b>Botmj</b>')
  126. Player.settNewRound()
  127. Module.StartCountDown()
  128. end
  129.  
  130. function eventKeyboard(name, keyc, down, x,y) Player.Check(name, keyc)
  131.    if started == true and players[name].timestamp < os.time()-500 and players[name].count >=1 then
  132.    players[name].count = players[name].count - 1
  133.    if players[name].lvl == 0 then Spawn.Anvil(name, x,y)
  134.    elseif players[name].lvl == 1 then Spawn.SP(name, x,y)
  135.    elseif players[name].lvl == 2 then Spawn.LP(name, x,y)
  136.    elseif players[name].lvl == 3 then Spawn.SB(name, x,y)
  137.    elseif players[name].lvl == 4 then Spawn.BB(name, x,y)
  138.    end
  139.    end end
  140.  
  141. function eventLoop(time,remaining)
  142. if remaining<=0 then
  143. tfm.exec.newGame(maps[math.random(#maps)])
  144. end
  145. if time >= 3000 and started == false then
  146. started=true
  147. end
  148. Module.DeSpawn()
  149. end
  150.  
  151. tfm.exec.newGame(maps[math.random(#maps)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement