Advertisement
DougCp

Visual funcorp

Dec 12th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.55 KB | None | 0 0
  1. --[[
  2. 2016 08 28 - Image Menu
  3. Visual interface for mice to choose an image.
  4. Commands
  5. =========================================================================
  6. msg               Send a public chat message as [Funcorp] in orange text
  7. next              Starts the next round
  8. Controls
  9. =========================================================================
  10. -
  11. Settings
  12. =========================================================================
  13. -
  14. ]]
  15.  
  16. admins = {Yuir=true}
  17.  
  18. imgList = {
  19.     {"Normal Mouse", "153d331c6b9", 50, 48};
  20.     {"Pink Cat", "153ec4eef26", 23, 30, "153ec4ec77d", 26, 30};
  21.     {"Nekoburger", "153ec7e82d6", 23, 26, "153ec7e664b", 26, 26};
  22.     {"Tabby", "154c592261e", 30, 32, "154c5925a15", 27, 32};
  23.     {"Squirrel", "156d73b5b13", 21, 24, "156d738d5b1", 20, 24};
  24.    
  25.     {"Mouse", "155ca47030c", 36, 22, "155ca47179a", 37, 22};
  26.     {"Toilet", "1507c256bcc", 23, 41, "1507c258fe8", 23, 41};
  27.    
  28.     {"Forto 01", "156d7850e4a", 35, 52, "156d785220e", 38, 52};
  29.     {"Forto 02", "156d79470fe", 35, 52, "156d79489a6", 38, 52};
  30.    
  31.     {"Mario", "156d7dafb2d", 23, 30, "156d7db1184", 23, 30};
  32.     {"Luigi", "156d7db2971", 23, 30, "156d7db3b85", 23, 30};
  33.    
  34.     {"Samus", "156d7c67e7b", 23, 30, "156d7c6c7d7", 23, 30};
  35.     {"Mins", "156d76d5156", 23, 30, "156d76db6e3", 23, 30};
  36.    
  37.     {"troll2", "1507b1adc13", 25, 25}; 
  38.     {"areyouserious", "1507b1b73d8", 25, 25};  
  39.     {"bplease", "1507b1b94f9", 25, 25};
  40.     {"youdontsay", "1507b1b314f", 25, 25}; 
  41.     {"ohno", "1507b1d17ef", 25, 25};   
  42.     {"itsnotok", "1507b1c5e8e", 25, 25};   
  43.     {"epicrage", "1507b1bfa13", 25, 25};   
  44.     {"challengeaccepted", "1507b1bb693", 25, 25};  
  45.     {"truestory", "1507b1aee88", 25, 25};  
  46.     {"lol", "1507b1ca194", 25, 25};
  47.     {"what", "1507b1b20c3", 25, 25};   
  48.     {"betterthanexpected", "1507b1c0a9d", 25, 25}; 
  49.     {"pffftch", "1507b1a6609", 25, 25};
  50.     {"epic", "1507b1be8c3", 25, 25};   
  51.     {"foreveralone", "1507b1c1b6e", 25, 25};   
  52.     {"unimpressed", "1507b1aff31", 25, 25};
  53.     {"okay", "1507b1d289c", 25, 25};   
  54.     {"areyoukiddingme", "1507b1b6340", 25, 25};
  55.     {"notsureifmegusta", "1507b1cf647", 25, 25};   
  56.     {"derp", "1507b1bd80d", 25, 25};   
  57.     {"ilied", "1507b1c5e8e", 25, 25};  
  58.     {"sweetjesus", "1507b1acab8", 25, 25}; 
  59.     {"nothingtodohere", "1507b1ce598", 25, 25};
  60.     {"sadface", "1507b1aa996", 25, 25};
  61.     {"pokerface2", "1507b1a8772", 25, 25}; 
  62.     {"notbad", "1507b1cd4f2", 25, 25}; 
  63.     {"yuno", "1507b1b4200", 25, 25};   
  64.     {"doge", "1507b1a432a", 30, 43, "1507b1a54a9", 30, 43};
  65.     {"rage", "1507b1a98c7", 25, 25};   
  66.     {"motherofgod", "1507b1cc438", 25, 25};
  67.     {"badass", "1507b1b0ffb", 25, 25}; 
  68.     {"megusta", "1507b1cb245", 25, 25};
  69.     {"listening", "1507b1c90c8", 25, 25};  
  70.     {"confident", "1507b1bc76c", 25, 25};  
  71.     {"suspicious", "1507b1aba24", 25, 25}; 
  72.     {"likeasir", "1507b1c803d", 25, 25};   
  73.     {"cereal", "1507b1ba583", 25, 25}; 
  74.     {"ohgodwhy", "1507b1d0768", 25, 25};   
  75.     {"happytroll", "1507b1c3d31", 25, 25}; 
  76.     {"herp", "1507b1c4dcb", 25, 25};   
  77.     {"awwyeah", "1507b1b8475", 25, 25};
  78.     {"pokerface", "1507b1a76d7", 25, 25};  
  79.     {"happyderp", "1507b1c2c6a", 25, 25};  
  80.     {"actually", "1507b1b52a7", 25, 25};
  81. }
  82. menuPages = math.ceil(#imgList/6)
  83.  
  84. text = {}
  85. text.en = {
  86.      welcome = "\n<VP>Welcome to the FunCorp room! Stats don't count here.\n"
  87. }
  88. text.es = {
  89.     welcome = "\n<VP>¡Bienvenido a la sala FunCorp! Aquí no cuentan los stats.\n"
  90. }
  91.  
  92. commands = {"msg","next"}
  93. keys = {0,2}
  94. _left = 0
  95. _right = 2
  96.  
  97. imgData = {}
  98. facingLeft = {}
  99. imgId = {}
  100.  
  101. mice = {}
  102.  
  103. lang = text[tfm.get.room.community] or text.en
  104.  
  105. function main()
  106.     for _,c in pairs(commands) do
  107.         system.disableChatCommandDisplay(c)
  108.     end
  109.     for name in pairs(tfm.get.room.playerList) do
  110.         eventNewPlayer(name)
  111.         tfm.exec.killPlayer(name)
  112.     end
  113. end
  114.  
  115. function eventNewGame()
  116.     for n,mouse in pairs(mice) do
  117.     facingLeft[n] = false
  118.         updateImg(n)
  119.     end
  120. end
  121.  
  122. function eventNewPlayer(name)
  123.     mice[name] = {
  124.         menuPage = 1
  125.     }
  126.    
  127.     for _,k in pairs(keys) do
  128.         tfm.exec.bindKeyboard(name, k, true)
  129.     end
  130.     facingLeft[name] = false
  131.   updateImg(name)
  132.  
  133.   tfm.exec.chatMessage(lang.welcome, name)
  134.     --ui.addTextArea(0, "<p align='center'><font color='#010101'><a href='event:openMenu'>O</a></font></p>", nil, 780, 380, 16, 16, 0xff5880, 0xff00cc, 0.8, true)
  135.     ui.addTextArea(0, "<p align='center'><font color='#010101'><a href='event:openMenu'>CLICK HERE</a></font></p>", nil, 714, 380, 82, 16, 0xff5880, 0xff00cc, 0.8, true)
  136. end
  137.  
  138. function eventPlayerRespawn(name)
  139.   facingLeft[name] = false
  140.     updateImg(name)
  141. end
  142.  
  143. function eventKeyboard(name, key, down, px, py)
  144.   if key == _left then
  145.         facingLeft[name] = true
  146.     updateImg(name, true)
  147.    
  148.     elseif key == _right then
  149.         facingLeft[name] = false
  150.     updateImg(name, true)
  151.        
  152.     end
  153. end
  154.  
  155. function updateImg(name, turning)
  156.     local d = imgData[name]
  157.     if not d then return end
  158.    
  159.     if not d[5] then
  160.         if turning then return
  161.         else
  162.             facingLeft[name] = true
  163.         end
  164.     end
  165.    
  166.     if imgId[name] then tfm.exec.removeImage(imgId[name]) end
  167.    
  168.     local img,x,y
  169.     if facingLeft[name] then
  170.         img,x,y = d[2],d[3],d[4]
  171.     else
  172.         img,x,y = d[5],d[6],d[7]
  173.     end
  174.     imgId[name] = tfm.exec.addImage(img..".png", "%"..name, -x, -y, nil)
  175. end
  176.  
  177. function eventChatCommand(name, mes)
  178.     if admins[name] then
  179.         if mes:sub(1,3) == "msg" then
  180.             tfm.exec.chatMessage("<font color='#ff8547'>[FunCorp] "..mes:sub(5).."</font>", nil)
  181.         elseif mes == "next" then
  182.             tfm.exec.newGame()
  183.         end
  184.     end
  185. end
  186.  
  187. function eventTextAreaCallback(id, name, cb)
  188.     local mouse = mice[name]
  189.     if id == 0 then
  190.         if mouse.menuOpen then
  191.             mouse.menuOpen = false
  192.             closeMenu(name)
  193.         else
  194.             mouse.menuOpen = true
  195.             openMenu(name)
  196.         end
  197.        
  198.     elseif id == 2 and mouse.menuPage > 1 then
  199.         mouse.menuPage = mouse.menuPage - 1
  200.         openMenu(name)
  201.        
  202.     elseif id == 3 and mouse.menuPage < menuPages then
  203.         mouse.menuPage = mouse.menuPage + 1
  204.         openMenu(name)
  205.        
  206.     elseif id >= 10 and id <= 15 then
  207.         local k = cb:sub(12) + 0
  208.         if k == 1 then
  209.             imgData[name] = nil
  210.             tfm.exec.killPlayer(name)
  211.         else
  212.             imgData[name] = imgList[k]
  213.         end
  214.         updateImg(name)
  215.        
  216.     end
  217. end
  218.  
  219. function openMenu(name)
  220.     ui.addTextArea(1, "", name, 58, 44, 687, 110, 0x324650, 0x0, 0.4, true)
  221.     ui.addTextArea(16, "<p align='center'><font color='#010101' size='32'> &lt; </font></p>", name, 8, 80, 50, 50, 0x324650, 0x0, 0, true)
  222.     ui.addTextArea(17, "<p align='center'><font color='#010101' size='32'> &gt; </font></p>", name, 737, 80, 50, 50, 0x324650, 0x0, 0, true)
  223.     ui.addTextArea(2, "<p align='center'><font size='32'><a href='event:prevPage'> &lt; </a></font></p>", name, 6, 78, 50, 50, 0x324650, 0x0, 0, true)
  224.     ui.addTextArea(3, "<p align='center'><font size='32'><a href='event:nextPage'> &gt; </a></font></p>", name, 735, 78, 50, 50, 0x324650, 0x0, 0, true)
  225.    
  226.     local mouse = mice[name]
  227.     local page = mouse.menuPage
  228.     local menuImg = mouse.menuImg
  229.    
  230.     if menuImg then
  231.         for i=1,6 do
  232.             if menuImg[i] then tfm.exec.removeImage(menuImg[i]) end
  233.             ui.removeTextArea(9+i, name)
  234.         end
  235.     else
  236.         mouse.menuImg = {}
  237.         menuImg = mouse.menuImg
  238.     end
  239.    
  240.     for i=1,6 do
  241.         local id = (page-1)*6 + i
  242.         local data = imgList[id]
  243.         if not data then break end
  244.        
  245.         local x1 = 63 + 115 * (i-1)
  246.         ui.addTextArea(3+i, "", name, x1, 50, 100, 100, 0x324650, 0x0, 0.1, true)
  247.         ui.addTextArea(9+i, "<p align='center'><a href='event:chooseImage"..id.."'>" .. data[1] .. "</a></p>\"", name, x1, 168, 100, 24, 0x324650, 0x0, 0.6, true)
  248.         menuImg[i] = tfm.exec.addImage(data[2]..".png", "&10000", x1+50 - data[3], 100 - data[4], name)
  249.     end
  250. end
  251.  
  252. function closeMenu(name)
  253.     local menuImg = mice[name].menuImg
  254.     for i=1,6 do
  255.         if menuImg[i] then tfm.exec.removeImage(menuImg[i]) end
  256.     end
  257.     for i=1,17 do
  258.         ui.removeTextArea(i, name)
  259.     end
  260. end
  261.  
  262. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement