XenoBot Forums - Powered by vBulletin

User Tag List

Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: Need Help with a couple of LUA scripts

  1. #1

    Join Date
    Dec 2012
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Need Help with a couple of LUA scripts

    Hey Guys,

    Just got Xenobot last night, real excited - but needing some advise on a couple of scripts to help me afk train

    1) Script to stop attacking current summons Slime and kill "Slime Mother" if my character is less than 80% hp

    2) Script to eat a brown mushroom (or any item id number) ever "x" amount of time (time can be designated)

    I'm Using CrazySwe's slime training script and its working great - but these 2 scripts would allow me to fully afk train without worry of death!

    Thanks in advance for any help!

  2. #2
    Super Moderator Infernal Bolt's Avatar
    Join Date
    Dec 2011
    Location
    Skellefteċ, Sweden
    Posts
    2,880
    Mentioned
    217 Post(s)
    Tagged
    2 Thread(s)
    there is a food eater built in under tools

  3. #3

    Join Date
    Dec 2012
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Durrr thanks Infernal Bolt!

    That solves that one - just need the kill script to make it perfect!

    Anyone have suggestions???

  4. #4
    Administrator
    Join Date
    Dec 2010
    Posts
    2,565
    Mentioned
    228 Post(s)
    Tagged
    1 Thread(s)
    I don't know exactly how all this new-fangled Lua stuff works but try this.
    [code=lua]
    function getMother()
    for i = CREATURES_LOW, CREATURES_HIGH do
    local c = Creature.New(i)
    if c:Name() == "Slime" and c:HealthPercent() <= 75 then
    return c
    end
    end
    end

    local mother = getMother()

    Module.New('slime-trainer', function(module)
    if mother:isAlive() and Self.HealthPercent() <= 80 then
    mother:Attack()
    module:Pause()
    end
    end)
    [/code]

    @Syntax could probably write a better one.

  5. #5

    Join Date
    Dec 2012
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks so much, Spectrus - I'll give this a try and test a few different scenarios in training that could possibly get me killed.

    I'll follow up and let you know if it works, but I really appreciate the attempt to begin with sir!

  6. #6

    Join Date
    Dec 2012
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm getting the following error code when I try to execute the script:
    "Xenoscript Error:
    Script: killiflowhealth.lua
    Line #: 13
    Error: Attempt to call field 'HealthPercent' (a nil value)

    Any ideas? Sorry, I really am illiterate when it comes to LUA scripting Luckily with neobot back in the day they had a great community for help - much like it seems we have here!

    I wanted to add... it seems the error comes into play when a slime is summoned by the mother. The script will execute initially until a slime is summoned it won't give that error
    Last edited by mjbz68; 01-12-2013 at 04:51 PM. Reason: adding addiotional details

  7. #7
    Lifetime Subscriber
    Join Date
    Dec 2011
    Posts
    994
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    Code:
    function getMother()
        for i = CREATURES_LOW, CREATURES_HIGH do
            local c = Creature.New(i)
            if c:Name() == "Slime" and c:HealthPercent() <= 75 then
                return c
            end
        end
    end
    
    local mother = getMother()
    local me = Creature.GetByID(Self.ID())
    
    Module.New('slime-trainer', function(module)
        if mother:isAlive() and me:HealthPercent() <= 80 then
            mother:Attack()
            module:Pause()
        end
    end)

  8. #8

    Join Date
    Dec 2012
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by soul4soul View Post
    Code:
    function getMother()
        for i = CREATURES_LOW, CREATURES_HIGH do
            local c = Creature.New(i)
            if c:Name() == "Slime" and c:HealthPercent() <= 75 then
                return c
            end
        end
    end
    
    local mother = getMother()
    local me = Creature.GetByID(Self.ID())
    
    Module.New('slime-trainer', function(module)
        if mother:isAlive() and me:HealthPercent() <= 80 then
            mother:Attack()
            module:Pause()
        end
    end)
    Just tried this one out - the script stayed executed and didn't kill itself this time when a slime was summoned, however, I received this error:

    "Xenoscript Error:
    Script: killiflowhealth.lua
    Line #: 16
    Error: Attempt to call method 'Pause' (a nil value)

    Sorry for the noob questions - I am trying to self-educate on Lua as well by reading some guides so hopefully someday I can be more self-sufficient!

  9. #9

    Join Date
    Dec 2012
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could it be a problem with some combination of the scripts you two have provided working in combination with CrazySwe's slime training script?

  10. #10
    Lifetime Subscriber
    Join Date
    Dec 2011
    Posts
    994
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mjbz68 View Post
    Just tried this one out - the script stayed executed and didn't kill itself this time when a slime was summoned, however, I received this error:

    "Xenoscript Error:
    Script: killiflowhealth.lua
    Line #: 16
    Error: Attempt to call method 'Pause' (a nil value)

    Sorry for the noob questions - I am trying to self-educate on Lua as well by reading some guides so hopefully someday I can be more self-sufficient!
    did it kill the mother when you had less then 80% health? Im not positive what spec meant to do with Pause() I think he meant Stop().
    Code:
    function getMother()
        for i = CREATURES_LOW, CREATURES_HIGH do
            local c = Creature.New(i)
            if c:Name() == "Slime" and c:HealthPercent() <= 75 then
                return c
            end
        end
    end
    
    local mother = getMother()
    local me = Creature.GetByID(Self.ID())
    
    Module.New('slime-trainer', function(module)
        if mother:isAlive() and me:HealthPercent() <= 80 then
            mother:Attack()
            module:Stop()
        end
    end)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •