Safwanrockz

#Riddle

Nov 5th, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.66 KB | None | 0 0
  1. --RIDDLE
  2.  
  3. tfm.exec.disableAutoScore(true)
  4. tfm.exec.disableAutoNewGame(true)
  5. tfm.exec.disableAfkDeath(true)
  6. cmds={"mod","word","cheat","respawn","staff"}
  7. for _,cmd in pairs(cmds) do
  8.  system.disableChatCommandDisplay(cmd)
  9. end
  10. admins={"Safwanrockz","Shamousey"}
  11. words={"cheese","ice","fire","llama","pony","hot","ditch","monkey","shaman","mouse","feather","cookie","music","donut","conscience","explosion","ear","eagle","dubstep","heat","pit","DNA","football","eyepatch","poor","record","recycle","hat","pen","pumpkin","rice","noodles","song","soccer","sonic","sparkle","unicycle","bicycle","tricycle","wedding","virus","emo","goat","sheep","lamb","buffalo","basketball","egg","frog","elevator","oasis","nightingale","leather","jail","lyrics","MacBook","scarf","summer","rainbow","tattoo","seafood","soda","Pepsi","Nemo","America","FireFox"}
  12. maps={"@4411282"}
  13.  
  14.  
  15. function table.random(t, associative)
  16.     associative = associative or false
  17.     if associative then
  18.         local t2 = {}
  19.         for k in pairs(t) do
  20.             t2[#t2 + 1] = k
  21.         end
  22.         return t[table.random(t2)]
  23.     else
  24.         return t[math.random(1,#t)]
  25.     end
  26. end
  27.  
  28. function table.contains(t,element)
  29.     if element==nil then
  30.         return false
  31.     end
  32.     for key,value in pairs(t) do
  33.         if value==element then
  34.             return true
  35.         end
  36.     end
  37.     return false
  38. end
  39.  
  40. for player in pairs(tfm.get.room.playerList) do
  41.      tfm.exec.setPlayerScore (player, 0)
  42. end
  43.  
  44. tfm.exec.newGame(table.random(maps))
  45.  
  46. function eventNewGame()
  47.  ui.addTextArea(0, "<p align='center'>Welcome to <font color='#ff0000'><B>Riddle</B></font> minigame! Type <font color='#ff0000'><B>!help</B></font> for help.</p>", name, 255, 19, nil, nil, "0x262626", "0x000000", 0.7, nil)
  48.  shaman=nil
  49.  for name,player in pairs(tfm.get.room.playerList) do
  50.   if(tfm.get.room.playerList[name].isShaman) then
  51.    shaman=name
  52.   end
  53.  end
  54.  answered=false
  55.  lastnew=false
  56.  word=table.random(words)
  57.  tfm.exec.setUIMapName("<VP>~Made by Safwanrockz")
  58.  tfm.exec.setGameTime(105,true)
  59.  ui.addTextArea(1, "<BV>You have to make a riddle of the word.. \n<J><B>"..word.."</B></J>\nYou have 2 minutes!", shaman, 5, 20, nil, nil, "0x262626", "0x000000", 0.7, nil)
  60. end
  61.  
  62. function evenNewPlayer(name)
  63.  ui.updateTextArea(0, "<p align='center'>Welcome to <font color='#ff0000'><B>Riddle</B></font> minigame! Type <font color='#ff0000'><B>!help</B></font> for help.</p>", name, 275, 19, nil, nil, "0x262626", "0x000000", 0.7, nil)
  64.  tfm.exec.respawnPlayer(name)
  65. end
  66.  
  67. function eventChatCommand(name,cmd)
  68.  local arg={}
  69.  for argument in cmd:gmatch("[^%s]+") do
  70.   table.insert(arg, argument);
  71.  end
  72.  if cmd:lower()==word:lower() and name~=shaman and not answered then
  73.   ui.removeTextArea(5)
  74.   ui.addTextArea(0, "<J>"..name.."<BV> has solved the riddle! The word was <J>"..word.."</J>", nil, 255, 19, nil, nil, "0x262626", "0x000000", 0.7, nil)
  75.   tfm.exec.giveCheese(name)
  76.   tfm.exec.playerVictory(name)
  77.   answered=true
  78.   tfm.exec.setPlayerScore(name,5)
  79.   tfm.exec.setGameTime(5,true)
  80.   tfm.exec.setPlayerScore(shaman,0)
  81.  elseif cmd=="help" then
  82.   ui.removeTextArea(4)
  83.   ui.addTextArea(3, "<p align='center'><font color='#ff0000' size='13' face='Soopafresh'>Welcome to Riddle minigame!</font></p><br><br>Your goal as a shaman is to make a riddle out of the word you get.<br>Your goal as a mouse is to guess the riddle the shaman is making.<br><br><p align='center'><font color='#ff0000' size='13' face='Soopafresh'>Additional Commands</font></p><br><font color='#ff0000'><B>!next</B></font> as a shaman to skip your turn.<br><font color='#ff0000'><B>!new</B></font> as a shaman to get a new word.<br><font color='#ff0000'><B>!respawn</B></font> to respawn your mouse.<br><font color='#ff0000'><B>!staff</B></font> to view the list of room staff.<br><br><br><br><p align='right'><a href='event:close'><font color='#ff0000' face='Soopafresh'>Close</p></a></font>", name, 289, 76, 230, 250, "0x262626", "0x000000", 0.7)
  84.  elseif cmd=="respawn" then
  85.   tfm.exec.respawnPlayer(name)
  86.  elseif cmd=="staff" then
  87.   ui.removeTextArea(3)
  88.   ui.addTextArea(4, "<p align='center'><font color='#ff0000' size='13' face='Soopafresh'>Room Staff</font> </p><br><br><font color='#ff0000'><B>•</B></font> Safwanrockz<br><font color='#ff0000'><B>•</B></font> Shamousey<br><br><br><br><p align='right'><a href='event:close'><font color='#ff0000' size='13' face='Soopafresh'>Close</p></a></font></B>", name, 329, 156, 130, 130, "0x262626", "0x000000", 0.7)
  89.  end
  90.  if tfm.get.room.playerList[name].isShaman then
  91.   if cmd=="next" then
  92.    answered=true
  93.    tfm.exec.setGameTime(1,true)
  94.    tfm.exec.setPlayerScore(shaman,0)
  95.    ui.updateTextArea(0, "<BV>The shaman has decided to skip their turn! The word was:\n<J>"..word, nil)
  96.   elseif cmd=="new" and not answered and not lastnew then
  97.    word=table.random(words)
  98.    ui.removeTextArea(0)
  99.    ui.addTextArea(5, "<BV>The shaman has chosen a new word!", nil, 295, 19, nil, nil, "0x262626", "0x000000", 0.7, nil)
  100.    ui.updateTextArea(1, "<BV>You have to make a riddle of the word.. \n<J><B>"..word.."</B></J>\nYou have 2 minutes!", shaman)
  101.    lastnew=true
  102.   elseif cmd==word and not answered then
  103.    ui.removeTextArea(5)
  104.    tfm.exec.setPlayerScore(name,0)
  105.    ui.updateTextArea(0, "<R>The shaman has cheated! Beginning a new round..", nil)
  106.    answered=true
  107.    tfm.exec.setGameTime(5,true)
  108.   end
  109.  end
  110.  if table.contains(admins, name) then
  111.   if cmd=="cheat" then
  112.    ui.removeTextArea(0)
  113.    ui.removeTextArea(5)
  114.    ui.addTextArea(6, "<BV>No cheating allowed!", nil, 335, 19, nil, nil, "0x262626", "0x000000", 0.7, nil)
  115.    tfm.exec.setGameTime(5,true)
  116.    answered=true
  117.   elseif cmd:sub(0,3)=="mod" then
  118.    ui.addTextArea(2, "<ROSE>• [~Riddle Mod] "..cmd:sub(5), nil, 5, 377, nil, nil, "0x262626", "0x000000", 0.7, nil)
  119.   elseif arg[1]=="map" then
  120.    tfm.exec.newGame(arg[2])
  121.   elseif cmd=="word" then
  122.    ui.updateTextArea(0, "The word is "..word, name)
  123.   elseif arg[1]=="shaman" then
  124.    tfm.exec.setGameTime(0,true)
  125.    tfm.exec.setPlayerScore(arg[2],1337)
  126.   elseif arg[1]=="admin" then
  127.    table.insert(admins, arg[2])
  128.   end
  129.  end
  130. end
  131.  
  132. function eventTextAreaCallback(textid,name,cb)
  133.  if cb=='close' then
  134.   ui.removeTextArea(3, name)
  135.   ui.removeTextArea(4, name)
  136.  end
  137. end
  138.  
  139. function eventLoop(time,remaining)
  140.  if remaining <= 5000 and not answered then
  141.   ui.removeTextArea(5)
  142.   ui.removeTextArea(6)
  143.   ui.removeTextArea(0)
  144.   ui.addTextArea(7, "<BV>Nobody solved the riddle! The word was <J><B>"..word, nil, 263, 19, nil, nil, "0x262626", "0x000000", 0.7, nil)
  145.   answered=true
  146.  end
  147.  if remaining <= 0 then
  148.   tfm.exec.newGame(table.random(maps))
  149.   answered=false
  150.   ui.removeTextArea(1)
  151.   ui.removeTextArea(2)
  152.   ui.removeTextArea(3)
  153.   ui.removeTextArea(4)
  154.   ui.removeTextArea(5)
  155.   ui.removeTextArea(6)
  156.   ui.removeTextArea(7)
  157.  end
  158. end
Advertisement
Add Comment
Please, Sign In to add comment