Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --People who want to join lua it's not a good idea to copy this.
- --Globals
- map={}
- shaman={}
- players={}
- roomLang=tfm.get.room.community
- loaded=false
- --Cool cats incorporated
- admins={
- "Thewav",
- "Gogoninja",
- "Fxie",
- "Begentle"
- }
- --All the maps
- maps={
- --Difficulty : 1
- {"98","72","36","5","17","16","91","90","93","4","0","40","3","66","@145968","@156966","@129420","@243562","@157033","@365011","@426398"},
- --Difficulty : 2
- {"@126092","@173024","@120806","@237106","@165741","@187088","@299158","@182878","@156104","@306731","@158963","@159709","@340220","@576319","@595756","@500471","@596640","@1324782","@392150","@497021","@576456","@1655360","@420875","@740663","@953233","@1900072","@460646","@222673","@348367","@2080619","@1641473","@1974090","@326777"},
- --Difficulty : 3
- {"@166138","@215312","@164213","@252478","@169710","@172357","@155582","@215337","@151712","@165565","@199112","@157743","@182896","@213781","@184833","@131444","@149095","@361032","@239941","@184961","@310507","@448567","@206400","@196584","@508150","@176748","@442510","@224120","@798052","@499562","@384181","@511088","@273240","@1331620","@413750","@268534","@187466","@1411844","@183895","@505403","@950364","@1203037","@1143235","@1317866","@521183","@1547749","@2116521","@781753","@1751612","@388828","@1233889","@1777037","@2068355","@1618577","@953826","@2012449","@757907","@1796429","@1786437","@2209096","@2462668","@1746907","@2092021","@268191","@3120329","@3298111"},
- --Difficulty : 4
- {"@263781","@194688","@219444","@196529","@156461","@191222","@234665","@355630","@164663","@158480","@168872","@187059","@220435","@198928","@185911","@171093","@178025","@183740","@185090","@198246","@315827","@202863","@171097","@364705","@193690","@553883","@261584","@365009","@868945","@1701298","@1092673","@858366","@2038478","@1620772","@1949565","@2088714","@2878646","@2092977","@2129724","@3112222","@1669376","@1766183","@2138532","@2472758","@771582"},
- --Difficulty : 5
- {"@200017","@185570","@217636","@188815","@232796","@188810","@191021","@245354","@714532","@188816","@188821","@714532","@178354","@256626","@164118","@202107","@180000","@187136","@198666","@180079","@158280","@196843","@190415","@226758","@173231","@314322","@263777","@232664","@205541","@235616","@308787","@230521","@215419","@183705","@214161","@196702","@307703","@417959","@182121","@257766","@227056","@221709","@247831","@241331","@481062","@307669","@258688","@740158","@476149","@314374","@199936","@212588","@609692","@308831","@356895","@968374","@359813","@379440","@262174","@2363288","@1751914","@1938417","@1995986","@2126726","@1203208","@2703245","@401476","@3262738","@2964954","@2096219"},
- --Difficulty : 6
- {"@235625","@238131","@197214","@198940","@234373","@188813","@193340","@213336","@210113","@209554","@232698","@241344","@225254","@244332","@264934","@194703","@242120","@203474","@196275","@187081","@188818","@206502","@192668","@237240","@233480","@387184","@212456","@295751","@199394","@200667","@212526","@214593","@212573","@206881","@355007","@343593","@335523","@276705","@236693","@551627","@217836","@276705","@236693","@551627","@217836","@225132","@322562","@213725","@240475","@205448","@227051","@258638","@334816","@969655","@305377","@306675","@416256","@338383","@923918","@352614","@1629869","@1481868","@1461340","@2371243","@2998412","@1345939","@2494537","@2359943","@3111491","@1494939","@2923482","@2412377","@3008779"},
- --Difficulty : 7
- {"@231731","@206992","@197353","@188823","@188820","@198024","@204088","@209528","@217864","@219864","@209446","@247680","@230991","@205344","@198784","@263784","@197293","@231132","@196828","@233166","@226248","@208640","@217000","@237064","@192020","@187080","@283029","@201801","@216219","@288084","@262099","@307610","@252937","@234380","@218468","@197595","@319985","@207798","@236796","@233629","@205419","@240739","@194233","@238375","@236131","@237406","@370752","@238455","@401492","@241457","@245860","@220335","@242375","@226413","@214937","@268623","@357228","@252048","@315809","@299382","@249822","@330892","@312031","@481056","@338181","@257757","@231528","@242278","@399349","@208736","@191592","@341559","@258637","@274146","@271587","@289645","@615238","@320494","@468071","@503884","@545807","@287449","@260221","@527447","@233649","@227971","@414660","@519242","@1417248","@414661","@846342","@512456","@417810","@553899","@752417","@542413","@556279","@733440","@234115","@520924","@2472679","@1423563","@1691055","@967215","@2406146","@1403042","@770904","@812076","@999188","@2023691","@1244150","@3176673","@2459719","@2841670","@2501595","@2852108","@2703587","@2998240","@2767741","@3056124","@2005081","@3184079","@1418785"},
- --Difficulty : 8
- {"@234123","@188822","@226778","@321526","@267955","@236791","@232571","@235336","@264225","@233647","@219832","@196829","@193002","@264915","@234632","@204664","@203470","@216341","@206309","@242370","@248286","@242983","@306627","@268246","@370516","@444297","@369747","@220380","@260509","@411326","@244891","@311356","@215993","@241751","@358290","@230969","@234309","@267842","@396930","@425908","@241553","@296711","@443132","@338190","@547559","@265010","@364005","@277898","@217526","@404228","@335297","@388986","@257186","@264935","@236798","@447984","@276392","@240682","@474472","@373987","@277983","@336989","@391241","@739499","@378580","@252438","@511728","@365768","@263329","@467414","@627202","@441346","@624118","@731489","@380166","@466490","@749021","@345151","@568364","@446198","@462403","@514457","@242459","@515899","@626181","@506517","@619280","@1340877","@534718","@578388","@814410","@231265","@593131","@785898","@1166601","@482681","@2127662","@528312","@1701589","@607825","@994954","@779801","@2389050","@763472","@735805","@1413649","@1351329","@2310061","@2534197","@959180","@1929795","@2331792","@998473","@1410949","@600603","@2840630","@2544586","@2537023","@2810439","@2799635","@2928258","@476182","@2978051","@2388832"},
- --Difficulty : 9
- {"@242369","@231308","@214832","@234430","@210051","@205530","@264943","@376296","@373949","@360293","@446312","@476210","@234352","@203079","@455544","@264936","@337908","@311349","@282609","@315828","@218679","@199601","@373344","@448969","@399871","@377583","@425781","@465681","@476209","@206508","@469323","@495986","@492211","@342786","@370472","@588036","@763403","@584718","@227131","@575724","@455636","@392885","@450444","@500142","@366667","@454431","@449352","@426294","@450439","@763385","@722487","@1449740","@441360","@883592","@615403","@567350","@1541093","@506058","@1375151","@619677","@696092","@692479","@726596","@632273","@713910","@1366068","@602412","@1788125","@781651","@1402219","@1081183","@476201","@2829045","@1915615","@2945559","@1649747","@2537078","@1448991","@2414363","@3062525","@2777149","@2780650","@2639999","@2777341","@1111111","@2408475","@3216511","@3049564","@2978100"},
- --Difficulty : 10
- {"@287311","@280839","@514036","@309436","@369744","@234917","@367050","@476207","@503546","@1446346","@203108","@566172","@1745954","@731853","@743329","@3181150","@599878"}
- }
- --All the words
- text={
- welcome="Welcome to the %s minigame. Press %s or write %s for more information.",
- help="Welcome to Room Spiritual!",
- help_setdiff="%s : set difficulty (range must be at least 2)",
- help_skip="%s : skip the map if you are shaman",
- help_mort="%s : die (same as /mort)",
- newgame="%s %s by %s - Difficulty : %d\n%s Shaman : %s - Level : %d",
- get_xp="You got %s Room XP!",
- level_up="%s is now Room Level %s!",
- setlang="Language set : %s",
- setdiff="Set difficulty : %d - %d",
- setdiff_invalid="Invalid difficulty! Try %s instead.",
- spirit_warning="You used %d / %d spirits allowed!",
- stats="%s's Stats: \n Setdiff %s, Level %s, Experience %s"
- }
- text.EN=text
- text.BR={
- welcome="Bem vindo a sala %s. Aperte %s ou escreva %s para mais informações",
- help="",
- help_setdiff="",
- help_skip="",
- help_mort="",
- newgame="%s %s by %s - Difficulty : %d\n%s Shaman : %s - Level : %d",
- get_xp="",
- level_up="",
- setlang="Idioma da sala alterado para o %s",
- setdiff="Alcance de sua dificuldade: %d - %d",
- setdiff_invalid="Jogadores com nova rosa podem te ajudar.",
- spirit_warning="Cuidado! Você só pode usar mais %d / %d spirit(s).",
- stats="%s's stats: \n Setdiff %s, Level %s, Experience %s"
- }
- --Administration
- function isAdmin(name)
- for i,admin in ipairs(admins) do
- if name==admin then
- return true
- end
- end
- return false
- end
- --Send chat messages catered toward your speaking
- function sendChatMessage(message,name,prefix,f)
- if name~=nil then
- message=(text[players[name].lang] or text)[message] or "ERROR"
- if prefix then
- message=prefix..message
- end
- if f then
- message=message:format(f[1],f[2],f[3],f[4],f[5],f[6],f[7],f[8],f[9])
- end
- tfm.exec.chatMessage(message,name)
- else
- for name,player in pairs(tfm.get.room.playerList) do
- sendChatMessage(message,name,prefix,f)
- end
- end
- end
- --Game begin
- function eventNewGame()
- tfm.exec.setShaman(shaman.name)
- tfm.exec.setUIMapName("<CH>"..map.code.."<N> - Difficulty "..map.diff)
- tfm.exec.setUIShamanName("<CH>"..shaman.name.."<N> Lv. "..shaman.level)
- map.author="Unknown"
- if tfm.get.room.xmlMapInfo~=nil then
- map.author=tfm.get.room.xmlMapInfo.author
- end
- sendChatMessage("newgame",nil,"<ROSE>",{
- "[•Map Info]<N>","<CH>"..map.code.."<N>",map.author,map.diff,
- "<ROSE>[•Map Info]<N>","<CH>"..shaman.name.."<N>",shaman.level
- })
- end
- --Game goes on
- function eventLoop(time,remaining,queue)
- if remaining<=500 then
- if shaman.saves~=nil and shaman.saves>0 then
- local xpgain=shaman.saves*map.diff+map.diff*10
- shaman.xp=shaman.xp+xpgain
- sendChatMessage("get_xp",shaman.name,"<CH>",{"<N>"..xpgain.."<CH>"})
- local nextLv=100*shaman.level+100
- if shaman.xp>nextLv then
- shaman.xp=shaman.xp-nextLv
- shaman.level=shaman.level+1
- sendChatMessage("level_up",nil,"<J>",{shaman.name,shaman.level})
- end
- end
- local topScore=-1
- for name,player in pairs(tfm.get.room.playerList) do
- if player.score>topScore and not player.isShaman then
- topScore=player.score
- shaman=players[name]
- end
- end
- shaman.saves=0
- shaman.spirits=0
- shaman.died=false
- tfm.exec.setPlayerScore(shaman.name,1,true)
- tmp = {}
- if queue==nil then
- for diff=shaman.diffMin ,shaman.diffMax do
- for _,value in ipairs(maps[diff]) do
- table.insert(tmp,value)
- end
- end
- map.code=tmp[math.random(#tmp)]
- for diff=shaman.diffMin,shaman.diffMax do
- for _,value in ipairs(maps[diff]) do
- if value==map.code then
- map.diff=diff
- end
- end
- end
- else
- map.diff=-1
- map.code=queue
- end
- if map.code == nil then
- Tfm.exec.setGameTime(5)
- else
- tfm.exec.setGameTime(5)
- tfm.exec.newGame(map.code)
- end
- end
- end
- --Players join
- function eventNewPlayer(name)
- tfm.exec.bindKeyboard(name,9,true,true)
- if not players[name] then
- players[name]={
- name=name,
- lang=roomLang,
- xp=0,
- level=1,
- diffMin=1,
- diffMax=5
- }
- end
- if isAdmin(name) then
- tfm.exec.setNameColor(name,"0xFE8CFF")
- end
- sendChatMessage("welcome",name,"<N>",{"<CH>SPIRITUAL<N>","<CH>TAB<N>","<CH>!help<N>"})
- end
- --Players die
- function eventPlayerDied(name)
- if name==shaman.name and not shaman.died then
- shaman.died=true
- tfm.exec.setGameTime(20,true)
- end
- for name,player in pairs(tfm.get.room.playerList) do
- if not player.isDead then
- return
- end
- end
- eventLoop(0,0)
- end
- --Players achieve victory
- function eventPlayerWon(name)
- if name~=shaman.name then
- shaman.saves=shaman.saves+1
- end
- for name,player in pairs(tfm.get.room.playerList) do
- if not player.isDead then
- return
- end
- end
- eventLoop(0,0)
- end
- --Players press keys
- function eventKeyboard(name,key,down,x,y)
- if key==9 then
- eventChatCommand(name,"help")
- end
- end
- --Shamans summon
- function eventSummoningEnd(name,id,x,y,angle,xSpeed,ySpeed,object,other)
- if id==24 then
- shaman.spirits=shaman.spirits+1
- if shaman.spirits>3 then
- eventLoop(0,0)
- else
- sendChatMessage("spirit_warning",name,"<R>",{shaman.spirits,3})
- end
- end
- end
- --Chat commands
- function eventChatCommand(name,message)
- --Prepwork
- local args={}
- local admin=isAdmin(name)
- for arg in message:gmatch("[^%s]+") do
- table.insert(args,arg:lower())
- end
- message=message:match("%s(.*)") or ""
- --Cmd: help
- if args[1]=="help" or args[1]=="info" or args[1]=="sync" then
- local text=text[players[name].lang] or text
- ui.addPopup(1,0,table.concat({
- "<b>"..(text.help or "HELP").."</b>",
- (text.help_setdiff or "SETDIFF"):format("<font color='#98E2EB'>!setdiff x-y</font>"),
- (text.help_skip or "SKIP"):format("<font color='#98E2EB'>!skip</font>"),
- (text.help_mort or "MORT"):format("<font color='#98E2EB'>!mort</font>")
- },"\n\n"),name,300,150,200)
- --Cmd: set difficulty
- elseif args[1]=="setdiff" then
- local min,max
- if args[2] then
- min,max=string.match(args[2],"(%d)-(%d+)")
- min,max=tonumber(min),tonumber(max)
- end
- if min==nil or max==nil or min<1 or min>=max-1 or max>10 then
- sendChatMessage("setdiff_invalid",name,"<R>",{"<N>!setdiff 1-5<R>"})
- else
- players[name].diffMin=min
- players[name].diffMax=max
- sendChatMessage("setdiff",name,"<N>",{min,max})
- end
- --Cmd: die
- elseif args[1]=="mort" then
- tfm.exec.killPlayer(name)
- --Cmd: skip map
- elseif args[1]=="skip" and (shaman.name==name or admin) then
- eventLoop(0,0)
- --Cmd: become shaman
- elseif admin and args[1]=="shaman" then
- tfm.exec.setShaman(name)
- --Cmd: play map
- elseif admin and args[1]=="play" then
- eventLoop(0,0,args[2])
- --Cmd: get paid
- elseif admin and args[1]=="score" then
- tfm.exec.setPlayerScore(name,tonumber(args[2]) or 0)
- elseif args[1]=="stats" then
- if not args[2] then args[2]=name end
- if players[args[2]]then sendChatMessage("stats",name,"<N>",{"<CH>"..args[2].."<N>","<CH>"..players[args[2]].diffMin.."<N>-<CH>"..players[args[2]].diffMax.."<N>","<CH>"..players[args[2]].level.."<N>","<CH>"..players[args[2]].xp.."<N>"}) end
- elseif admin and args[1]=="mod" then
- tfm.exec.chatMessage("<ROSE>["..name.."]<N> "..message)
- --Cmd: set language
- elseif text[args[1]:upper()] then
- players[name].lang=args[1]:upper()
- sendChatMessage("setlang",name,"<N>",{"<VP>"..args[1]:upper().."<N>"})
- end
- end
- --Hide commands
- for i,command in ipairs({"help","shaman","mod","mort","setdiff","stats","add","save","delete","info","maps","reset","fr","en","br","pt","pl","nl","vk","cn","tr","es"}) do
- system.disableChatCommandDisplay(command)
- end
- --Join existing players
- system.newTimer( function()
- for name,player in pairs(tfm.get.room.playerList) do
- eventNewPlayer(name)
- shaman=players[name]
- end eventLoop(0,0)end,3000)
- --Set up everything
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAutoNewGame(true)
- --Initiate
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement