ScriptUO
Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started 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:
;==========================================================
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
-
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)
-
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.
-
yeppers... that will cause code not to find targets at times. it will make a script really random in targeting
-
So how do I eliminate it? Should I be assigning #LtargetX, #LtargetY, etc?
-
Uhg, I am at a loss to figure this one out.
-
Seem to have solved it. Finditem was giving me a kind of 0 (zero) for the logs and is subsituted 1 and it worked.
-
What they meant is that you need to manually set your #ltargetkind to 1 before targeting:
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
}
-
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
-
My goodness, EN. That is a very handy little table. Sheds new light on all SORTS of issues I've had over the years...
-
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.
-
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.
-
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!
-
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!
-
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...