Advertisement
Guest User

integer.lua

a guest
Nov 1st, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.54 KB | None | 0 0
  1. --To use, call from shell with the integer you wish to pass
  2. --precede with _ instead of - for negative numbers
  3.  
  4. shell = require("shell")
  5. params, args = shell.parse(...)
  6. component = require("component")
  7. outputs = {}
  8. for address in component.list("redstone") do
  9.   outputs[component.proxy(address).getInput(1)] = component.proxy(address)
  10. end
  11.  
  12. input = string.gsub(params[1], "_", "-")
  13. input = tonumber(input)
  14. hex = string.format("%.8x", math.floor(math.abs(2*input+0.5)))
  15.  
  16. for i, v in pairs(outputs) do
  17.   v.setOutput(5, tonumber("0x"..hex:sub(i,i)))
  18. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement