Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Makinit's flattenFunctionTree
- do
- function flattenFunctionTree(tree, path)
- for name, value in pairs(tree) do
- if type(value) == "table" then
- flattenFunctionTree(value, path .. name .. "_")
- elseif type(value) == "function" then
- _G[path .. name] = value
- end
- end
- end
- local temp = {}
- for name, value in pairs(_G) do
- if value ~= _G then
- temp[name] = value
- end
- end
- flattenFunctionTree(temp, "")
- end
- local text={
- en={
- welcome = "Welcome my nibas"
- }
- }
- local _important,_info = 1,2
- local tags = {
- [0]={"",""},
- {"<VP><b>","</b>"},
- {"<J>",""}
- }
- local maps = {
- "113156","124000","149422","149451","150607","150651","150664","151655","152260","152733","153996","155480","155606","155611","155628","155765","156720","157004","157203","157805","157960","158345","158417","158909","159131","159187","159298","159932","160841","161023","161434","162482","163094","163159","163172","163506","163531","163596","164544","164916","165186","166032","166037","166056","166271","166333","166361","166430","166805","167075","168204","168754","169059","169076","169110","169139","169228","170514","171148","171480","171482","171776","172501","172512","172520","172547","172605","172621","172951","172976","173623","173816","174223","175204","175280","176253","176507","176619","176710","176729","179005","179488","179492","179807","180801","182370","182769","183139","183141","184648","184817","184868","185289","185428","185529","185873","185887","186066","186220","186378","189819","190646","190996","191177","191203","191205","191443","191642","192158","192959","193662","195116","197229","198988","199210","199710","199826","201000","202574","203664","204488","204647","205240","205506","206396","208056","208373","208653","208940","209848","213752","213755","213874","214631","214755","216171","216173","217261","220352","222377","222910","223174","223947","224108","225744","226266","230588","231137","231921","232469","232678","235037","236768","237091","242291","250153","254785","257218","257324","257715","258192","258908","259319","261298","261814","263819","263926","264091","268915","270143","270924","271193","271411","272183","272402","272518","272689","277427","277513","277824","279337","281948","282584","284134","286254","289865","290824","295465","295630","295932","297442","299942","299983","301610","302080","303151","303939","304861","305567","305614","305705","305820","306365","306384","306655","307324","313216","314743","315666","315800","316012","318129","319443","320483","320626","322582","327354","327743","329200","329318","329571","330933","330967","331344","331988","332130","332906","333002","336305","337644","342035","343456","354984","357814","361500","365061","368839","372255","372419","373105","375455","376704","378704","380516","383358","391924","392240","393426","394132","395216","395310","395961","397467","397469","397478","398116","399364","401630","403755","403940","406154","408577","408643","410040","410045","412467","412913","419369","419635","420877","422981","423311","424604","424685","424900","425747","425884","431433","431749","432501","435812","438333","438364","438449","439092","444589","447805","449496","454049","455271","457726","458528","460961","467137","476706","478236","482791","492222","492399","496610","496886","497965","499986","500000","500690","500748","500894","504485","505619","506032","506613","506940","510996","511136","512887","514311","522719","523270","528032","531084","536905","541223","541693","541729","543010","549666","551317","552986","556575","556841","557066","557074","560526","560583","562897","563436","564198","568122","571683","574183","575497","584783","586901","587501","592189","593164","593204","593431","593530","596239","598845","605255","608368","612415","618999","654894","684566","692650","692740","721319","722837","729863","758595","783547","801683","815336","834297","842019","842167","868262","881158","886744","898934","912356","914570","919484","970919","976944","999963","1000006","1004622","1014313","1018394","1046877","1066607","1111252","1130256","1156092","1157281","1162831","1164086","1225867","1226207","1242584","1255359","1256085","1265789","1266330","1301649","1303323","1323048","1333846","1383297","1384078","1390405","1398609","1403454","1410539","1413528","1427980","1435902","1494499","1503203","1526894","1531604","1540221","1580356","1580835","1593066","1595965","1615753","1615949","1620703","1647131","1678634","1722755","1733211","1788490","1807217","1809410","1923584","1955745","1989803","1990413","2024960","2040569","2130169","2178800","2311703","2329940","2416969","2423300","2451444","2469365","2520540","2636519","2788517","2794566","2795201","2846829","2989803","3038589","3136410","3199998","3295967","3326197","3333223","3380788","3456260","3551333","3668866","3668888","3690269","3907267","3908151","3988424","4000000","4067327","4074214","4445580"
- }
- local keys = {67,70,77,86}
- local _c = 67
- local _f = 70
- local _m = 77
- local _v = 86
- local gameFinished = true
- local gameLoaded
- local gameStarted
- local currentMap
- local playersInRoom = 0
- local mice = {}
- local teleport = {}
- local cheated = {}
- local timeList = {}
- local timeN = 0
- local msgList = {}
- function main()
- tfm_get_room_community = tfm.get.room.community
- tfm_exec_disableAfkDeath(true)
- tfm_exec_disableAutoNewGame(true)
- tfm_exec_disableAutoTimeLeft(true)
- tfm_exec_disableAutoShaman(true)
- tfm_exec_disableAutoScore(true)
- for n in pairs(tfm.get.room.playerList) do
- tfm_exec_setPlayerScore(n, 0)
- eventNewPlayer(n)
- end
- startGame()
- end
- function startGame()
- local newMap
- repeat
- newMap = math.random(#maps)
- until newMap ~= currentMap
- currentMap = newMap
- tfm_exec_newGame(maps[newMap])
- end
- function endGame()
- gameFinished = true
- tfm_exec_setGameTime(5)
- showTimeList()
- end
- function eventNewGame()
- gameLoaded = true
- gameStarted = false
- gameFinished = false
- tfm_exec_setGameTime(360)
- tfm_exec_setUIShamanName("Bootcamp")
- tfm_exec_setUIMapName("@"..tfm.get.room.xmlMapInfo.mapCode)
- teleport = {}
- cheated = {}
- viewingList = {}
- closeTimeList()
- timeList = {}
- timeN = 0
- end
- function eventNewPlayer(name)
- playersInRoom = playersInRoom + 1
- mice[name] = {
- }
- for _,k in pairs(keys) do
- tfm_exec_bindKeyboard(name, k, true)
- end
- system_bindMouse(name, true)
- msg(lang().welcome, name, _important)
- tfm_exec_respawnPlayer(name)
- end
- function eventPlayerLeft(name)
- playersInRoom = playersInRoom - 1
- mice[name] = nil
- end
- function eventPlayerDied(name)
- if gameFinished then return end
- tfm_exec_respawnPlayer(name)
- end
- function eventPlayerRespawn(name)
- cheated[name] = nil
- end
- function eventPlayerWon(name, _, t)
- if gameFinished then return end
- tfm_exec_respawnPlayer(name)
- local timeText
- if cheated[name] then
- timeText = "Cheater!"
- else
- local pos = 0
- for i=timeN,1,-1 do
- if t < timeList[i].t then
- timeList[i+1] = timeList[i]
- else
- pos = i
- break
- end
- end
- timeText = string.format("%02d:%02d:%02d", convertTime(t))
- if pos<60 then
- timeList[pos+1] = {n=name, t=t}
- if timeN < 60 then
- timeN = timeN + 1
- else
- timeList[61] = nil
- end
- if pos==0 then
- tfm_exec_setUIShamanName(name.." - "..timeText)
- end
- end
- tfm_exec_setPlayerScore(name, 1, true)
- end
- msgList[#msgList+1] = {n=name, ts=os.time()}
- ui_addTextArea(0, timeText, name, 20, 40, 120, 20)
- end
- function eventLoop(t, tr)
- if not gameLoaded then return end
- if not gameStarted then
- if t > 3000 then
- gameStarted = true
- end
- return
- end
- for i,m in ipairs(msgList) do
- if os.time() > m.ts + 2500 then
- ui_removeTextArea(0, m.n)
- table.remove(msgList, i)
- else
- break
- end
- end
- if not gameFinished and tr <= 0 then
- endGame()
- elseif gameFinished and tr <= 0 then
- startGame()
- end
- end
- function eventKeyboard(name, key, down, px, py)
- if key==_c then
- local tp = teleport[name]
- if tp then
- tfm_exec_movePlayer(name, tp.x, tp.y)
- cheated[name] = true
- end
- elseif key==_m then
- tfm_exec_killPlayer(name)
- elseif key==_f then
- tfm_exec_giveCheese(name)
- cheated[name] = true
- elseif key==_v then
- if viewingList[name] then
- closeTimeList(name)
- viewingList[name] = false
- else
- showTimeList(name)
- viewingList[name] = true
- end
- end
- end
- function eventMouse(name, mx, my)
- teleport[name] = {x=mx, y=my}
- end
- function eventChatCommand(name, com)
- if com=="mort" then
- tfm_exec_killPlayer(name)
- elseif com=="cheese" then
- tfm_exec_giveCheese(name)
- cheated[name] = true
- elseif com=="new" then
- startGame()
- elseif com=="test" then
- tfm_exec_newGame(1234567)
- end
- end
- function eventTextAreaCallback(id, name, cb)
- if id==3 then
- closeTimeList(name)
- viewingList[name] = false
- end
- end
- function showTimeList(name)
- ui_addTextArea(1, "<p align='center'><font size='16'>Completion times</font></p>", name, 270, 60, 260, 320)
- ui_addTextArea(2, "list", name, 280, 100, 240, 270)
- ui_addTextArea(3, "<a href='event:close'><p align='center'>X</p></a>", name, 550, 60, 20, 20, 0x882222)
- updateTimeList(name)
- end
- function updateTimeList(name)
- local s=""
- for i=1,timeN do
- local t = timeList[i]
- tm,ts,th = convertTime(t.t)
- s=s..string.format("%02d - %02d:%02d:%02d - %013s\n", i, tm, ts, th, t.n)
- end
- ui_updateTextArea(2, s, name)
- end
- function closeTimeList(name)
- for i=1,3 do
- ui_removeTextArea(i, name)
- end
- end
- function msg(msg, tgt, tag)
- tag = tags[tag or 0]
- tfm_exec_chatMessage(tag[1]..msg..tag[2], tgt)
- end
- function lang()
- return text[tfm_get_room_community] or text.en
- end
- function hundredthsToMinutes(h)
- return math.floor(h/6000)
- end
- function hundredthsToSeconds(h)
- return math.floor(h/100)
- end
- function convertTime(time)
- local min = hundredthsToMinutes(time)
- time = time - min*6000
- local sec = hundredthsToSeconds(time)
- time = time - sec*100
- return min,sec,time
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement