Advertisement
Terrah

recv

Sep 1st, 2014
404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 KB | None | 0 0
  1. local loopTime = 2
  2. local SCREEN = nil;
  3. local periList = peripheral.getNames()
  4.  
  5. for i = 1, #periList do
  6. print("I have a "..peripheral.getType(periList[i]).." attached as \""..periList[i].."\".")
  7.  
  8. if peripheral.getType(periList[i]) == "monitor" then
  9. SCREEN = peripheral.wrap( periList[i] );
  10. end
  11.  
  12. end
  13.  
  14. if SCREEN == nil then
  15.  
  16. write("No screen found!");
  17. return;
  18. end
  19.  
  20. local WL_LOADED = os.loadAPI("remote_reactor.lua");
  21.  
  22. if WL_LOADED then
  23. _G["RR"] = _G["remote_reactor.lua"];
  24. _G["remote_reactor.lua"] = nil;
  25. end
  26.  
  27. write("Terrah remote API: " .. tostring( WL_LOADED ) .. "\n" );
  28.  
  29. for k,v in pairs( _G ) do
  30. if k == "RR" then
  31. print(k.." " .. tostring(v));
  32. end
  33. end
  34.  
  35. local function eventHandler()
  36.  
  37. while not finished do
  38. event, arg1, arg2, arg3, arg4, arg5 = os.pullEvent()
  39.  
  40. if event == "monitor_touch" then
  41. sideClick, xClick, yClick = arg1, math.floor(arg2), math.floor(arg3)
  42. elseif event == "char" then
  43. local ch = string.lower(arg1)
  44. end
  45. end
  46. end
  47.  
  48. local function pad(start, str, x)
  49.  
  50. if str == nil then
  51. return start;
  52. end
  53.  
  54. str = tostring(str);
  55.  
  56. str = str:gsub(" ", "" );
  57.  
  58. local ret = "";
  59.  
  60. local amount = (x-1) - ( start:len()+str:len() );
  61.  
  62. if amount > 0 then
  63.  
  64. for i = 0, amount do
  65. ret = ret .. " ";
  66. end
  67.  
  68. end
  69.  
  70. return start .. ret .. str;
  71. end
  72.  
  73. local function xtonumber( str )
  74.  
  75. if str == nil or str == "" then
  76. return 0;
  77. end
  78.  
  79. local ret = tonumber(str);
  80.  
  81. if ret == nil then
  82. return 0;
  83. end
  84.  
  85. return ret;
  86. end
  87.  
  88. function main()
  89.  
  90. local x, y = SCREEN.getSize();
  91.  
  92. print("x: " .. x);
  93. print("y: " .. y);
  94.  
  95. while not finished do
  96.  
  97. term.redirect(SCREEN);
  98. --SCREEN.clear();
  99. SCREEN.setCursorPos(x,0);
  100. SCREEN.setTextColor(1024);
  101.  
  102. --print("~Terrah Swag Console");
  103. print( pad("FLATCHEST STATUS:", "JUSTICE!",x) );
  104. for i = 0, x do
  105. SCREEN.write("-");
  106. end
  107.  
  108. local proc_f = xtonumber(RR.Call( "getFuelAmount" ));
  109. local proc_w = xtonumber(RR.Call( "getWasteAmount" ));
  110. local fuelrods = xtonumber(RR.Call( "getNumberOfControlRods" ));
  111.  
  112. local top = proc_w+proc_f;
  113. local depetion = (proc_w/top)*100;
  114. local rodslevel = 0;
  115. local currentrod = 0;
  116.  
  117. for n = 1, fuelrods do
  118.  
  119. currentrod = RR.Call( "getControlRodLevel", n-1 );
  120.  
  121. if currentrod == nil then
  122. break;
  123. end
  124.  
  125. rodslevel = rodslevel + tonumber(currentrod);
  126. end
  127.  
  128. local rodstaus = rodslevel/fuelrods;
  129.  
  130. SCREEN.setTextColor(1);
  131. SCREEN.setTextScale(1);
  132.  
  133. print( pad( "ENERGY:",tostring(RR.Call( "getEnergyStored" )) .. "/10000000",x) );
  134. print( pad("RF/t:", tostring(RR.Call( "getEnergyProducedLastTick" )),x ) );
  135. print( pad("Fuel/t:", tostring(RR.Call( "getFuelConsumedLastTick" )),x ) );
  136. print( pad("CASING HEAT:", tostring(RR.Call( "getCasingTemperature" )) .. " C",x ) );
  137. print( pad("CORE HEAT:", tostring(RR.Call( "getFuelTemperature" )).. " C",x ) );
  138. print( pad("REACTIVITY:", tostring(RR.Call( "getFuelReactivity" )) .. "%",x ) );
  139. print( pad("DEPLETED:", depetion .. "%",x ) );
  140. print( pad("FUELRODS (" ..fuelrods.. "):", rodstaus .. "%",x) );
  141. print( pad("ACTIVE:", tostring(RR.Call( "getActive" )):upper(),x) );
  142. --term.redirect(term.native);
  143. sleep(loopTime);
  144. end
  145. end
  146.  
  147. --paintutils.drawImage(paintutils.loadImage("kon"),0,0);
  148.  
  149. while not finished do
  150. parallel.waitForAny(eventHandler, main)
  151. sleep(loopTime)
  152. end
  153.  
  154. term.redirect(term.native);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement