Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ http://www.transformice.com/forum/?s=715842&p=0 Challenge_1 ]]
- listP = {}
- godOfSpeed = " "
- godSelect = " "
- itL = "<p align='center'><a href='event:-10'>«</a><a href='event:-1'><</a> "
- itR = " <a href='event:+1'>></a><a href='event:+10'>»</a></p>"
- function init()
- for name, key in pairs(tfm.get.room.playerList) do
- eventNewPlayer(name)
- end
- end
- function eventNewGame()
- ui.removeTextArea(2, godOfSpeed)
- godOfSpeed = listP[math.random(#listP)]['name']
- godSelection = godOfSpeed
- print("Your new god of speed is "..godOfSpeed)
- ui.addTextArea(2, "<a href='event:listP'>•</a>", godOfSpeed,345, 375, 20, 20, 1, 1, 0, true)
- end
- function eventNewPlayer(name)
- ui.addTextArea(1, itL.."0"..itR, name, 355, 375, 90, 20, 1, 1, 0, true)
- table.insert(listP, {['name']=name, ['vx']=0, ['vy']=0 })
- end
- function eventPlayerLeft(name)
- table.remove(listP, findPlayer(listP, name))
- if name == godSelection then godSelection = godOfSpeed end
- end
- function eventTextAreaCallback(id, name, call)
- if id == 1 then
- god = name == godOfSpeed
- cible = (god and godSelection) or name
- cibleK = findPlayer(listP, cible)
- listP[cibleK]["vx"] = listP[cibleK]["vx"] + ((god and call) or callV(listP[cibleK]["vx"], call))
- if listP[cibleK]["vx"] ~= 0 then tfm.exec.movePlayer(cible, 0, 0, true, listP[cibleK]["vx"] , tfm.get.room.playerList[cible]['vy'], false) end
- ui.updateTextArea(1, itL..tostring(listP[cibleK]["vx"])..itR, cible)
- if name == godOfSpeed then ui.updateTextArea(1, itL..tostring(listP[cibleK]["vx"])..itR, name) end
- elseif id == 2 then
- for key, tab in ipairs(listP) do ui.addTextArea(key+2, "<a href='event:"..tab.name.."'>"..tab.name.."</a>", godOfSpeed, 270, 375-(key-1)*13, 70, 15, 1, 1, 0, true) end
- elseif id >= 3 then
- godSelection = call
- for key in ipairs(listP) do ui.removeTextArea(key + 2, godOfSpeed) end
- end
- end
- function callV (v, add)
- local vT = v + add
- if vT < -50 then
- return -v-50
- else
- return ((vT < 50 and add) or 50-v)
- end
- end
- function findPlayer(tab, name)
- for key, elmt in pairs(tab) do
- if elmt.name == name then return key end
- end
- end
- init()
- tfm.exec.newGame(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement