Advertisement
Guest User

FishSimulator

a guest
Nov 23rd, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.84 KB | None | 0 0
  1. --Config
  2. local FishSimulatorVersion = "1.6.8"
  3. local fishX = 10
  4. local fishY = 10
  5. local fishHealth = 40
  6. local fishLt = "(O<"
  7. local fishRt = ">O)"
  8. local fishX2 = 12
  9. local fishY2 = 12
  10. local fishX3 = 6
  11. local fishY3 = 7
  12. local fishX4 = 14
  13. local fishY4 = 13
  14.  
  15. --Extra Variables
  16. local reset = 19
  17. local feed = 33 -- the key id for the F key
  18. local h = colors.green -- h is the variable for the color of the health number
  19. local fishLook = true -- true means left false means right
  20. local fishLook2 = false
  21. local fishLook3 = true
  22. local fishLook4 = false
  23. FishScreen = {
  24.   {},{},{},{},{},{},{},{0,    0,
  25.     0,    0,
  26.     0,    0,
  27.     0,    0,
  28.     0,    0,
  29.     0,    0,    0,
  30.     0,    0,
  31.     0,    0,
  32.     0,    0,
  33.     0,    0,
  34.     0,    0,
  35.     0,    0,    0,
  36.     0,    0,
  37.     0,    0,
  38.     0,    0,
  39.     0,    0,
  40.     0,    0,
  41.     0,    0,
  42.     0,    0,
  43.     0,    0,
  44.   },
  45.   {
  46.     0,
  47.     0,
  48.     0,
  49.     0,
  50.     0,
  51.     0,
  52.     0,
  53.     0,
  54.     0,
  55.     0,
  56.     0,
  57.     0,
  58.     0,
  59.     0,
  60.     0,
  61.     0,
  62.     0,
  63.     0,
  64.     0,
  65.     0,
  66.     0,
  67.     0,
  68.     0,
  69.     0,
  70.     0,
  71.     0,
  72.     0,
  73.     0,
  74.     0,
  75.     0,
  76.     0,
  77.     0,
  78.     0,
  79.     0,
  80.     0,
  81.     0,
  82.     0,
  83.     0,
  84.     0,
  85.     0,
  86.     0,
  87.     0,
  88.   },
  89.   {},
  90.   {},
  91.   {},
  92.   {},
  93.   {
  94.     0,
  95.     0,
  96.     0,
  97.     0,
  98.     0,
  99.     0,
  100.     0,
  101.     0,
  102.     0,
  103.     0,
  104.     0,
  105.     0,
  106.     0,
  107.     0,
  108.     0,
  109.     0,
  110.     0,
  111.     0,
  112.     32,
  113.     0,
  114.     0,
  115.     0,
  116.     32,
  117.     0,
  118.     0,
  119.     0,
  120.     0,
  121.     0,
  122.     32,
  123.     0,
  124.     0,
  125.     0,
  126.     32,
  127.   },
  128.   {
  129.     0,
  130.     0,
  131.     0,
  132.     0,
  133.     0,
  134.     0,
  135.     0,
  136.     0,
  137.     0,
  138.     0,
  139.     0,
  140.     0,
  141.     0,
  142.     0,
  143.     0,
  144.     0,
  145.     0,
  146.     0,
  147.     0,
  148.     8192,
  149.     0,
  150.     32,
  151.     0,
  152.     0,
  153.     0,
  154.     0,
  155.     0,
  156.     0,
  157.     32,
  158.     0,
  159.     0,
  160.     0,
  161.     0,
  162.     32,
  163.   },
  164.   {
  165.     0,
  166.     0,
  167.     0,
  168.     0,
  169.     0,
  170.     0,
  171.     0,
  172.     0,
  173.     0,
  174.     0,
  175.     0,
  176.     0,
  177.     0,
  178.     0,
  179.     0,
  180.     0,
  181.     0,
  182.     0,
  183.     0,
  184.     8192,
  185.     0,
  186.     8192,
  187.     0,
  188.     0,
  189.     0,
  190.     0,
  191.     0,
  192.     0,
  193.     8192,
  194.     0,
  195.     0,
  196.     0,
  197.     0,
  198.     8192,
  199.   },
  200.   {
  201.     0,
  202.     0,
  203.     0,
  204.     0,
  205.     0,
  206.     0,
  207.     0,
  208.     0,
  209.     0,
  210.     0,
  211.     0,
  212.     0,
  213.     0,
  214.     0,
  215.     0,
  216.     0,
  217.     0,
  218.     0,
  219.     0,
  220.     0,
  221.     8192,
  222.     0,
  223.     0,
  224.     0,
  225.     0,
  226.     0,
  227.     0,
  228.     0,
  229.     0,
  230.     8192,
  231.     0,
  232.     0,
  233.     8192,
  234.   },
  235.   {
  236.     0,
  237.     0,
  238.     0,
  239.     0,
  240.     0,
  241.     0,
  242.     0,
  243.     0,
  244.     0,
  245.     0,
  246.     0,
  247.     0,
  248.     0,
  249.     0,
  250.     0,
  251.     0,
  252.     0,
  253.     0,
  254.     0,
  255.     0,
  256.     8192,
  257.     0,
  258.     0,
  259.     0,
  260.     0,
  261.     0,
  262.     0,
  263.     0,
  264.     0,
  265.     8192,
  266.     0,
  267.     0,
  268.     8192,
  269.   },
  270.   {
  271.     16,
  272.     16,
  273.     16,
  274.     16,
  275.     16,
  276.     16,
  277.     16,
  278.     16,
  279.     16,
  280.     16,
  281.     16,
  282.     16,
  283.     16,
  284.     16,
  285.     16,
  286.     16,
  287.     16,
  288.     16,
  289.     16,
  290.     16,
  291.     16,
  292.     16,
  293.     16,
  294.     16,
  295.     16,
  296.     16,
  297.     16,
  298.     16,
  299.     16,
  300.     16,
  301.     16,
  302.     16,
  303.     16,
  304.     16,
  305.     16,
  306.     16,
  307.     16,
  308.     16,
  309.     16,
  310.     16,
  311.     16,
  312.     16,
  313.     16,
  314.     16,
  315.     16,
  316.     16,
  317.     16,
  318.     16,
  319.     16,
  320.     16,
  321.     16,
  322.   },
  323. }
  324. --Functions
  325. function reset()
  326. term.setCursorPos(3,3)
  327. print("Resetting Fish Positions")
  328. fishX = 10
  329. fishY = 10
  330. fishX2 = 12
  331. fishY2 = 12
  332. fishX3 = 14
  333. fishY3 = 13
  334. fishLook = true -- true means left false means right
  335. fishLook2 = false
  336. fishLook3 = true
  337. fishLook4 = false
  338. end
  339. function fishFeed()
  340.     term.setCursorPos(5,5)
  341.     term.setBackgroundColor(colors.lightBlue)
  342.     print("Feeding Your Fish!")
  343.     fishHealth = fishHealth+1.5
  344.         if fishHealth < 10 then
  345. h = colors.red
  346. elseif fishHealth < 20 then
  347. h = colors.orange
  348.     elseif fishHealth > 30 then
  349. h = colors.green
  350. elseif fishHealth > 20 then
  351. h = 1
  352. elseif fishHealth < 10 then
  353. h = colors.red
  354. end
  355. if fishHealth > 40 then
  356. term.setCursorPos(5,5)
  357. term.setBackgroundColor(colors.lightBlue)
  358.     print("Your Fish Was Overfed!")
  359.     sleep(1)
  360.     term.clear()
  361.     term.setTextColor(1)
  362.         term.setCursorPos(1,1)
  363.         print("Restart? (Y/N)")
  364.         E,K = os.pullEvent("key")
  365.         y = 21
  366.         n = 49
  367.         if K == y then
  368.         shell.run("pastebin run 5x9Uu1pr")
  369.         error()
  370.         elseif K == n then
  371.         term.setBackgroundColor(colors.black)
  372.         term.clear()
  373.         term.setCursorPos(1,1)
  374.         error()
  375.         shell.run("shell")
  376.         end
  377.         end
  378.     if fishHealth < .5 then
  379.     term.setCursorPos(5,5)
  380.     term.setBackgroundColor(colors.lightBlue)
  381.     print("Your Fish Starved To Death!")
  382.     sleep(1)
  383.     term.clear()
  384.     term.setTextColor(1)
  385.         term.setCursorPos(1,1)
  386.         print("Restart? (Y/N)")
  387.         E,K = os.pullEvent("key")
  388.         y = 21
  389.         n = 49
  390. if K == y then
  391.         shell.run("pastebin run 5x9Uu1pr")
  392.         error()
  393.         elseif K == n then
  394.         term.setBackgroundColor(colors.black)
  395.         term.clear()
  396.         term.setCursorPos(1,1)
  397.         error()
  398.         shell.run("shell")
  399.         end
  400. end
  401. end
  402. function fishMove()
  403.   term.setBackgroundColor(colors.lightBlue)
  404.   term.clear()
  405.   term.setCursorPos(1,1)
  406.   term.setTextColor(1)
  407.   term.write("Fish's Life: ")
  408.   term.setTextColor(h)
  409.   term.write(fishHealth)
  410.   term.setCursorPos(fishX,fishY)
  411.   term.setTextColor(colors.black)
  412.   term.setBackgroundColor(fishC1)
  413.   if fishLook then
  414.     term.write(fishLt)
  415.     else if fishLook == false then
  416.           term.write(fishRt)
  417.     end
  418.   end
  419. move3 = math.random(4)
  420.     if move3 == 1 then
  421.           fishX3 = fishX3-1
  422.           fishLook3 = true
  423.           elseif move3 == 2 then
  424.           fishX3 = fishX3+1
  425.           fishLook3 = false
  426.           elseif move3 == 3 then
  427.           fishY3 = fishY3-1
  428.           elseif move3 == 4 then
  429.           fishY3 = fishY3+1
  430. end
  431. term.setCursorPos(fishX3,fishY3)
  432.   term.setTextColor(colors.black)
  433.   term.setBackgroundColor(fishC3)
  434.   if fishLook3 then
  435.     term.write(fishLt)
  436.     else
  437.           term.write(fishRt)    
  438. end
  439. move2 = math.random(4)
  440.     fishHealth = fishHealth - .5
  441.     if move2 == 1 then
  442.           fishX2 = fishX2-1
  443.           fishLook2 = true
  444.           elseif move2 == 2 then
  445.           fishX2 = fishX2+1
  446.           fishLook2 = false
  447.           elseif move2 == 3 then
  448.           fishY2 = fishY2-1
  449.           elseif move2 == 4 then
  450.           fishY2 = fishY2+1
  451. end
  452. term.setCursorPos(fishX2,fishY2)
  453.   term.setTextColor(colors.black)
  454.   term.setBackgroundColor(fishC2)
  455.   if fishLook2 then
  456.     print(fishLt)
  457.     else
  458.           print(fishRt)    
  459. end
  460.     move = math.random(4)
  461.     if move == 1 then
  462.           fishX = fishX-1
  463.           fishLook = true
  464.           elseif move == 2 then
  465.           fishX = fishX+1
  466.           fishLook = false
  467.           elseif move == 3 then
  468.           fishY = fishY-1
  469.           elseif move == 4 then
  470.           fishY = fishY+1
  471.   --Health ColorChangers
  472. if fishHealth < 5 then
  473. h = colors.red
  474. elseif fishHealth < 10 then
  475. h = colors.orange
  476.     elseif fishHealth > 15 then
  477. h = colors.green
  478. elseif fishHealth > 9 then
  479. h = 1
  480. elseif fishHealth < 5 then
  481. h = colors.red
  482. end
  483. if fishHealth > 40 then
  484. term.setCursorPos(5,5)
  485. term.setBackgroundColor(colors.lightBlue)
  486.     term.clear()
  487.         print("Your Fish Was Overfed!")
  488.     sleep(1)
  489.     term.clear()
  490.     term.setTextColor(1)
  491.         term.setCursorPos(1,1)
  492.         print("Restart? (Y/N)")
  493.         E,K = os.pullEvent("key")
  494.         y = 21
  495.         n = 49
  496.         if K == y then
  497.         shell.run("pastebin run 5x9Uu1pr")
  498.         error()
  499.         elseif K == n then
  500.         term.setBackgroundColor(colors.black)
  501.         term.clear()
  502.         term.setCursorPos(1,1)
  503.         error()
  504.         shell.run("shell")
  505.         end
  506.         end  
  507.  if fishHealth < .5 then
  508.     term.setCursorPos(5,5)
  509.     term.setBackgroundColor(colors.lightBlue)
  510.     print("Your Fish Starved To Death!")
  511.     sleep(1)
  512.     term.clear()
  513.     term.setTextColor(1)
  514.         term.setCursorPos(1,1)
  515.         print("Restart? (Y/N)")
  516.         E,K,L = os.pullEvent()
  517.         y = 21
  518.         n = 49
  519. if E == "key" then
  520.         if K == y then
  521.         shell.run("pastebin run 5x9Uu1pr")
  522.         error()
  523.         elseif K == n then
  524.         term.setBackgroundColor(colors.black)
  525.         term.clear()
  526.         term.setCursorPos(1,1)
  527.         error()
  528.         shell.run("shell")
  529.         end
  530. elseif E == "monitor_touch" and L == 1 and K == 11 then
  531. shell.run("pastebin run 5x9Uu1pr")
  532.         error()
  533. else
  534. error()
  535.     end
  536. end
  537.    end
  538.   paintutils.drawImage(FishScreen,1,1)
  539.   term.setBackgroundColor(colors.lightBlue)
  540.   end
  541. --Startup Screen
  542. function sScreen()
  543. local fish1 = math.random(2)
  544. local fish2 = math.random(2)
  545. local fish3 = math.random(2)
  546. if fish1 == 1 then
  547. fishC1 = colors.orange
  548. else
  549. fishC1 = colors.yellow
  550. end
  551. if fish2 == 1 then
  552. fishC2 = colors.blue
  553. else
  554. fishC2 = colors.lime
  555. end
  556. if fish3 == 1 then
  557. fishC3 = colors.red
  558. else
  559. fishC3 = colors.white
  560. end
  561. term.setBackgroundColor(colors.lightBlue)
  562. term.setTextColor(colors.black)
  563. term.clear()
  564. paintutils.drawImage(FishScreen,1,1)
  565. paintutils.drawImage(FishScreen,1,1)
  566. term.setCursorPos(1,1)
  567. term.setBackgroundColor(colors.lightBlue)
  568. print("Fish Simulator v. "..FishSimulatorVersion)
  569. term.setCursorPos(fishX,fishY)
  570. term.setBackgroundColor(fishC1)
  571. print(fishLt)
  572. term.setBackgroundColor(fishC2)
  573. term.setCursorPos(fishX2,fishY2)
  574. print(fishRt)
  575. term.setBackgroundColor(fishC3)
  576. term.setCursorPos(fishX3,fishY3)
  577. print(fishLt)
  578. term.setBackgroundColor(colors.lightBlue)
  579. sleep(.50)
  580. term.setCursorPos(1,2)
  581. print("Fire An Event To Begin.")
  582. os.pullEvent()
  583. fishMove()
  584. --Run Code
  585. local id = os.startTimer(1)
  586. while true do
  587.   local event = {os.pullEvent()}
  588.   if event[ 1 ] == "timer" and event[ 2 ] == id then
  589.     fishMove()
  590.     id = os.startTimer(1)
  591.   elseif event[ 1 ] == "key" and event[ 2 ] == feed then
  592.     fishFeed()
  593.   elseif event[ 1 ] == "monitor_touch" then
  594.     fishFeed()
  595.   elseif event[ 1 ] == "key" and event[ 2 ] == 19 then
  596. reset()
  597.   end
  598. end
  599. end
  600. sScreen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement