Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- settings
- tfm.exec.disableAutoTimeLeft(disable)
- tfm.exec.disableAfkDeath(disable)
- tfm.exec.disableAllShamanSkills(disable)
- tfm.exec.disableAutoScore(disable)
- tfm.exec.disableAutoNewGame(disable)
- tfm.exec.disableMortCommand(disable)
- tfm.exec.disableAutoShaman(disable)
- initialMap = "@7640468"
- tfm.exec.newGame(initialMap)
- roundStart = false
- -- constants
- playerData = {}
- -- functions
- findIndex = function(value, array)
- rArray = {}
- for i=1, #array do
- rArray[array[i]] = i
- end
- return rArray[value]
- end
- pythag = function(x1,y1,x2,y2,range)
- return ((x1 - x2)^2 + (y1 - y2)^2 < range^2)
- end
- generateCollectables = function(playerName)
- for i=1,4 do
- local randInt = math.random(1, #spawners.x)
- local index = #playerData[playerName].collectables.x
- playerData[playerName].collectables.x[index+1] = spawners.x[randInt]
- playerData[playerName].collectables.y[index+1] = spawners.y[randInt]
- end
- end
- spawnCollectables = function(playerName)
- for i=1, #playerData[playerName].collectables.x do
- ui.addTextArea(500 + i-1, "?", playerName, playerData[playerName].collectables.x[i]-5, playerData[playerName].collectables.y[i]-5, 20, 20, 0x000000, 0x000001, 0, false)
- end
- end
- createRing = function(playerName, x, y, r1, r2, alpha, fineness, i)
- num = 0
- while num <= 2*math.pi do
- ui.addTextArea(i, "", playerName, r1*math.cos(num)+x-r2/2, r1*math.sin(num)+y-r2/2, r2, r2, 0x000000, 0x000001, alpha, true)
- num = num + 2*math.pi/fineness
- if i then
- i = i + 1
- end
- end
- return i
- end
- nightMode = function(playerName)
- i = 0
- x = 400
- y = 250
- i = createRing(playerName, x, y, 90, 35, 0.5, 25, i)
- i = createRing(playerName, x, y, 120, 40, 0.66, 30, i)
- i = createRing(playerName, x, y, 160, 50, 0.83, 40, i)
- ui.addTextArea(i, "", playerName, 545, 0, 255, 400, 0x000000, 0x000001, 1, true)
- i=i+1
- ui.addTextArea(i, "", playerName, 0, 0, 255, 400, 0x000000, 0x000001, 1, true)
- i=i+1
- ui.addTextArea(i, "", playerName, 0, 0, 800, 123, 0x000000, 0x000001, 1, true)
- i=i+1
- ui.addTextArea(i, "", playerName, 0, 375, 800, 25, 0x000000, 0x000001, 1, true)
- i=i+1
- end
- -- events
- eventNewPlayer = function(playerName)
- if not playerData[playerName] then
- playerData[playerName] = {collectables = {x = {}, y = {}}}
- end
- tfm.exec.bindKeyboard(playerName, 40, true, true)
- tfm.exec.bindKeyboard(playerName, 83, true, true)
- nightMode(playerName)
- tfm.exec.setPlayerScore(playerName, 0, false)
- end
- eventNewGame = function()
- local xml = (tfm.get.room.xmlMapInfo.xml or '<C><P /><Z><S /><D /><O /></Z></C>')
- spawners = {x = {},y = {}}
- if xml:find('<O') then -- creds to Ratufufu for finding the x and ys of the yellow nails
- for data in xml:gmatch('<O(.-)/>') do
- if data:find('C="22"') then
- spawners.x[#spawners.x + 1] = (tonumber(data:match('X="(.-)"')) or 0)
- spawners.y[#spawners.x + 1] = (tonumber(data:match('Y="(.-)"')) or 0)
- end
- end
- end
- for k, v in next, tfm.get.room.playerList do
- generateCollectables(v.playerName)
- spawnCollectables(v.playerName)
- tfm.exec.respawnPlayer(v.playerName)
- end
- roundStart = true
- end
- eventKeyboard = function(playerName, keyCode, down)
- if keyCode == 40 or keyCode == 83 then
- for i=1, #playerData[playerName].collectables.x do
- if pythag(playerData[playerName].collectables.x[i], playerData[playerName].collectables.y[i], tfm.get.room.playerList[playerName].x, tfm.get.room.playerList[playerName].y, 40) then
- local randInt = math.random(1, #spawners.x)
- print(spawners.x[randInt] .. "," .. spawners.y[#spawners.x])
- playerData[playerName].collectables.x[i] = spawners.x[randInt]
- playerData[playerName].collectables.y[i] = spawners.y[randInt]
- print(randInt)
- ui.addTextArea(500 + i-1, "?", playerName, spawners.x[randInt]-5, spawners.y[randInt]-5, 20, 20, 0x000000, 0x000001, 0, false)
- tfm.exec.setPlayerScore(playerName, 1, true)
- end
- end
- end
- end
- -- execution
- for k, v in next, tfm.get.room.playerList do
- eventNewPlayer(v.playerName)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement