Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- collected = {} --what items were collected by player y, per player
- coords = {{x = 500, y = 325},{x = 100, y = 325},{x = 200, y = 325},{x = 300, y = 325},{x = 400, y = 325}} --coords for each item/ground//whatever
- size = 10 --in pixels, the item hitbox is 2*size by 2*size
- function eventNewPlayer(name)
- tfm.exec.bindKeyboard(name,32,true,true)
- ui.addTextArea(0,"",name,5,27,nil,nil,0x32464F,0x32464F,0.9,false)
- end
- function eventKeyboard(name,key,up,x,y)
- if (key == 32) and (#collected[name] ~= #coords) then
- for i=1,#coords do
- local exists = false
- for _,ob in pairs(collected[name]) do
- if ob == i then
- exists = true
- end
- end
- if exists == false then
- if (tfm.get.room.playerList[name].x >= coords[i].x - size) and (tfm.get.room.playerList[name].x <= coords[i].x +size) and (tfm.get.room.playerList[name].y >= coords[i].y - size) and (tfm.get.room.playerList[name].y <= coords[i].y + size) then
- ui.updateTextArea(0,"Item " ..i.. " collected",name)
- table.insert(collected[name], i)
- if #collected[name] == #coords then
- ui.updateTextArea(0,"You have collected all the items!", name)
- tfm.exec.giveCheese(name)
- tfm.exec.playerVictory(name)
- end
- end
- end
- end
- end
- end
- function eventMouse(name, x, y)
- tfm.exec.movePlayer(name, x, y, false, -1, -1, false)
- end
- function eventNewGame()
- for name,player in pairs(tfm.get.room.playerList) do
- collected[name] = {}
- ui.updateTextArea(0,"",name)
- end
- for i=1,#coords do
- tfm.exec.addPhysicObject(i, coords[i].x, coords[i].y, {type=4, width=20, height=20, foreground=false, miceCollision=false, dynamic=false})
- end
- end
- tfm.exec.disableAutoShaman(true)
- tfm.exec.newGame("@0")
- for name,player in pairs(tfm.get.room.playerList) do
- eventNewPlayer(name)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement