Safwanrockz

#Riddle

Feb 11th, 2014
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.19 KB | None | 0 0
  1. --[[RIDDLE;
  2. The shaman has to make a riddle of the word they were given, while players must guess that word.
  3. Commands:
  4. !word to guess the word
  5. !help to see the help
  6. !respawn for respawning your mouse (if dead)
  7. !staff to see the current room staff
  8. As a shaman:
  9. !new to get a new word (you can only !new once.)
  10. !next to skip your turn
  11. Admin commands:
  12. !cheat to skip the turn if the shaman was caught cheating
  13. !word to view the current word
  14. !mod to chat as mod (pink text)]]
  15. tfm.exec.disableAutoScore(true)
  16. tfm.exec.disableAutoNewGame(true)
  17. tfm.exec.disableAfkDeath(true)
  18. tfm.exec.disableAllShamanSkills(true)
  19. cmds={"mod","word","cheat","respawn","staff"}
  20. for _,cmd in pairs(cmds) do
  21.      system.disableChatCommandDisplay(cmd)
  22. end
  23. admins={"Safwanrockz","Shamousey"}
  24. 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"}
  25. maps={"@4411282"}
  26. texts= {
  27.     welcome = "<p align='center'>Welcome to <font color='#ff0000'><B>Riddle</B></font> minigame! Type <font color='#ff0000'><B>!help</B></font> for help.</p>",
  28.     shamriddle = "<BV>You have to make a riddle of the word.. \n<J><B>%s</B></J>\nYou have 2 minutes!",
  29.     winner = "<J>%s<BV> has solved the riddle! The word was <J>%s",
  30.     help = "<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>",
  31.     staff = "<p align='center'><font color='#ff0000' size='13' face='Soopafresh'>Room Staff</font> </p><br><br>"..table.concat(admins, "\n").."<br><br><br><br><p align='right'><a href='event:close'><font color='#ff0000' size='13' face='Soopafresh'>Close</p></a></font></B>",
  32.     skip = "<BV>The shaman has decided to skip their turn! The word was <J>%s",
  33.     newword = "<BV>The shaman has chosen a new word!",
  34.         cheat = "<R>The shaman has cheated! Beginning a new round..",
  35.         nocheat = "<BV>No cheating allowed!",
  36.         nowinner = "<BV>Nobody solved the riddle! The word was <J><B>%s"
  37.     }
  38.  
  39. --Lua functions
  40. function table.delete(table, element)
  41.      for k,v in pairs(table) do
  42.          if v==element then
  43.              table.remove(table, k)
  44.          end
  45.      end
  46. end
  47.  
  48. function table.random(t, associative)
  49.      associative = associative or false
  50.      if associative then
  51.          local t2 = {}
  52.          for k in pairs(t) do
  53.           t2[#t2 + 1] = k
  54.         end
  55.         return t[table.random(t2)]
  56.     else
  57.         return t[math.random(1,#t)]
  58.     end
  59. end
  60.  
  61. function table.contains(t,element)
  62.     if element==nil then
  63.         return false
  64.     end
  65.     for key,value in pairs(t) do
  66.         if value==element then
  67.             return true
  68.         end
  69.     end
  70.     return false
  71. end
  72.  
  73. for player in pairs(tfm.get.room.playerList) do
  74.      tfm.exec.setPlayerScore (player, 0)
  75. end
  76.  
  77. tfm.exec.newGame(table.random(maps))
  78.  
  79. --Events
  80. function eventNewGame()
  81.      ui.addTextArea(0, texts.welcome, name, 255, 19, nil, nil, "0x262626", "0x000000", 0.7, nil)
  82.      shaman=nil
  83.      for name,player in pairs(tfm.get.room.playerList) do
  84.           if(tfm.get.room.playerList[name].isShaman) then
  85.                shaman=name
  86.           end
  87.      end
  88.      answered=false
  89.      lastnew=false
  90.      word=table.random(words)
  91.      tfm.exec.setUIMapName("<VP>~Made by Safwanrockz")
  92.      tfm.exec.setGameTime(120,true)
  93.      ui.addTextArea(1, texts.shamriddle:format(word), shaman, 5, 20, nil, nil, "0x262626", "0x000000", 0.7, nil)
  94. end
  95.  
  96. function evenNewPlayer(name)
  97.      ui.updateTextArea(0, texts.welcome, name, 275, 19, nil, nil, "0x262626", "0x000000", 0.7, nil)
  98.      tfm.exec.respawnPlayer(name)
  99. end
  100.  
  101. function eventChatCommand(name,command)
  102.      local split=string.find(command," ") or #command+1
  103.      local cmd=string.sub(command,1,split-1)
  104.      local args=string.sub(command,split+1)
  105.      if cmd:lower()==word:lower() and name~=shaman and not answered then
  106.           ui.removeTextArea(5)
  107.           ui.addTextArea(0, texts.winner:format(name, word), nil, 255, 19, nil, nil, "0x262626", "0x000000", 0.7, nil)
  108.           tfm.exec.giveCheese(name)
  109.           tfm.exec.playerVictory(name)
  110.           answered=true
  111.           tfm.exec.setPlayerScore(name,5)
  112.           tfm.exec.setGameTime(5,true)
  113.           tfm.exec.setPlayerScore(shaman,0)
  114.      elseif cmd=="help" then
  115.           ui.removeTextArea(4)
  116.           ui.addTextArea(3, texts.help, name, 289, 76, 230, 250, "0x262626", "0x000000", 0.7)
  117.      elseif cmd=="respawn" then
  118.           tfm.exec.respawnPlayer(name)
  119.      elseif cmd=="staff" then
  120.           ui.removeTextArea(3)
  121.           ui.addTextArea(4, texts.staff, name, 329, 156, 130, 130, "0x262626", "0x000000", 0.7)
  122.      end
  123.      if tfm.get.room.playerList[name].isShaman then
  124.           if cmd=="next" then
  125.                answered=true
  126.                tfm.exec.setGameTime(1,true)
  127.                tfm.exec.setPlayerScore(shaman,0)
  128.                ui.updateTextArea(0, texts.skip:format(word), nil)
  129.           elseif cmd=="new" and not answered and not lastnew then
  130.                word=table.random(words)
  131.                ui.removeTextArea(0)
  132.                ui.addTextArea(5, texts.newword, nil, 295, 19, nil, nil, "0x262626", "0x000000", 0.7, nil)
  133.                ui.updateTextArea(1, texts.shamriddle:format(word), shaman)
  134.                lastnew=true
  135.           elseif cmd==word and not answered then
  136.                ui.removeTextArea(5)
  137.                tfm.exec.setPlayerScore(name,0)
  138.                ui.updateTextArea(0, texts.cheat, nil)
  139.                answered=true
  140.                tfm.exec.setGameTime(5,true)
  141.           end
  142.      end
  143.      if table.contains(admins, name) then
  144.           if cmd=="cheat" then
  145.                ui.removeTextArea(0)
  146.                ui.removeTextArea(5)
  147.                ui.addTextArea(6, texts.nocheat, nil, 335, 19, nil, nil, "0x262626", "0x000000", 0.7, nil)
  148.                tfm.exec.setGameTime(5,true)
  149.                answered=true
  150.           elseif cmd=="mod" then
  151.                ui.addTextArea(2, "<ROSE>• [~Riddle Mod] "..args, nil, 5, 377, nil, nil, "0x262626", "0x000000", 0.7, nil)
  152.           elseif cmd=="map" then
  153.                tfm.exec.newGame(args:match("%d+"))
  154.           elseif cmd=="word" then
  155.                ui.addTextArea(0, "The word is "..word, name, 255, 19, nil, nil, "0x262626", "0x000000", 0.7, nil)
  156.           elseif cmd=="shaman" then
  157.                tfm.exec.setGameTime(0,true)
  158.                tfm.exec.setPlayerScore(args,1337)
  159.           elseif cmd=="admin" then
  160.                table.insert(admins, args)
  161.           elseif cmd=="unadmin" then
  162.                table.delete(admins, args)
  163.           end
  164.      end
  165. end
  166.  
  167. function eventTextAreaCallback(textid,name,cb)
  168.      if cb=='close' then
  169.           ui.removeTextArea(3, name)
  170.           ui.removeTextArea(4, name)
  171.      end
  172. end
  173.  
  174. function eventLoop(time,remaining)
  175.      if remaining <= 5000 and not answered then
  176.           ui.removeTextArea(5)
  177.           ui.removeTextArea(6)
  178.           ui.removeTextArea(0)
  179.           ui.addTextArea(7, texts.nowinner:format(word), nil, 263, 19, nil, nil, "0x262626", "0x000000", 0.7, nil)
  180.           answered=true
  181.      end
  182.      if remaining <= 0 then
  183.           tfm.exec.newGame(table.random(maps))
  184.           answered=false
  185.           for i=0,7 do
  186.                ui.removeTextArea(i)
  187.           end
  188.      end
  189. end
Advertisement
Add Comment
Please, Sign In to add comment