Page 1 of 2

Repairing with Simple Repair Hammers on the go.

Posted: Tue Aug 23, 2011 9:54 pm
by Wildfire
I have spent the past couple of weeks tearing my hair out over this and I stand before you humbly begging assistance. Hell I will even bribe with cookies on this one if I must.

What am I trying to achieve?
While harvesting my dailys I want the bot to use Simple Repair Hammers on main hand weapon when it drops below 100 dura or 90%.

Now believe me I have tried googling for a solution and although the RoMBot wiki provides examples, it doesn't show or explain from the prospective of a... (shall I say it?) noob. ^^
I am aware that I can repair at a vender however sometimes it isn't always possible due to distance or terrain.

This is what I have been able to scape together thus far.

Code: Select all

<onLeaveCombat>
	local dura = inventory:getMainHandDurability();
	printf("Durability:%s\n", dura);
	if( dura < 90 ) then
	inventory:useItem("Simple Repair Hammer");
	end
</onLeaveCombat>
Would someone be kind enough assist me in this simple yet eluding task? or at least point me in the right direction.

Re: Repairing with Simple Repair Hammers on the go.

Posted: Tue Aug 23, 2011 10:41 pm
by lisa
You are pretty close
use this instead of the dura check you use.

Code: Select all

if ( 90 > dura ) then
also you need to target the equipment slot to make it use the hammer, can't think of that code off hand.

Code: Select all

<onLeaveCombat>
   local dura = inventory:getMainHandDurability();
   printf("Durability:%s\n", dura);
   if ( 90 > dura ) then
   inventory:useItem("Simple Repair Hammer");
-- add in click main weapon here
   end
</onLeaveCombat>

Re: Repairing with Simple Repair Hammers on the go.

Posted: Wed Aug 24, 2011 12:27 am
by rock5
I think it's UseEquipmentItem or PickupEquipmentItem

Code: Select all

RoMScript("UseEquipmentItem(16)")
or

Code: Select all

RoMScript("PickupEquipmentItem(16)")
I'm not 100% sure it's 16 though. I think it's 15 in the game.

Re: Repairing with Simple Repair Hammers on the go.

Posted: Wed Aug 24, 2011 12:51 am
by lisa
I think use would be right click, so that prob wouldnt work. I would go with pickup item.

Would be a good idea to add in a check to make sure icon has changed before using that code, you don't really want to pick up your weapon.

Re: Repairing with Simple Repair Hammers on the go.

Posted: Wed Aug 24, 2011 7:01 am
by Wildfire
lisa wrote: You are pretty close
use this instead of the dura check you use.

Code: Select all

if ( 90 > dura ) then
also you need to target the equipment slot to make it use the hammer, can't think of that code off hand.

Code: Select all

<onLeaveCombat>
   local dura = inventory:getMainHandDurability();
   printf("Durability:%s\n", dura);
   if ( 90 > dura ) then
   inventory:useItem("Simple Repair Hammer");
-- add in click main weapon here
   end
</onLeaveCombat>
Really? I'm using < and it works just fine.
Using the greater or lesser than symbol directly gives me a phasing profile error. I believe it's due to the fact the greater symbol is being perceived or read as a close/open bracket as in </onLeaveCombat>
lisa wrote: also you need to target the equipment slot to make it use the hammer, can't think of that code off hand.
This is the bit that has been driving me nuts.
lisa wrote: I think use would be right click, so that prob wouldnt work. I would go with pickup item.

Would be a good idea to add in a check to make sure icon has changed before using that code, you don't really want to pick up your weapon.
Already ahead of you on that one. I knew I was close a couple of days ago when I got the mouse icon to change to a repair hammer but then the bot would halt due to my trial by error codng or nothing at all.
rock5 wrote:I think it's UseEquipmentItem or PickupEquipmentItem

Code: Select all

RoMScript("UseEquipmentItem(16)")
or

Code: Select all

RoMScript("PickupEquipmentItem(16)")
I'm not 100% sure it's 16 though. I think it's 15 in the game.
I'll give this a try later and you know how things turn out but your right, it is slot 16 for the mainhand. I believe 17 is the offhand.


Much appreciate both your inputs.

Re: Repairing with Simple Repair Hammers on the go.

Posted: Wed Aug 24, 2011 8:29 am
by rock5
I think logically you would have to "Use" the hammer and then "Pickup" the mainhand weapon.

You are right, &lt is fine and, yes, you can't normally use '<' in xml files. Most people just find it easier to change

Code: Select all

if a < b
to

Code: Select all

if b > a 
instead of remembering '&lt', me included.

Re: Repairing with Simple Repair Hammers on the go.

Posted: Wed Aug 24, 2011 8:47 am
by Wildfire
rock5 wrote:I think logically you would have to "Use" the hammer and then "Pickup" the mainhand weapon.

You are right, &lt is fine and, yes, you can't normally use '<' in xml files. Most people just find it easier to change

Code: Select all

if a < b
to

Code: Select all

if b > a 
instead of remembering '&lt', me included.
It's a html coding habbit for me. But hell, as long as you can understand your own coding either way works :lol:
Oh and it's 15 not 16 for mainhand in-game as you first suspected.

All is working like a charm now.

Lisa, Rock5... my gratitude to you both!

Re: Repairing with Simple Repair Hammers on the go.

Posted: Wed Aug 24, 2011 8:50 am
by lisa
Yeah my post was purely in deciding between the 2 sendmacro rock posted.

Using the weapon would be a right click which you dont want.

Picking up the weapon would be a left click.

So use

Code: Select all

RoMScript("PickupEquipmentItem(16)")

Re: Repairing with Simple Repair Hammers on the go.

Posted: Fri Oct 05, 2012 4:20 am
by newton666
hi did anyone get this to work?

Code: Select all

]]></onLeaveCombat>
   local dura = inventory:getMainHandDurability();
   printf("Durability:%s\n", dura);
   if ( 90 > dura ) then
   inventory:useItem("Simple Repair Hammer");
    RoMScript("PickupEquipmentItem(15)");
   end
]]></onLeaveCombat>
just that it dosnt do anything thing

Re: Repairing with Simple Repair Hammers on the go.

Posted: Fri Oct 05, 2012 4:59 am
by rock5
This is an open tag

Code: Select all

<onLeaveCombat>
and this is a close tag

Code: Select all

</onLeaveCombat>
The code goes between. Those other square brackets don't belong there.

So something like this should work.

Code: Select all

<onLeaveCombat>
   local dura = inventory:getMainHandDurability();
   printf("Durability:%s\n", dura);
   if ( 90 > dura ) then
      inventory:useItem("Simple Repair Hammer");
      RoMScript("PickupEquipmentItem(15)");
   end
</onLeaveCombat>

Re: Repairing with Simple Repair Hammers on the go.

Posted: Fri Oct 05, 2012 5:37 am
by newton666
thxs stupid me ;)

Re: Repairing with Simple Repair Hammers on the go.

Posted: Sun Oct 07, 2012 2:20 am
by newton666
i'm scrathcing my head here trying to make this repair mainhand and offhand at the same time , any clues?
Main weapon repair fine.
i know off hand is 16 but how do you get it to check if it need repair .

thx

Re: Repairing with Simple Repair Hammers on the go.

Posted: Sun Oct 07, 2012 3:26 am
by rock5
Well if you look at the getMainHandDurability function in inventory.lua you can see that all it does is return

Code: Select all

equipment:getDurability( 15 )
Yes, there is an equipment class now. So for off hand you would use 16. You can also use

Code: Select all

inventory:getDurability( 16 )
which is there for backward compatibility and points to the same function.

Re: Repairing with Simple Repair Hammers on the go.

Posted: Sun Oct 07, 2012 4:25 am
by newton666
you mean i i need ot do is this

Code: Select all

	<onLeaveCombat><![CDATA[
player:lootAll()
  local dura = inventory:getMainHandDurability();
   printf("Durability:%s\n", dura);
   if ( 50> dura ) then
   inventory:useItem("Simple Repair Hammer");
    RoMScript("PickupEquipmentItem(15)");
inventory:useItem("Simple Repair Hammer");
 inventory:getDurability( 16 ):

end

]]></onLeaveCombat>
tried it but just keeps hammering main and not off hand

Re: Repairing with Simple Repair Hammers on the go.

Posted: Sun Oct 07, 2012 4:40 am
by rock5
You asked how to get the durability of the off hand. That is what that command does. Using the hammer on the off hand is easy. Just use "RoMScript("PickupEquipmentItem(16)".

To test each hand and repair as necessary it should look like this.

Code: Select all

<onLeaveCombat>
   -- Repair main hand
   local dura = inventory:getMainHandDurability();
   printf("Main hand durability:%s\n", dura);
   if ( 50 > dura ) then
      inventory:useItem("Simple Repair Hammer");
      RoMScript("PickupEquipmentItem(15)");
   end
   -- Repair off hand
   local dura = inventory:getDurability(16);
   printf("Off hand durability:%s\n", dura);
   if ( 50 > dura ) then
      inventory:useItem("Simple Repair Hammer");
      RoMScript("PickupEquipmentItem(16)");
   end
</onLeaveCombat>

Re: Repairing with Simple Repair Hammers on the go.

Posted: Sun Oct 07, 2012 5:33 am
by newton666
you rock rock thanks alot

Re: Repairing with Simple Repair Hammers on the go.

Posted: Fri Nov 02, 2012 11:11 pm
by SpringSun
how to put those things in DIYCE and where i should put the code..

Thanks

Re: Repairing with Simple Repair Hammers on the go.

Posted: Sun Nov 04, 2012 2:17 am
by abron1
hey rock if leveling the skill on a mob how would you use this code if you never leave combat? do you just put it in the onload? and it will check every so often?

Re: Repairing with Simple Repair Hammers on the go.

Posted: Sun Nov 04, 2012 4:49 am
by rock5
For leveling your weapon skill you would usually have some sort of custom written loop. You would just need add the code in the loop.

Re: Repairing with Simple Repair Hammers on the go.

Posted: Sat Sep 21, 2013 2:20 pm
by rido_knight
rock5 wrote:This is an open tag

Code: Select all

<onLeaveCombat>
and this is a close tag

Code: Select all

</onLeaveCombat>
The code goes between. Those other square brackets don't belong there.

So something like this should work.

Code: Select all

<onLeaveCombat>
   local dura = inventory:getMainHandDurability();
   printf("Durability:%s\n", dura);
   if ( 90 > dura ) then
      inventory:useItem("Simple Repair Hammer");
      RoMScript("PickupEquipmentItem(15)");
   end
</onLeaveCombat>
i tried this macro but didnt work :( Macro choose Hammer but not click on Main Hand and continue to kill monster :/