Filmos

Casino - test

Jun 14th, 2024 (edited)
567
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.13 KB | None | 0 0
  1. function convertUUIDToHex(uuid)
  2.     -- Ensure the input is a table with 4 integers
  3.     if type(uuid) ~= "table" or #uuid ~= 4 then
  4.         error("Invalid UUID format. Expected a table with 4 integers.")
  5.     end
  6.  
  7.     -- Helper function to convert a signed integer to an unsigned 32-bit hexadecimal
  8.     local function toHex(num)
  9.         if num < 0 then
  10.             num = num + 0x100000000 -- Convert negative to unsigned 32-bit
  11.         end
  12.         return string.format("%08x", num)
  13.     end
  14.  
  15.     -- Convert each integer to an 8-digit hexadecimal string
  16.     local hexParts = {}
  17.     for i = 1, 4 do
  18.         table.insert(hexParts, toHex(uuid[i]))
  19.     end
  20.  
  21.     -- Concatenate the parts with hyphens in the correct places
  22.     local hexUUID = table.concat({hexParts[1]:sub(1, 8), hexParts[2]:sub(1, 4), hexParts[2]:sub(5, 8),
  23.                                   hexParts[3]:sub(1, 4), hexParts[3]:sub(5, 8) .. hexParts[4]:sub(1, 8)}, "-")
  24.  
  25.     return hexUUID
  26. end
  27.  
  28. function extractUUID()
  29.     s = peripheral.wrap("top")
  30.     return s.getItemDetail(1)["rawNBT"]["BlockEntityTag"]["LootrOpeners"][1]
  31. end
  32.  
  33. print(convertUUIDToHex(extractUUID()))
  34.  
Advertisement
Add Comment
Please, Sign In to add comment