Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function convertUUIDToHex(uuid)
- -- Ensure the input is a table with 4 integers
- if type(uuid) ~= "table" or #uuid ~= 4 then
- error("Invalid UUID format. Expected a table with 4 integers.")
- end
- -- Helper function to convert a signed integer to an unsigned 32-bit hexadecimal
- local function toHex(num)
- if num < 0 then
- num = num + 0x100000000 -- Convert negative to unsigned 32-bit
- end
- return string.format("%08x", num)
- end
- -- Convert each integer to an 8-digit hexadecimal string
- local hexParts = {}
- for i = 1, 4 do
- table.insert(hexParts, toHex(uuid[i]))
- end
- -- Concatenate the parts with hyphens in the correct places
- local hexUUID = table.concat({hexParts[1]:sub(1, 8), hexParts[2]:sub(1, 4), hexParts[2]:sub(5, 8),
- hexParts[3]:sub(1, 4), hexParts[3]:sub(5, 8) .. hexParts[4]:sub(1, 8)}, "-")
- return hexUUID
- end
- function extractUUID()
- s = peripheral.wrap("top")
- return s.getItemDetail(1)["rawNBT"]["BlockEntityTag"]["LootrOpeners"][1]
- end
- print(convertUUIDToHex(extractUUID()))
Advertisement
Add Comment
Please, Sign In to add comment