Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --
- -- Defender Android Module (V11)
- -- by ame824
- --
- local center = android.getSelf()
- local cx, cy, cz = center.posX, center.posY, center.posZ
- local MIN_FUEL = 500
- local hasWarned = false
- local weaponTypes = {
- "sword", "blade", "rapier", "katana", "sai", "spear",
- "glaive", "cutlass", "claymore", "hammer", "axe",
- "chakram", "scythe", "halberd"
- }
- local hostileMobs = {
- "zombie", "skeleton", "creeper", "spider", "enderman", "slime", "witch", "pillager"
- }
- print("--- Wachmodus V11 Aktiv ---")
- function isReady()
- local currentFuel = android.fuelLevel()
- -- 1. HAND-INFO (Erster Wert ist der Name laut Bild)
- local hName, _ = android.getHandInfo("main")
- local hand = tostring(hName or "empty"):lower()
- local ohName, _ = android.getHandInfo("off")
- local offhand = tostring(ohName or "empty"):lower()
- -- 2. INVENTAR-SCAN (Spezial-Logik für Slots)
- local inv = {}
- local freeSlot, redstoneSlot, swordSlot, totemSlot = -1, -1, -1, -1
- for i = 0, 15 do
- local v1, v2 = android.getSlotInfo(i)
- local name = "empty"
- -- Slot-Logik: v1 ist oft false, dann ist v2 der Name
- if type(v1) == "string" then
- name = v1:lower()
- elseif v1 == false and type(v2) == "string" then
- name = v2:lower()
- end
- inv[i] = name
- if name == "empty" or name == "air" then
- if freeSlot == -1 then freeSlot = i end
- else
- if name:find("redstone") then redstoneSlot = i
- elseif name:find("totem") then totemSlot = i end
- for _, wType in ipairs(weaponTypes) do
- if name:find(wType) then
- swordSlot = i
- break
- end
- end
- end
- end
- -- 3. OFFHAND CHECK (Totem)
- -- Wenn Name "air" oder "empty" ist, rüste das Totem aus
- --if (offhand == "air" or offhand == "empty") and totemSlot ~= -1 then
- -- print("Offhand leer. Totem aus Slot " .. totemSlot .. " wird ausgeruestet.")
- -- android.equipSlot(totemSlot, "off")
- -- sleep(0.4)
- -- return true -- Im nächsten Loop weiter
- -- end
- -- 4. WAFFEN CHECK
- if hand == "air" or hand == "empty" then
- if swordSlot ~= -1 then
- print("Waffe ausgerüstet: " .. inv[swordSlot])
- android.equipSlot(swordSlot, "main")
- sleep(0.5)
- return true
- else
- if not hasWarned then
- android.sendChatMessage("Keine Waffe gefunden!")
- android.changeFace("sad")
- hasWarned = true
- end
- return false
- end
- end
- -- 5. FUEL CHECK
- if currentFuel < MIN_FUEL then
- android.changeFace("woozy")
- if redstoneSlot ~= -1 and freeSlot ~= -1 then
- android.storeItem(freeSlot)
- sleep(0.3)
- android.equipSlot(redstoneSlot, "main")
- sleep(0.3)
- android.refuel()
- print("Aufgetankt.")
- hasWarned = false
- return true
- end
- return false
- end
- hasWarned = false
- return true
- end
- -- Hauptschleife (unverändert)
- while true do
- if isReady() then
- local currentTask = android.currentTask()
- if currentTask == "idle" then
- android.changeFace("happy")
- local target = nil
- for _, mType in ipairs(hostileMobs) do
- local mob = android.getClosestMob(mType)
- if mob and mob.uuid then target = mob.uuid; break end
- end
- if target then
- android.changeFace("annoyed")
- android.attack(target)
- else
- local me = android.getSelf()
- if math.sqrt((me.posX-cx)^2 + (me.posZ-cz)^2) > 2 then
- android.moveTo(cx, cy, cz)
- end
- end
- end
- else
- if android.currentTask() ~= "idle" then android.cancelTask() end
- local me = android.getSelf()
- if math.sqrt((me.posX-cx)^2 + (me.posZ-cz)^2) > 1.5 then
- android.moveTo(cx, cy, cz)
- end
- end
- sleep(1)
- end
Add Comment
Please, Sign In to add comment