ame824

CC:Androids Defender

Feb 27th, 2026 (edited)
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.25 KB | None | 0 0
  1. --
  2. -- Defender Android Module (V11)
  3. -- by ame824
  4. --
  5.  
  6. local center = android.getSelf()
  7. local cx, cy, cz = center.posX, center.posY, center.posZ
  8. local MIN_FUEL = 500
  9. local hasWarned = false
  10.  
  11. local weaponTypes = {
  12.     "sword", "blade", "rapier", "katana", "sai", "spear",
  13.     "glaive", "cutlass", "claymore", "hammer", "axe",
  14.     "chakram", "scythe", "halberd"
  15. }
  16.  
  17. local hostileMobs = {
  18.     "zombie", "skeleton", "creeper", "spider", "enderman", "slime", "witch", "pillager"
  19. }
  20.  
  21. print("--- Wachmodus V11 Aktiv ---")
  22.  
  23. function isReady()
  24.     local currentFuel = android.fuelLevel()
  25.    
  26.     -- 1. HAND-INFO (Erster Wert ist der Name laut Bild)
  27.     local hName, _ = android.getHandInfo("main")
  28.     local hand = tostring(hName or "empty"):lower()
  29.    
  30.     local ohName, _ = android.getHandInfo("off")
  31.     local offhand = tostring(ohName or "empty"):lower()
  32.  
  33.     -- 2. INVENTAR-SCAN (Spezial-Logik für Slots)
  34.     local inv = {}
  35.     local freeSlot, redstoneSlot, swordSlot, totemSlot = -1, -1, -1, -1
  36.  
  37.     for i = 0, 15 do
  38.         local v1, v2 = android.getSlotInfo(i)
  39.         local name = "empty"
  40.        
  41.         -- Slot-Logik: v1 ist oft false, dann ist v2 der Name
  42.         if type(v1) == "string" then
  43.             name = v1:lower()
  44.         elseif v1 == false and type(v2) == "string" then
  45.             name = v2:lower()
  46.         end
  47.        
  48.         inv[i] = name
  49.  
  50.         if name == "empty" or name == "air" then
  51.             if freeSlot == -1 then freeSlot = i end
  52.         else
  53.             if name:find("redstone") then redstoneSlot = i
  54.             elseif name:find("totem") then totemSlot = i end
  55.            
  56.             for _, wType in ipairs(weaponTypes) do
  57.                 if name:find(wType) then
  58.                     swordSlot = i
  59.                     break
  60.                 end
  61.             end
  62.         end
  63.     end
  64.  
  65.     -- 3. OFFHAND CHECK (Totem)
  66.     -- Wenn Name "air" oder "empty" ist, rüste das Totem aus
  67.     --if (offhand == "air" or offhand == "empty") and totemSlot ~= -1 then
  68.    --     print("Offhand leer. Totem aus Slot " .. totemSlot .. " wird ausgeruestet.")
  69.    --     android.equipSlot(totemSlot, "off")
  70.    --     sleep(0.4)
  71.    --     return true -- Im nächsten Loop weiter
  72.    -- end
  73.  
  74.     -- 4. WAFFEN CHECK
  75.     if hand == "air" or hand == "empty" then
  76.         if swordSlot ~= -1 then
  77.             print("Waffe ausgerüstet: " .. inv[swordSlot])
  78.             android.equipSlot(swordSlot, "main")
  79.             sleep(0.5)
  80.             return true
  81.         else
  82.             if not hasWarned then
  83.                 android.sendChatMessage("Keine Waffe gefunden!")
  84.                 android.changeFace("sad")
  85.                 hasWarned = true
  86.             end
  87.             return false
  88.         end
  89.     end
  90.  
  91.     -- 5. FUEL CHECK
  92.     if currentFuel < MIN_FUEL then
  93.         android.changeFace("woozy")
  94.         if redstoneSlot ~= -1 and freeSlot ~= -1 then
  95.             android.storeItem(freeSlot)
  96.             sleep(0.3)
  97.             android.equipSlot(redstoneSlot, "main")
  98.             sleep(0.3)
  99.             android.refuel()
  100.             print("Aufgetankt.")
  101.             hasWarned = false
  102.             return true
  103.         end
  104.         return false
  105.     end
  106.  
  107.     hasWarned = false
  108.     return true
  109. end
  110.  
  111. -- Hauptschleife (unverändert)
  112. while true do
  113.     if isReady() then
  114.         local currentTask = android.currentTask()
  115.         if currentTask == "idle" then
  116.             android.changeFace("happy")
  117.             local target = nil
  118.             for _, mType in ipairs(hostileMobs) do
  119.                 local mob = android.getClosestMob(mType)
  120.                 if mob and mob.uuid then target = mob.uuid; break end
  121.             end
  122.             if target then
  123.                 android.changeFace("annoyed")
  124.                 android.attack(target)
  125.             else
  126.                 local me = android.getSelf()
  127.                 if math.sqrt((me.posX-cx)^2 + (me.posZ-cz)^2) > 2 then
  128.                     android.moveTo(cx, cy, cz)
  129.                 end
  130.             end
  131.         end
  132.     else
  133.         if android.currentTask() ~= "idle" then android.cancelTask() end
  134.         local me = android.getSelf()
  135.         if math.sqrt((me.posX-cx)^2 + (me.posZ-cz)^2) > 1.5 then
  136.             android.moveTo(cx, cy, cz)
  137.         end
  138.     end
  139.     sleep(1)
  140. end
Add Comment
Please, Sign In to add comment