Advertisement
giwdul

Untitled

Jun 11th, 2025
1,162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.84 KB | None | 0 0
  1. -- Programme pour recuperer le nom du proprietaire d'un shop Lightman Currency
  2.  
  3. -- Configuration
  4. local SHOP_SIDE = "right"  -- Direction du shop
  5.  
  6. -- Connexion au shop
  7. local shop = peripheral.wrap(SHOP_SIDE)
  8.  
  9. -- Verification
  10. if not shop then
  11.     print("❌ Erreur: Shop non trouve sur " .. SHOP_SIDE)
  12.     print("Peripheriques disponibles:")
  13.     for _, name in pairs(peripheral.getNames()) do
  14.         print("  - " .. name .. " (" .. peripheral.getType(name) .. ")")
  15.     end
  16.     return
  17. end
  18.  
  19. print("=== VERIFICATEUR DE PROPRIETAIRE ===")
  20. print("Shop detecte: " .. peripheral.getType(SHOP_SIDE))
  21. print()
  22.  
  23. -- Fonction pour obtenir le nom du proprietaire
  24. function getShopOwner()
  25.     if not shop.getOwnerName then
  26.         return false, "Fonction getOwnerName non disponible"
  27.     end
  28.    
  29.     local success, owner = pcall(function()
  30.         return shop.getOwnerName()
  31.     end)
  32.    
  33.     return success, owner
  34. end
  35.  
  36. -- Recuperer le proprietaire
  37. local success, owner = getShopOwner()
  38.  
  39. if success then
  40.     if owner and owner ~= "" then
  41.         print("✅ Proprietaire du shop: " .. owner)
  42.     else
  43.         print("❓ Shop sans proprietaire ou proprietaire vide")
  44.     end
  45. else
  46.     print("❌ Erreur lors de la recuperation: " .. tostring(owner))
  47. end
  48.  
  49. print()
  50.  
  51. -- Informations supplementaires si disponibles
  52. print("=== INFORMATIONS SUPPLEMENTAIRES ===")
  53.  
  54. -- Essayer d'autres fonctions utiles
  55. local functions_to_test = {
  56.     {name = "getTrades", description = "Trades disponibles"},
  57.     {name = "getName", description = "Nom du shop"},
  58.     {name = "size", description = "Taille de l'inventaire"}
  59. }
  60.  
  61. for _, func_info in ipairs(functions_to_test) do
  62.     if shop[func_info.name] then
  63.         local success, result = pcall(function()
  64.             return shop[func_info.name]()
  65.         end)
  66.        
  67.         if success then
  68.             print("✅ " .. func_info.description .. ":")
  69.             if type(result) == "table" then
  70.                 print("  Type: table (contient " .. #result .. " elements)")
  71.                 -- Afficher les premiers elements si c'est une liste
  72.                 for i = 1, math.min(3, #result) do
  73.                     print("  [" .. i .. "]: " .. tostring(result[i]))
  74.                 end
  75.                 if #result > 3 then
  76.                     print("  ... et " .. (#result - 3) .. " de plus")
  77.                 end
  78.             else
  79.                 print("  Valeur: " .. tostring(result))
  80.             end
  81.         else
  82.             print("❌ " .. func_info.description .. ": " .. tostring(result))
  83.         end
  84.     else
  85.         print("❓ " .. func_info.description .. ": fonction non disponible")
  86.     end
  87. end
  88.  
  89. print()
  90. print("=== RESUME ===")
  91. if success and owner and owner ~= "" then
  92.     print("🏪 Shop appartient a: " .. owner)
  93. else
  94.     print("❓ Proprietaire non determine")
  95. end
  96. print("Analyse terminee.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement