Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local players = {}
- local maps = {'@6509524', '@6509938', '@6509942', '@6509617', '@6509625', '@324046', '@321307', '@321294', '@6509961', ''}
- local toDespawn = {}
- local version = 'Beta 4'
- tfm.exec.disableAutoScore(true)
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAutoNewGame(true)
- Messages = {
- greet = 'Welcome to <b>botmj</b>! Type !help for more information\nOriginal game by Maqqara and Modmj\nIf game crushed conctact to Aviener';
- 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';
- info = 'Version: '..version..' ~';
- 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';
- congrats = 'Great job! You have successfully bought '
- }
- Module = {
- ['Start'] = function ()
- tfm.exec.newGame(maps[math.random(#maps)])
- started = false
- for name,player in pairs(tfm.get.room.playerList) do
- system.bindKeyboard(name, 40, true, true)
- system.bindKeyboard(name, 83, true, true)
- players[name] = {lvl = 0; count = 15; timestamp=os.time()}
- end end;
- ['StartCountDown'] = function()
- system.newTimer(function() tfm.exec.chatMessage('<font color="#98E2EB">[<b>Botmj</b>] <b>3</b></font>') end, 1000, false)
- system.newTimer(function() tfm.exec.chatMessage('<font color="#98E2EB">[<b>Botmj</b>] <b>2</b></font>') end, 2000, false)
- system.newTimer(function() tfm.exec.chatMessage('<font color="#98E2EB">[<b>Botmj</b>] <b>1</b></font>') end, 3000, false)
- system.newTimer(function() tfm.exec.chatMessage('<font color="#98E2EB">[<b>Botmj</b>] <b>GO!</b></font>') end, 3250, false)
- end;
- ['DeSpawn'] = function()
- for i,obj in ipairs(toDespawn) do
- if obj[1] <= os.time()-3000 then
- tfm.exec.removeObject(obj[2])
- table.remove(toDespawn,i)
- end
- end end;
- }
- Player = {
- ['SetasNew'] = function(name)
- system.bindKeyboard(name, 40, true, true)
- system.bindKeyboard(name, 83, true, true)
- players[name] = {lvl = 0; count = 15; timestamp=os.time()}
- end;
- ['Check'] = function(name, keyc)
- if (key==40 or key==83) then
- end
- end;
- ['settNewRound'] = function ()
- for name,player in pairs(tfm.get.room.playerList) do
- players[name].count = 15
- players[name].timestamp = os.time()
- end end;
- ['CheckScore'] = function (name)
- score = tfm.get.room.playerList[name].score
- end
- }
- ChatManager = {
- ['SendMessage'] = function (text, name)
- tfm.exec.chatMessage('<font color="#e09a82">→[</font><font color="#d67e42"><b>Botmj</b></font><font color="#e09a82">] ' ..text..'</font>', name)
- end; }
- Spawn = {
- ['Anvil'] = function(name, x, y)
- local id=tfm.exec.addShamanObject (10, x, y+10, 0, 0, 0, false)
- players[name].timestamp=os.time()
- table.insert(toDespawn,{os.time(),id})
- end;
- ['SP'] = function(name, x, y)
- local id=tfm.exec.addShamanObject (3, x, y+10, 0, 0, 0, false)
- players[name].timestamp=os.time()
- table.insert(toDespawn,{os.time(),id})
- end;
- ['LP'] = function(name, x,y)
- local id=tfm.exec.addShamanObject (4, x, y+10, 0, 0, 0, false)
- players[name].timestamp=os.time()
- table.insert(toDespawn,{os.time(),id})
- end;
- ['SB'] = function()
- players[name].count = players[name].count - 1
- local id=tfm.exec.addShamanObject (1, x, y+10, 0, 0, 0, false)
- players[name].timestamp=os.time()
- table.insert(toDespawn,{os.time(),id})
- end;
- ['BB'] = function()
- local id=tfm.exec.addShamanObject (2, x, y+10, 0, 0, 0, false)
- players[name].timestamp=os.time()
- table.insert(toDespawn,{os.time(),id})
- end;
- }
- Module.Start()
- function eventPlayerWon(name) tfm.exec.setPlayerScore(name, 1, true) players[name].count = 0 end
- function eventPlayerDied(name) players[name].count = 0 end
- function eventNewPlayer(name) Player.SetasNew(name) ChatManager.SendMessage(Messages.greet) end
- function eventChatCommand(name, cmd)
- score = tfm.get.room.playerList[name].score
- if cmd == 'help' then ChatManager.SendMessage(Messages.help)
- elseif cmd == '^^' then ChatManager.SendMessage(Messages.info)
- elseif cmd == 'sp' and score >=2 then players[name].lvl = 1 tfm.exec.setPlayerScore(name, -2, true) ChatManager.SendMessage(Messages.congrats..'small plank!', name)
- elseif cmd == 'lp' and score >=5 then players[name].lvl = 2 tfm.exec.setPlayerScore(name, -5, true) ChatManager.SendMessage(Messages.congrats..'large plank!', name)
- elseif cmd == 'sb' and score >=8 then players[name].lvl = 3 tfm.exec.setPlayerScore(name, -8, true) ChatManager.SendMessage(Messages.congrats..'small box!', name)
- 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
- function eventNewGame()
- started=false
- tfm.exec.setUIShamanName ('<b>Botmj</b>')
- Player.settNewRound()
- Module.StartCountDown()
- end
- function eventKeyboard(name, keyc, down, x,y) Player.Check(name, keyc)
- if started == true and players[name].timestamp < os.time()-500 and players[name].count >=1 then
- players[name].count = players[name].count - 1
- if players[name].lvl == 0 then Spawn.Anvil(name, x,y)
- elseif players[name].lvl == 1 then Spawn.SP(name, x,y)
- elseif players[name].lvl == 2 then Spawn.LP(name, x,y)
- elseif players[name].lvl == 3 then Spawn.SB(name, x,y)
- elseif players[name].lvl == 4 then Spawn.BB(name, x,y)
- end
- end end
- function eventLoop(time,remaining)
- if remaining<=0 then
- tfm.exec.newGame(maps[math.random(#maps)])
- end
- if time >= 3000 and started == false then
- started=true
- end
- Module.DeSpawn()
- end
- tfm.exec.newGame(maps[math.random(#maps)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement