paramus

Iron Man UI

Sep 7th, 2026 (edited)
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.96 KB | Gaming | 0 0
  1. local modules = peripheral.find("neuralInterface")
  2.  
  3. local hasLaser = false
  4. local hasIntrospection = false
  5. local hasGlasses = false
  6. local hasScanner = false
  7. local hasKinetic = false
  8. local hasSensor = false
  9.  
  10. local playerData = nil
  11. local canvas3d = nil
  12. local canvas = nil
  13. local blocksMap = {}
  14. local TARGET_ORES = {}
  15. local keyMappings = {}
  16. local acceptedFoods = {}
  17. local laserStrength = 5 -- min:0.5 | max:5
  18. local hover = false
  19. local spacebar = false
  20. local w = false
  21. local seeOres = false
  22.  
  23. local windowWidth, windowHeight = 0,0
  24.  
  25. local function load()    
  26.     if (modules) then
  27.         hasLaser = modules.hasModule("plethora:laser")
  28.         hasIntrospection = modules.hasModule("plethora:introspection")
  29.         hasGlasses = modules.hasModule("plethora:glasses")
  30.         hasScanner = modules.hasModule("plethora:scanner")
  31.         hasKinetic = modules.hasModule("plethora:kinetic")
  32.         hasSensor = modules.hasModule("plethora:sensor")
  33.        
  34.         playerData = modules.getMetaOwner()
  35.         canvas3d = modules.canvas3d()
  36.         canvas = modules.canvas()
  37.        
  38.         windowWidth, windowHeight = canvas.getSize()
  39.     end
  40.    
  41.     TARGET_ORES = {
  42.         ["minecraft:coal_ore"] = 0x00FAE0FF, -- black
  43.         ["minecraft:deepslate_coal_ore"] = 0x00FAE0FF,
  44.         ["minecraft:diamond_ore"] = 0x00FFFFFF, -- Cyan
  45.         ["minecraft:deepslate_diamond_ore"] = 0x00FFFFFF,
  46.         ["minecraft:ancient_debris"] = 0xFF8000FF, -- Orange
  47.         ["minecraft:iron_ore"] = 0xD8AF93FF, -- Beige/Brown
  48.         ["minecraft:deepslate_iron_ore"] = 0xD8AF93FF,
  49.         ["minecraft:gold_ore"] = 0xFFD700FF, -- Gold
  50.         ["minecraft:deepslate_gold_ore"] = 0xFFD700FF,
  51.         ["minecraft:emerald_ore"] = 0x00FF00FF, -- Green
  52.         ["minecraft:deepslate_emerald_ore"] = 0x00FF00FF,
  53.     }
  54.    
  55.     -- The value assigned is not used for anything, but I need so the script does not freak out
  56.     acceptedFoods = {
  57.         ["minecraft:cooked_beef"] = 1,
  58.         ["minecraft:bread"] = 1,
  59.         ["minecraft:cooked_porkchop"] = 1,
  60.         ["minecraft:cooked_chicken"] = 1,
  61.         ["minecraft:baked_potato"] = 1,
  62.         ["minecraft:pumpkin_pie"] = 1,
  63.         ["minecraft:cooked_rabbit"] = 1,
  64.         ["minecraft:rabbit_stew"] = 1,
  65.         ["minecraft:cooked_mutton"] = 1,
  66.         ["minecraft:beetroot_soup"] = 1
  67.     }
  68.    
  69.     --TODO: Add field "icon" to display peripheral control
  70.     keyMappings = {
  71.         ["grave"] = { -- º
  72.             display="º",
  73.             fun=function()
  74.                 if (hasLaser and hasIntrospection) then -- Shoots laser
  75.                     playerData = modules.getMetaOwner()
  76.                     modules.fire(playerData.yaw, playerData.pitch, laserStrength)
  77.                 end
  78.             end
  79.         },
  80.         ["rightAlt"] = { -- <
  81.             display="R-Alt",
  82.             fun=function()
  83.                 if (hasLaser) then -- Adjusts laser strength
  84.                     laserStrength = laserStrength + 1
  85.                     if (laserStrength > 5) then
  86.                         laserStrength = 1
  87.                     end
  88.                 end
  89.             end
  90.         },
  91.         ["leftAlt"] = {
  92.             display="L-Alt",
  93.             fun=function()
  94.                 if (hasKinetic) then
  95.                     hover = not hover
  96.                 end
  97.             end
  98.         },
  99.         ["space"] = {
  100.             display="space",
  101.             fun=function()
  102.                 spacebar = true
  103.             end
  104.         },
  105.         ["rightCtrl"] = {
  106.             display="R-Ctr",
  107.             fun=function()
  108.                 seeOres = not seeOres
  109.             end
  110.         },
  111.         ["w"] = {
  112.             display="R-Ctr",
  113.             fun=function()
  114.                 w = true
  115.             end
  116.         }
  117.     }
  118. end
  119.  
  120. local function update()
  121.     while (true) do
  122.         if (hasIntrospection) then
  123.             playerData = modules.getMetaOwner()
  124.         end
  125.        
  126.         -- ore scanner
  127.         if (hasScanner and seeOres) then
  128.             local blocks = modules.scan()
  129.             for i=#blocks, 1, -1 do
  130.                 local block = blocks[i]
  131.                 if (TARGET_ORES[block.name] == nil) then
  132.                     table.remove(blocks, i)
  133.                 end
  134.             end
  135.             blocksMap = blocks
  136.         end
  137.        
  138.         --Auto feed
  139.         if (hasIntrospection and playerData.food.hungry and false) then -- Very broken
  140.            
  141.             local inv = modules.getInventory()
  142.             for slot, meta in pairs(inv.list()) do
  143.                 local slotItem = inv.getItem(slot)
  144.                 if slotItem and acceptedFoods[meta.name] then
  145.                     slotItem.consume()
  146.                     break
  147.                 end
  148.             end
  149.            
  150.         end
  151.        
  152.         spacebar = false
  153.         sleep(0.1)
  154.     end
  155. end
  156.  
  157. local function draw()
  158.     while (true)do
  159.         if (hasGlasses) then
  160.             canvas3d.clear()
  161.             canvas.clear()
  162.            
  163.             -- Ore location
  164.             if (hasScanner) then                
  165.                 if (seeOres) then
  166.                     canvas.addText({ x = 10, y = 45 }, "Ores: ON")
  167.                     local group = canvas3d.create()
  168.                     for _, block in ipairs(blocksMap) do
  169.                         local color = TARGET_ORES[block.name]
  170.                         local box = group.addBox(block.x, block.y, block.z, 1, 1, 1, color)
  171.                         box.setDepthTested(false) -- See thru walls
  172.                     end
  173.                 else
  174.                     canvas.addText({ x = 10, y = 45 }, "Ores: OFF")
  175.                 end
  176.             end
  177.            
  178.             if (hasKinetic) then
  179.                 if (hover) then
  180.                     canvas.addText({ x = 10, y = 55 }, "Hover: ON")
  181.                 else
  182.                     canvas.addText({ x = 10, y = 55 }, "Hover: OFF")
  183.                 end
  184.             end
  185.            
  186.             if (hasLaser) then
  187.                 canvas.addText({ x = 10, y = 25 }, "Laser: " .. tostring(laserStrength))
  188.             end
  189.            
  190.             -- Compass N/S/E/W
  191.             if (hasIntrospection) then
  192.                 --local textYaw = canvas.addText({ x = 10, y = 5 }, tostring(playerData.yaw))
  193.                
  194.                 local NLocation = ((-playerData.yaw/90) * (windowWidth/2)) - windowWidth/2
  195.                 local SLocation = ((-playerData.yaw/90) * (windowWidth/2)) + windowWidth/2
  196.                 local ELocation = (-playerData.yaw/90) * (windowWidth/2)
  197.                 local WLocation = (-playerData.yaw/90) * (windowWidth/2) + windowWidth
  198.                
  199.                 canvas.addText({ x = NLocation, y = 15 }, "N")
  200.                 canvas.addText({ x = SLocation, y = 15 }, "S")
  201.                 canvas.addText({ x = WLocation, y = 15 }, "W")
  202.                 canvas.addText({ x = ELocation, y = 15 }, "E")
  203.             end
  204.         end
  205.        
  206.         sleep(0.1)
  207.     end
  208. end
  209.  
  210. local function fly()
  211.     while (true) do
  212.        
  213.         if (hover and hasKinetic) then
  214.             playerData = modules.getMetaOwner()
  215.            
  216.             if (w) then
  217.                 modules.launch(playerData.yaw, playerData.pitch, 1)
  218.                 w=false
  219.             else
  220.                 local force = 0.25
  221.                 if (playerData.motionY < 0) then
  222.                     force = 0.4
  223.                 end
  224.                
  225.                 if (playerData.isSneaking) then
  226.                     force = force/2
  227.                 elseif(spacebar) then
  228.                     force = force*2
  229.                 end
  230.                
  231.                 modules.launch(0, -90, math.min(4, math.abs(force)))
  232.             end
  233.            
  234.             --sleep(0.1)
  235.         else
  236.             sleep(1)
  237.         end
  238.        
  239.     end
  240. end
  241.  
  242. local function keyPress()
  243.     while (true) do
  244.         local event, key, is_held = os.pullEvent("key")
  245.         key = keys.getName(key) -- transform key number to word
  246.         --print(key)
  247.        
  248.         local keyObj = keyMappings[key]
  249.         if (keyObj) then
  250.             keyObj.fun()
  251.         end
  252.     end
  253. end
  254.  
  255. load()
  256. parallel.waitForAny(update, draw, keyPress, fly)
Advertisement
Add Comment
Please, Sign In to add comment