Advertisement
Eliaseeg

CheeseClicker

Nov 7th, 2016
496
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.74 KB | None | 0 0
  1. local map = '<C><P /><Z><S><S L="106" o="324650" H="36" X="53" Y="382" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="10" o="324650" H="64" X="316" Y="-282" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="227" o="324650" H="10" X="426" Y="-245" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="227" o="324650" X="434" Y="-317" T="12" H="10" /><S P="0,0,0.3,0.2,0,0,0,0" L="10" o="324650" X="542" Y="-279" T="12" H="64" /></S><D /><O /></Z></C>'
  2. local player = 'Eliaseeg'
  3. local help_pool = {
  4.     -- NOMBRE, COSTO, DISPNIBLES
  5.     {"Cursor", 50, 0},
  6.     {"Vaca", 200, 0},
  7.     {"Rata", 1000, 0},
  8.     {"Granjero", 5000, 0},
  9.     {"Máquina del tiempo", 100000, 0}
  10. }
  11. -- No toques nada de aquí!
  12. local mice = {}
  13. local cooldown = 0
  14. local cheesePerSecond = 0
  15. local cheese = 0
  16. local time = 0
  17.  
  18. function main()
  19.     tfm.exec.disableAutoShaman(true)
  20.     tfm.exec.disableAutoTimeLeft(true)
  21.     tfm.exec.disableAutoNewGame(true)
  22.     tfm.exec.disableAfkDeath(true)
  23.     startGame()
  24. end
  25.  
  26. function startGame()
  27.     cooldown = 0
  28.     tfm.exec.newGame(map)
  29.     table.foreach(tfm.get.room.playerList, eventNewPlayer)
  30.     table.foreach(tfm.get.room.playerList, showGui)
  31. end
  32.  
  33. function eventNewPlayer(name)
  34.     if name == player then
  35.         system.bindMouse(name, true)
  36.         tfm.exec.movePlayer(name, 50, 345)
  37.     else
  38.         tfm.exec.movePlayer(name, 426, -276)
  39.     end
  40. end
  41.  
  42. function showGui(name)
  43.     ui.addTextArea(0, "<font size='35'>"..cheese.."<G>$</G></font>", name, 10, 40, 200, 40, 0x191919, 0x191919, 0.6, true)
  44.     ui.addTextArea(1, "", name, 10, 100, 200, 220, 0x191919, 0x191919, 0.6, false)
  45.     ui.addTextArea(2, "<font size='15'><a href='event:".. help_pool[1][1] .."'>".. help_pool[1][1] ..": <G>".. help_pool[1][2] .."$</G></a></font></p>\n<font size='10'>"..help_pool[1][3], name, 510, 40, 280, 50, 0x191919, 0x191919, 0.6, true)
  46.     ui.addTextArea(3, "<font size='15'><a href='event:".. help_pool[2][1] .."'>".. help_pool[2][1] ..": <G>".. help_pool[2][2] .."$</G></a></font></p>\n<font size='10'>"..help_pool[2][3], name, 510, 100, 280, 50, 0x191919, 0x191919, 0.6, true)
  47.     ui.addTextArea(4, "<font size='15'><a href='event:".. help_pool[3][1] .."'>".. help_pool[3][1] ..": <G>".. help_pool[3][2] .."$</G></a></font></p>\n<font size='10'>"..help_pool[3][3], name, 510, 160, 280, 50, 0x191919, 0x191919, 0.6, true)
  48.     ui.addTextArea(5, "<font size='15'><a href='event:".. help_pool[4][1] .."'>".. help_pool[4][1] ..": <G>".. help_pool[4][2] .."$</G></a></font></p>\n<font size='10'>"..help_pool[4][3], name, 510, 220, 280, 50, 0x191919, 0x191919, 0.6, true)
  49.     ui.addTextArea(6, "<font size='15'><a href='event:".. help_pool[5][1] .."'>".. help_pool[5][1] ..": <G>".. help_pool[5][2] .."$</G></a></font></p>\n<font size='10'>"..help_pool[5][3], name, 510, 280, 280, 50, 0x191919, 0x191919, 0.6, true)
  50. end
  51.  
  52. function eventTextAreaCallback(id, name, callback)
  53.     if name  ~= player then return end
  54.     for i=1,5 do
  55.         if callback == help_pool[i][1] and cooldown <= 0 then
  56.             if cheese - help_pool[i][2] >= 0 then
  57.                 cooldown = 1
  58.                 help_pool[i][3] = help_pool[i][3] + 1
  59.                 cheese = cheese - help_pool[i][2]
  60.                 local newNumber = help_pool[i][2]+(help_pool[i][2]*25/100)
  61.                 help_pool[i][2] = round(newNumber, 0)
  62.                 updateTextArea(0, "<font size='35'>"..cheese.."<G>$</G></font>", name)
  63.                 updateTextArea(i+1, "<font size='15'><a href='event:"..help_pool[i][1].."'>".. help_pool[1][1] ..": <G>".. help_pool[i][2] .."$</G></a></font></p>\n<font size='10'>"..help_pool[i][3], name)
  64.             end
  65.         end
  66.     end
  67. end
  68.  
  69. function eventLoop()
  70.     time = time + 0.5
  71.     cooldown = cooldown - 0.5
  72.     if (time >= 1) then
  73.         tfm.exec.setUIMapName("<BV>CheeseClicker</BV> <G>|</G> " .. player .." tiene un apróximado de: <BV>" .. cheesePerSecond .. "</BV> quesos por segundo\n")
  74.         if ((help_pool[1][3]) >= 1 or tonumber(help_pool[2][3]) >= 1 or tonumber(help_pool[3][3]) >= 1 or tonumber(help_pool[4][3]) >= 1 or tonumber(help_pool[5][3]) >= 1) then
  75.             i = help_pool[1][3] + help_pool[2][3]*5 + help_pool[3][3]*10 + help_pool[4][3]*20 + help_pool[5][3]*50
  76.             cheese = cheese + i
  77.             cheesePerSecond = i
  78.         end
  79.         time = 0
  80.     end
  81.     updateTextArea(0, "<font size='35'>".. cheese .."<G>$</G></font>", k)
  82. end
  83.  
  84. function eventChatCommand(name, command)
  85.     local args = {}
  86.     for arg in command:gmatch("[^%s]+") do
  87.         table.insert(args, arg:lower())
  88.     end
  89.     if name ~= player then return end
  90.     if args[1] == "save" then
  91.         saveGame();
  92.     elseif args[1] == "load" then
  93.         new = table.concat(args)
  94.         local loaded = string.split(new:sub(5), ":")
  95.         loadGame(loaded[1], loaded[2], loaded[3], loaded[4], loaded[5], loaded[6])
  96.     end
  97.  
  98. end
  99.  
  100. function saveGame()
  101.     -- Quesos : Cursores : Vacas : Ratas : Granjero : Máquinas del tiempo
  102.     line = cheese .. " : ".. help_pool[1][3] .. " : " .. help_pool[2][3] .. " : " .. help_pool[3][3] .. " : " .. help_pool[4][3] .. " : " .. help_pool[5][3] .. ""
  103.     print("Here is your back up:")
  104.     print(line)
  105. end
  106.  
  107. function loadGame(cheeseVar, var1, var2, var3, var4, var5)
  108.     startGame()
  109.     cheese = cheeseVar
  110.     help_pool[1][3], help_pool[2][3], help_pool[3][3], help_pool[4][3], help_pool[5][3] = tonumber(var1), tonumber(var2), tonumber(var3), tonumber(var4), tonumber(var5)
  111.     updateTextArea(0, "<font size='35'>"..cheese.."<G>$</G></font>", name)
  112.     updateTextArea(1, "", name)
  113.     updateTextArea(2, "<font size='15'><a href='event:".. help_pool[1][1] .."'>".. help_pool[1][1] ..": <G>".. help_pool[1][2] .."$</G></a></font></p>\n<font size='10'>"..help_pool[1][3], name)
  114.     updateTextArea(3, "<font size='15'><a href='event:".. help_pool[2][1] .."'>".. help_pool[2][1] ..": <G>".. help_pool[2][2] .."$</G></a></font></p>\n<font size='10'>"..help_pool[2][3], name)
  115.     updateTextArea(4, "<font size='15'><a href='event:".. help_pool[3][1] .."'>".. help_pool[3][1] ..": <G>".. help_pool[3][2] .."$</G></a></font></p>\n<font size='10'>"..help_pool[3][3], name)
  116.     updateTextArea(5, "<font size='15'><a href='event:".. help_pool[4][1] .."'>".. help_pool[4][1] ..": <G>".. help_pool[4][2] .."$</G></a></font></p>\n<font size='10'>"..help_pool[4][3], name)
  117.     updateTextArea(6, "<font size='15'><a href='event:".. help_pool[5][1] .."'>".. help_pool[5][1] ..": <G>".. help_pool[5][2] .."$</G></a></font></p>\n<font size='10'>"..help_pool[5][3], name)
  118. end
  119.  
  120. function eventMouse(name, x, y)
  121.     if (x >= 4 and x <= 215) then
  122.         if (y >= 94 and y <= 322) then
  123.             cheese = cheese + 1
  124.             updateTextArea(0, "<font size='35'>".. cheese .."<G>$</G></font>", name)
  125.             tfm.exec.displayParticle(15, x, y, 0, 0, 0, 0)
  126.         end
  127.     end
  128. end
  129.  
  130. function string.split(str, sep)
  131.     local t={} ; i=1
  132.     for str in string.gmatch(str, "([^"..sep.."]+)") do
  133.         t[i] = str
  134.         i = i + 1
  135.     end
  136.     return t
  137. end
  138.  
  139. function round(num, idp)
  140.   local mult = 10^(idp or 0)
  141.   return math.floor(num * mult + 0.5) / mult
  142. end
  143.  
  144. function updateTextArea(id, text)
  145.     return table.foreach(tfm.get.room.playerList, function (k, v) ui.updateTextArea(id, text, k) end)
  146. end
  147.  
  148. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement