ScriptUO

Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: Paulonius on April 25, 2011, 01:31:58 PM

Title: Event Macro 22 0 Issues
Post by: Paulonius on April 25, 2011, 01:31:58 PM
I am playing with a lumberjack script and having issues getting event macro 22 to work consistently.  I have the script cutting logs into boards by assigning the log ID to #LTargetID and using event macro 22 0.  I can confirm that the value of #LtargetID is correctly assigned, but it still fails.  For some reason #LtargetID is retaining the tree targe and will try to cut the last tree I hit.  If I manually target something other than the tree, then it will accept #LtargetID assignments.  I am at a loss for what I am doing wrong.


Here is an example of the code I am having trouble with.  It works fine if I manually target something after I am done cutting trees, but otherwise never cuts the logs despite having the right IDs:


Code: [Select]
;==========================================================
Sub Cut_Logs
event sysmessage In Cut Logs
Finditem %Hatchet C_ , #CharID
   If #FindCnt < 1
      Finditem %Hatchet C_ , #BackpackID
   If #FindCnt < 1
      Return
Set %Cutwith #FindID
Finditem ZLK C_ , #BackpackID
event sysmessage Hatchet is %CutWith Logs are #Findtype #findid LtargetID is #LtargetID
For %LogCount 1 #FindCnt
   {
   Set #Findindex %LogCount
   Set #LobjectID %CutWith
   Event Macro 17 0
   target 20
   Set #LtargetID #FindID
   event sysmessage Findindex is #Findindex  TargetID is #LtargetID
   Event Macro 22 0
   Wait 20
   }
Wait 20
Return
Title: Re: Event Macro 22 0 Issues
Post by: UOMaddog on April 25, 2011, 01:46:06 PM
don't forget to set #ltargetkind !!!!! Look it up on EUO Documentation (http://wiki.easyuo.com/index.php/Documentation) so that you set it to the correct thing (tree, object, person, whatever)
Title: Re: Event Macro 22 0 Issues
Post by: Paulonius on April 25, 2011, 01:59:58 PM
I have never used #findkind other than with targeting tiles and never run into this issue. 

I inserted an assignement for #findkind to #ltargetkind and it didn't do anything.
Title: Re: Event Macro 22 0 Issues
Post by: _C2_ on April 25, 2011, 02:12:33 PM
yeppers... that will cause code not to find targets at times.  it will make a  script really random in targeting
Title: Re: Event Macro 22 0 Issues
Post by: Paulonius on April 25, 2011, 02:14:06 PM
So how do I eliminate it?  Should I be assigning #LtargetX, #LtargetY, etc?
Title: Re: Event Macro 22 0 Issues
Post by: Paulonius on April 25, 2011, 02:30:39 PM
Uhg, I am at a loss to figure this one out.
Title: Re: Event Macro 22 0 Issues
Post by: Paulonius on April 25, 2011, 03:00:15 PM
Seem to have solved it.  Finditem was giving me a kind of 0 (zero) for the logs and is subsituted 1 and it worked.
Title: Re: Event Macro 22 0 Issues
Post by: 12TimesOver on April 25, 2011, 03:12:05 PM
What they meant is that you need to manually set your #ltargetkind to 1 before targeting:

Code: [Select]
For %LogCount 1 #FindCnt
   {
   Set #Findindex %LogCount
   Set #LobjectID %CutWith
   set #ltargetkind 1     <--------------------------------
   Event Macro 17 0
   target 20
   Set #LtargetID #FindID
   Event Macro 22 0
   Wait 20
   }
Title: Re: Event Macro 22 0 Issues
Post by: Endless Night on April 25, 2011, 04:34:22 PM
you should always set the targetkind before targetting... 70% of the time you can get away with not doing it (as you manually set via a click target before opening script).. but if you dont do it you will never figure out why a bit of code is not working like above.

IMPORTANT targetkind is not the same as findkind
targetkind <> findkind <> curskind <> contkind

findkind results are
-1    No objects found.
0    Object is in a container.
1    Object is on the ground.

Targetkind
1    Object
2    Ground,Mountains,Caves
3    Resource: Tree,Water
Title: Re: Event Macro 22 0 Issues
Post by: NObama on April 25, 2011, 06:54:12 PM
My goodness, EN.  That is a very handy little table.  Sheds new light on all SORTS of issues I've had over the years...
Title: Re: Event Macro 22 0 Issues
Post by: Endless Night on April 25, 2011, 08:11:55 PM
My goodness, EN.  That is a very handy little table.  Sheds new light on all SORTS of issues I've had over the years...

LOL its blatently ripped from the EUO wiki over at easyuo.  I probably read every page of that wiki when i was working on my EUO to OpenEUO translator.
Title: Re: Event Macro 22 0 Issues
Post by: Paulonius on April 26, 2011, 06:57:34 AM
Yeah, that was an interesting lesson for me.  All of the scripting I have done in the past has been item based crafting stuff, so I have never used kind and gotten away with it.  Threw me for a loop yesterday.
Title: Re: Event Macro 22 0 Issues
Post by: UOMaddog on April 26, 2011, 08:55:07 AM
98% of the time, it's not an issue if you're doing a repetitive script, however that 2% will drive you nuts! I went back through all my scripts and set #ltargetkind everywhere I used em22. A nice little Find/Replace works great to make sure you have it every time!
Title: Re: Event Macro 22 0 Issues
Post by: Paulonius on April 26, 2011, 09:02:33 AM
No kidding, its definitely a best practices to use it.  Was knocking my head on my desk for a bit there.

Thanks for the help guys!
Title: Re: Event Macro 22 0 Issues
Post by: Endless Night on April 26, 2011, 11:50:39 AM
No kidding, its definitely a best practices to use it.  Was knocking my head on my desk for a bit there.

Thanks for the help guys!

Welcome to the club.. we all must have done that at least once... ... i encountered it the first time in my mining script... when i added autocrafting of tools...