ScriptUO
Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: Paulonius on November 24, 2009, 08:03:29 AM
-
I am working on a general purpose imbue sub that throws a lot of stuff around. It picks up resources, makes stuff, then puts those resources away, gets out imbue resources, imbues stuff, etc... I had a simple version working pretty well, but as it has gotten more complicated with various failsafe's and checks, it started creating ghost items and hanging. I am playing with adding in waits and reopening containers, but I wonder if someone has some insight into why ghost items happen so that there might be some logic behind my tinkering.
-
If you can determine where the items are being ghosted, do a drop there. You can open your backpack to eliminate it, but it might come back in your pack.
Maybe a combination of dropc and open pack would be best.
-
Here is where the primary ghost/hangup is showing up atm:
CheckExceptional:
If %ExceptionalRequired = Y
{
Finditem %CurrentItemType C_ , #backpackid
event property #findid
If exceptional in #property
{
Set %CurrentItemID #Findid
Gosub OffSetClick 30 450 ; Closes Craft Gump
Wait 10
Gosub UnloadResources
Return
}
Wait 10
Gosub OffSetClick 30 450 ; Closes Craft Gump
Gosub Dispose #findid
Goto MakeLastCraftLoop
When it comes back from the Disposal it goes to a series of commands that hits Make Last.
The Dispose Sub looks like this:
;==========================================================
Sub Dispose
StartDispose:
Set #lobjectID #BackpackID
Event Macro 17
wait 5
Set %DisposeItemID %1
Finditem %DisposeItemID C , #BackPackID
Set %CurrentDisposeType #FindType
If #FindCnt < 1
Return
If %CurrentDisposeType in %TrashList
{
Set #lobjectID %TrashBarrel
Event Macro 17
wait 5
exevent drag %DisposeItemID #Findstack
wait 10
exevent dropc %TrashBarrel
wait 20
Return
}
Cut:
If %CurrentDisposeType in %Cutlist
{
FindItem %Scissors C_ , #BackpackID
Set #LobjectID #FindID
Event Macro 17
Gosub waitfortargetCursor
if ! #result
{
Goto StartDispose
}
set #ltargetID %DisposeItemID
event macro 22 0
wait 10
Return
}
Smelt:
If %CurrentDisposeType in %Smeltlist
{
FindItem %Tongs C_ , #BackpackID
Set #LobjectID #FindID
Event Macro 17
gosub waitforgump %cwin
if ! #result
{
Goto StartDispose
}
Gosub OffSetClick 30 350 ; Smelt Item Button
Gosub waitfortargetCursor
if ! #result
{
Goto StartDispose
}
set #ltargetID %DisposeItemID
event macro 22 0
gosub waitforgump %cwin
if ! #result
{
Goto StartDispose
}
Gosub OffSetClick 30 450
wait 5
Return
}
Display The itemtype you are currently making, %CurrentDisposeType , needs to be added to either the CutList, TrashList or the SmeltList
Halt
-
I have seen over about 60 percent of scripts at one point or another cause ghosting. It is all based around when the item is picked up and droped and the timing there with in. If the pickup and drop happen to fast and then you mix in a little lag, Voila you have a ghost item. I can almost reproduce it everytime by starting up a high end virus scan while a script is picking up an item and trying to drop it, boom you now have a ghost item.
-
So my failsafes are redundant checks, slow the process down, and re-open containers?
-
I had thought that a simple item count would work... but we never really had the problem enough to pursue it....
Before dragging and dropping, do an item count of the place your dragging from or to. Then do a repeat drag/drop routine.... maybe one that steps up the delays, until that item count changes....
finditem * C_ , %wherever
set %number_of_items #findCnt
set %timout ( #sCnt + 30 ) ; 30 second timout
repeat
{
exevent drag %DisposeItemID #Findstack
wait %timer1
exevent dropc %TrashBarrel
wait %timer2
set %timer1 ( %timer1 + 1 )
set %timer2 ( %timer2 + 1 )
finditem * C_ , %wherever
}
until #findCNt <> %number_of_items || #sCnt > %timeout
set %timer1 5
set %timer2 20
return
Now you have to be careful cause you dealing with two seperate found items, the one you are actually trying to move, and the ones in the container your counting. If you define yours with a variable, then just use that variable here and let the counter be the last found item.
This was just a concept I'd thought of a long time ago and never really needed. It may work, may not, may be so full of holes it looks like the health care plan... oops.
-
I like it, one more tool in the arsenal. I just finished putting in code to reopen all of the containers in volved with wait 10's after each for every time I am moving something. Slows the script down, but if it makes it stable it will be worth it. If this doesn't work I will look into turning your item count idea into a general purpose move item sb.
-
I like it, one more tool in the arsenal. I just finished putting in code to reopen all of the containers in volved with wait 10's after each for every time I am moving something. Slows the script down, but if it makes it stable it will be worth it. If this doesn't work I will look into turning your item count idea into a general purpose move item sb.
Yea who cares how fast a crafting script is really? I never craft unless I'm doing nothing in UO anyways... :) Speed is great but stability is WAY better.
-
I've never used this... completely untested and recently (30 mins ago) written. It's just an idea I thought of a long time ago with a Lumberjack program that had a ghosting issue.
The logic seems sound. You drag and drop until the item is actually in the container. If the delays are causing it not to drop, add to the delays.
Lemme know if you test it at all, I'd be interested.
-
I dont believe the item counting will help any. After the item is ghosted it is consider under the cursor and in your backpack at the same time. You can not remove it from your backpack because it thinks it is under your cursor. Also at the client level it sees it in your backpack and will count it also. I hope this made sense if not I will try to explain it differently.
-
I always thought it was on your cursor, and you had to drop it to get it off. If thats the case then it's easier to do by using #lliftedID or whatever the command is to tell if you have something on your cursor.
If it's in both places, then check the cursor, if it's only on your cursor, then check the item count. One of those methods should work.
-
Had not thought about checking your cursor command to see if its there. I am going to do that today to find out that maybe a new mini snippet for all script to place in then as a lag/ghosting fix.
-
That would be very cool Mass. Let me know what you find. In the short term, I added code to re-open the containers involved every time I am moving anything in this script with a wait 10 after the bag is opened. Seems to have eliminated my issue for now.