Log in

View Full Version : Equip Looted Item



djnacht
12-31-2015, 11:11 PM
Hello,

The idea behind this script would be to verify items that are looted and to check if they have better characteristics than the equipment currently worn by my character. If they do have better stats, then I would like the bot to wear the new piece of equipment and throw the old one on the floor.

The only way I could see myself doing this would be adding a label every waypoint called "CheckEQ" that looks at my inventory to check if I looted some sort of piece of equipment that would be better for my character. I would much rather have the bot decide all this after it loots a creature, but I don't think there are any methods of doing that.

Any suggestions?

Proteus
01-02-2016, 04:37 PM
Hello,

The idea behind this script would be to verify items that are looted and to check if they have better characteristics than the equipment currently worn by my character. If they do have better stats, then I would like the bot to wear the new piece of equipment and throw the old one on the floor.

The only way I could see myself doing this would be adding a label every waypoint called "CheckEQ" that looks at my inventory to check if I looted some sort of piece of equipment that would be better for my character. I would much rather have the bot decide all this after it loots a creature, but I don't think there are any methods of doing that.

Any suggestions?
Hi there! This is very possible, easiest if you expect something to be looted. I actually use this in my rook script (I made a rook script to get from 1-20 during which time to save supplies and level faster, I have it loot better gear/weapons then equip them if they exist)

I don't use lables to do this though since you'll be carrying the gear around for a while then (I have my script drop the unused gear since it has no value though). They way I do it is by using modules, a constant scan to see what gear you've looted and by using Self.Weapon().id,Self.Armor().id etc. you can see if its what you'd prefer

djnacht
01-02-2016, 06:29 PM
That sounds about right. I have no idea what modules are though, I'll see if I can figure it out.

Just found this http://forums.xenobot.net/showthread.php?11767-Can-someone-explain-Modules-a-little/page2

It explains it all perfectly.

xux
01-02-2016, 06:44 PM
Yea i got such thing in my own dawnport script as well its like this

local longsword = false
Checker = Module.New('longsword checker', function(mod)
if (Self.ItemCount(3285) >0 and longsword ==false) then
Cavebot.Stop()
print("Holy cow!! It is the longsword!!")
Self.Equip(3285, "weapon", 1)
wait(1500)
Self.DropItems(Self.Position().x, Self.Position().y, Self.Position().z, 3273)
wait(1500)
longsword = true
Cavebot.Start()
Checker:Stop()
mod:Delay(20000)
end
mod:Delay(19000)
end
)


Module.New('sword dropper', function(module)
if (Self.ItemCount(3285) > 1) then
delayWalker(1000)
print("Dropping longsword.")
Self.DropItem(Self.Position().x, Self.Position().y, Self.Position().z, 3285, 1)
else


end
module:Delay(2000,10000)
end)

djnacht
01-05-2016, 10:56 PM
xux:

I'm confused about this line here: Checker = Module.New('longsword checker', function(mod)

What does function(mod) mean and what are these lines of code found a bit later on : mod: Delay(20000)?

xux
01-05-2016, 11:29 PM
xux:

I'm confused about this line here: Checker = Module.New('longsword checker', function(mod)

What does function(mod) mean and what are these lines of code found a bit later on : mod: Delay(20000)?
It just means that the module get's delayed for 20 seconds before starting again.

djnacht
01-06-2016, 02:07 AM
It just means that the module get's delayed for 20 seconds before starting again.

Ok, so the script picks up all Longswords and then checks every 20 seconds if there is a longsword in the backpack.

The : really throws me off, I'm new to all this and I haven't seen the colon used anywhere yet.

Why is the parameter "Mod" passed to the function when you create a new module? I don't see that function declared anywhere.

djnacht
01-19-2016, 04:08 AM
Ok, so I've made a bit of progress on my own.

function(mod) is what is called a anonymous function, so that makes sense to me now.

"An important note is that in order to utilize the Module: Delay() function, you need to pass the module object to the function that you are calling."

I still don't understand the parameter "mod" though and when and how it is being passed into the function. It is supposedly a module object, but how did it get there?

I'm also confused as to what is being assigned to "Checker", because if I check its type it says its a table.

Checker:Stop() doesn't seem to do anything, or nothing that I notice.

Could someone help me with these questions, please?
I know they are not really related to Xenobot, and more related to Lua, but I would still love for some help, or someone to tell me what to Google would be fine.