Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- maps = {
- "10","15","14", }
- local keys = {space = 32}
- local places = 0
- local players = {}
- local shop = {
- {n = "Meep (Spacebar to use)",
- cost = 25,
- effect = function(n)
- tfm.exec.giveMeep(n)
- end,
- },
- {n = "Speed (Spacebar to use)",
- cost = 60,
- effect = function(n)
- tfm.exec.bindKeyboard(n, keys.space, true, true)
- end,
- },
- }
- function main()
- for n in pairs(tfm.get.room.playerList) do
- eventNewPlayer(n)
- end
- end
- function newGame()
- local code = specialMaps[math.random(#specialMaps)]
- tfm.exec.newGame(code)
- end
- function showShop(n)
- if players[n].openShop then
- local shopStr = ""
- for i, item in pairs(shop) do
- shopStr = "<a href='event:shop_"..i.."'>["..item.cost.."] "..item.n.."</a><br>"..shopStr
- end
- ui.addTextArea(0, "<font size='12' face='Wingdings'><p align='center'><a href='event:close'><rose><a href='event:close'>z <font size='12' face='Calibri'>"..players[n].coins, n, 10, 30, 60, 19, 0x212e35, 0x5d7d90, 0.5, true)
- ui.addTextArea(1, "<br><br>"..shopStr, n, 250, 80, 300, 200, 0x324650, 0x5d7d90, 1, true)
- ui.addTextArea(2, "<font size='14' face='Calibri'><p align='center'>Shop", n, 250, 80, 298, 20, 0x212e35, 0x5d7d90, 1, true)
- ui.addTextArea(3, "<font size='16' face='Calibri'><p align='center'><a href='event:close'><v>X", n, 520, 78, 29, 29, 0x324650, 0x000000, 0, true)
- else
- ui.addTextArea(0, "<font size='12' face='Wingdings'><p align='center'><a href='event:close'><rose><a href='event:open'>z <font size='12' face='Calibri'>"..players[n].coins, n, 10, 30, 60, 19, 0x212e35, 0x5d7d90, 0.5, true)
- end
- end
- function eventNewGame()
- places = 0
- end
- function eventKeyboard(n, key, down, x, y)
- local data = tfm.get.room.playerList[n]
- if key == keys.space then
- local dir = data.isFacingRight and 1 or -1
- tfm.exec.movePlayer(n, 0, 0, false, 80 * dir, 0, false)
- tfm.exec.bindKeyboard(n, keys.space, true, false)
- end
- end
- function eventPlayerWon(n)
- local player = players[n]
- places = places + 1
- if places == 1 then
- player.coins = player.coins + 20
- elseif places == 2 then
- player.coins = player.coins + 15
- elseif places == 3 then
- player.coins = player.coins + 5
- end
- showShop(n)
- end
- function eventNewPlayer(n)
- if not players[n] then
- players[n] = {
- coins = 0,
- openShop = false,
- }
- end
- showShop(n)
- end
- function eventTextAreaCallback(id, n, cb)
- local player = players[n]
- if cb == "close" then
- for i = 0, 3, 1 do
- ui.removeTextArea(i, n)
- end
- player.openShop = false
- elseif cb == "open" then
- player.openShop = true
- elseif cb:sub(1, 4) == "shop" then
- local i = tonumber(cb:sub(6))
- local item = shop[i]
- if item.cost <= player.coins then
- player.coins = player.coins - item.cost
- if item.effect then item.effect(n) end
- end
- end
- showShop(n)
- end
- main()
- newGame()
- function eventPlayerDied(name)
- if not data[name].CheeseGhost then
- local i=0
- local n
- for pname,player in pairs(tfm.get.room.playerList) do
- if not player.isDead then
- i=i+1
- n=pname
- end
- end
- if i==0 then
- tfm.exec.setGameTime(2)
- elseif i==1 then
- tfm.exec.setGameTime(20)
- end
- else
- data[name].CheeseGhost=false
- end
- end
- tfm.exec.newGame(maps[math.random(#maps)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement