Advertisement
Myros27

oldexp

Feb 11th, 2021 (edited)
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.39 KB | None | 0 0
  1. local link = "wget -f https://pastebin.com/raw/VFjeDZHF exp.lua"
  2. local robot = require("robot")
  3. local term = require("term")
  4. local computer = require("computer")
  5. local component = require("component")
  6. local sides = require("sides")
  7. local keyboard = require("keyboard")
  8.  
  9. robot.select(1);
  10. robot.swing();
  11.  
  12. lastExp = 0
  13.  
  14. local function printStuff()
  15.   local double expdouble = component.experience.level()
  16.   exp = string.format("%.4f",expdouble);
  17.   local double diff = expdouble - lastExp;
  18.   lastExp = expdouble;
  19.   diffExp = string.format("%.8f",diff);
  20.   term.clear();
  21.   print("I have " .. exp .. " Exp.\nThats " .. diffExp .. " more than last time.");
  22.   robot.turnRight();
  23.   component.sign.setValue("I have\n" .. exp .. " Exp.\n(+" .. diffExp .. ")");
  24.   robot.turnLeft();
  25. end
  26.  
  27. local function errorStuff(err)
  28.   print(err);
  29. end
  30.  
  31. local function updateStuff()
  32.   error = xpcall(printStuff, errorStuff);
  33.   while (error == false) do
  34.     os.sleep(1);
  35.     error = xpcall(printStuff, errorStuff);
  36.   end
  37. end
  38.  
  39. local function interruptStuff()
  40.   if keyboard.isKeyDown(keyboard.keys.c) and keyboard.isControlDown() then
  41.     os.exit();
  42.   end
  43. end
  44.  
  45. local function doStuff()
  46.  
  47.   local counter = 0;
  48.   local maxCounter = 100;
  49.  
  50.   while (counter < maxCounter) do
  51.     counter = counter + 1;
  52.     robot.place();
  53.     interruptStuff();
  54.     robot.swing();
  55.   end
  56. end
  57.  
  58. while true do
  59.   updateStuff()
  60.   doStuff()
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement