Log in

View Full Version : Paladin Need Help with a couple of LUA scripts



mjbz68
01-12-2013, 08:05 AM
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!

Infernal Bolt
01-12-2013, 08:29 AM
there is a food eater built in under tools

mjbz68
01-12-2013, 08:40 AM
Durrr thanks Infernal Bolt!

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

Anyone have suggestions???

Spectrus
01-12-2013, 09:06 AM
I don't know exactly how all this new-fangled Lua stuff works but try this.


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)


Syntax could probably write a better one.

mjbz68
01-12-2013, 04:14 PM
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!

mjbz68
01-12-2013, 04:49 PM
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

soul4soul
01-12-2013, 04:54 PM
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)

mjbz68
01-12-2013, 05:14 PM
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!

mjbz68
01-12-2013, 05:18 PM
Could it be a problem with some combination of the scripts you two have provided working in combination with CrazySwe's slime training script?

soul4soul
01-12-2013, 05:19 PM
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().

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)

mjbz68
01-12-2013, 05:27 PM
Just want to give you a quick background on the purpose: What I am doing is pushing my character out of the 2 square "safe zone" where only 2 mobs can hit you - to simulate someone coming up and moving me around if I was afk. So what happens is the mother will summon 3 slimes, and I will get surrounded and hit down to death.

The purpose of the script is to switch targets to the mother slime if I'm below 80% to kill it and log me off - to avoid death and the possibility of being messed with by people seeking out botters.

The script did not kill the mother slime - as soon as I hit 80% health, I got the error and my character just stood there getting hit by all 4 slimes and didn't kill the mother.

p.s - forgot to metion - I'm going to try your edit in a sec here when the slime respawns :)

mjbz68
01-12-2013, 06:04 PM
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().

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)

The new one you posted works!!!! This is literally perfect!!!

I ran one of my other characters over and tested it a few different ways - everytime the mother slime got killed when I dropped below 80% health!!!

Thank you SOOOO much soul4soul for getting it perfect - and Spectrus for all of your help today, you guys are amazing :)

now 1 final question.... does the bot have a built in log out feature? or do I need to add a small bit of Lua code at the end of this script to log me out after killing the slime.

Spectrus
01-12-2013, 11:15 PM
No logout feature, you need to wait 15 min for kick :(.

soul4soul I didn't check documentation on Modules. No idea what I'm doing. :D thanks for the fix.

mjbz68
01-18-2013, 01:53 PM
Did something change with the functions in my script?? Died afk training on my paladin yesterday :( So I did a little research and found out that when I get to below 80% the character is not switching targets to the mother slime like it should (and once was) - thus the death.

Any ideas?

soul4soul
01-18-2013, 02:25 PM
that not that i am aware of. remember the mother slime needs to have under 75% hp.

mjbz68
01-18-2013, 10:07 PM
that not that i am aware of. remember the mother slime needs to have under 75% hp.

Interesting.... I guess I will need to run some more tests - every time I go to pull the slime to my training spot I always hit it down to 10-25% health on the way there, so I am confident that was not the problem in this case.

I did some quick tests this morning and it didn't work - but I'll mess around with it tonight when I return from work and update everyone on the status.

Thanks soul4soul!!!

Also: this is an odd request.... but I've come across something that may have been the reason I died.... I noticed that when I died - I was out of small stones.... so possibly what happened was I had no stones in my hand and could not kill the mother slime fast enough (even though my fisting skill is 33 from training FOREVER in the past too :)) and so I died as a result...

Therefore - would there be any potential for a script that would: if no small stones (item #1781) in hand - kill mother slime?...... and while I'm at it: if player on screen - kill mother slime?

These would be monumentally helpful for me to avoid reports/bans/death.

Furthermore.... I don't want to keep bothering you expert scriptwriters. Is there some sort of a general Lua command guide you can refer me to? I used to make my own scripts pieced together from the Neobot community - but the scripting commands are totally different for Xenobot and I'm lost!

Thanks in advance for any help/direction!

soul4soul
01-18-2013, 10:54 PM
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 or Self.ItemCount("small stone") < 1 or not Self.isAreaPvPSafe(8, false, true)) then
mother:Attack()
module:Stop()
end
end)
I havent test isAreaPvPSafe Im not 100% sure I used it correctly. Its suppose to detect players on the screen.
you might been to change "small stone" to the itemid. Im not sure if it will pick it up I believe tibia has more then 1 item called "small stone"
look in C:\Program Files (x86)\XenoBot\Data\XenoLuaLib.lua for scripting functions(or what your calling commands).

mjbz68
01-19-2013, 03:21 AM
soul4soul - once again you've outdone yourself. This script works PERFECTLY :) The play on screen function you added works beautifully!

Also, as an aside... my death was caused by something completely non-script related. Let me explain so some other poor sap doesn't die to something this silly....I wasn't aware that after the function completed and the mother slime was killed - it will not do it again without killing the script and re-executing it.... Extremely dumb, I know - but at least I realized it before I learned that hard lesson twice!

Anyhow, thanks so much for the script help ONCE again! This one is fabulous - and to all you readers out there, USE THIS!!! Modify it to your toon and have fun training for hours on end without the possibility of death! I just went 23hr full on my knight (96/95, SAME SLIME! :) Paladin (96/85) is limited to 6 because of capacity... small stones are heavy!

Have fun, kids!

soul4soul
01-19-2013, 03:08 PM
your welcome =]. thank Spectrus for starting off the script too I would of been preoccupied with other scripts.

mjbz68
01-20-2013, 02:59 AM
Ohh of course! Spectrus - you were also critical in this script creation/initial thought, and have also outdone yourself!

Thank you both :) Hopefully other readers enjoy this one too in combination with CrazySwe's slime training script/settings!

Attached are both files with 100% props/credit to a combination of CrazySwe Spectrus and soul4soul -- Thanks guys and enjoy

5888
5889

Don't forget to edit the settings & script for your character's stats! Alarms/auto logoff are enabled by default for ultimate protection.

Paladyn
06-11-2016, 08:51 AM
On the Paladin Mother-Killer.lua it comes up attempt to index upvalue 'mother' (a nil value) #line 14.