ScriptUO
Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: Coragin on January 25, 2010, 01:57:18 AM
-
Okay, this is something I want to learn as there are a lot of things in imbuing and other areas where you want to click the same button twice or more to get to your desired result. I knew how to do this with MQ2, but I will be damned I forgot, but I will give it a stab in the dark and see what you all have to say.
if %setimbue 15
{
set %clicktimes 2
gosub DoTheClick
}
Sub DoTheClick
repeat
for %i 0
click %x %y
set %i +1
until %i = %clicktimes
Return
-
I have been using a REPEAT UNTIL loop with a counter.
-
I guess what i did about the same thing, just more complicated huh?
-
Okay, this is something I want to learn as there are a lot of things in imbuing and other areas where you want to click the same button twice or more to get to your desired result. I knew how to do this with MQ2, but I will be damned I forgot, but I will give it a stab in the dark and see what you all have to say.
if %setimbue 15
{
set %clicktimes 2
gosub DoTheClick
}
Sub DoTheClick
repeat
for %i 0
click %x %y
set %i +1
until %i = %clicktimes
Return
Well you're syntax is a little off there with your for loop. This isn't the way I would code that particular logic but, if I did, I would do it like this:
if %setimbue 15
{
set %clicktimes 2
gosub DoTheClick
}
Sub DoTheClick
for %i 1 %clicks
click %x %y
Return
Personally I would do something like:
if %setimbue 15
{
set %clickx = xxx ;whatever the coordinate is
set %clicky = xxx ;whatever the coordinate is
gosub DoTheClick %clickx %clicky
gosub DoTheClick %clickx %clicky
}
Sub DoTheClick
set %ClickmeX %1
set %ClickmeY %2
click %ClickmeX %ClickmeY
;insert some kind of gump waiting logic or gosub here
Return
X
-
corrected your sysntax (if x = y ) and removed redundant lines (for %x Start End )
if %setimbue = 15
{
set %clicktimes 2
gosub DoTheClick
}
Sub DoTheClick
for %i 0 %Clicktimes
click %x %y
Return
You might also want to look at the click command parameters
click %x %y X , %ClickTimes
-
EN and 12X, you guys are my heros for teaching me, you give such great examples, thank you. Now maybe you can help me with what Im working on in special projects. I will just post my questions here, since its all how to stuff...
Please give me some great examples....
1. How do I close a single gump with no exit button? Paul tried to help me with this, but its not working. Im doing something wrong.
Next question I know is redundant because I have asked about this like a zillion times, Im having a hard time remembering, small quote from the thread here...
Clicks...
I got it setup like this...
set %plantwaterx #contposx + 220
set %plantwatery #contposy + 75
With the click in the sub looking like this...(clicking a gump)
click %plantwaterx %plantwatery
gosub waitfortarget
Is this correct? Because sometimes its clicking sometimes it isint.
Final question dealing with targeting an item, which I think I am doing something wrong...
finditem %water C_ , %potionsecure
set #ltargetid %water
event macro 22 0
Now its not doing it for some reason. For all potions and water I got the same thing, so if I can figure this out, I think I can get the script running, to test further.
Heres is what the whole sub looks like...
set %plantwaterx #contposx + 220
set %plantwatery #contposy + 75
Sub CheckWater
savePix %waterckx %watercky 1
wait 10
if ( #pixcol > %yellow1 )
{
if ( #pixcol < %yellow2 )
{
waterloop1:
gosub CheckWaterContainer
click %plantwaterx %plantwatery
gosub waitfortarget
if ! #result
goto waterloop1
finditem %water C_ , %potionsecure
set #ltargetid %water
event macro 22 0
wait 15
gosub waitforgump %plantwindow1
}
}
if ( #pixcol > %red1 )
{
if ( #pixcol < %red2 )
{
waterloop2:
gosub CheckWaterContainer
click %plantwaterx %plantwatery
gosub waitfortarget
if ! #result
goto waterloop2
finditem %water C_ , %potionsecure
set #ltargetid %water
event macro 22 0
wait 15
gosub waitforgump %plantwindow1
gosub CheckWaterContainer
click %plantwaterx %plantwatery
gosub waitfortarget
if ! #result
goto waterloop2
finditem %water C_ , %potionsecure
set #ltargetid %water
event macro 22 0
wait 15
gosub waitforgump %plantwindow1
}
}
Return
Ok, yes got one more, so I dont need to post again...
This is setting up potions, poison, heal ect, for the subs similar to the above...does it look correct?
Sub SetPotions
display OK Click on your workchest
{
set #targcurs 1
while #targcurs = 1
wait 1
set %potionsecure #ltargetid
set #lobjectID #ltargetID
event macro 17 0
wait 20
set #menubutton N/A
}
Display OK Click on your POISON Potions
{
set #targcurs 1
while #targcurs = 1
wait 1
set %poisonpotions #ltargetid
wait 10
}
Display OK Click on your CURE Potions
{
set #targcurs 1
while #targcurs = 1
wait 1
set %curepotions #ltargetid
wait 10
}
Display OK Click on your HEAL Potions
{
set #targcurs 1
while #targcurs = 1
wait 1
set %healpotions #ltargetid
wait 10
}
Display OK Click on your STRENGTH Potions
{
set #targcurs 1
while #targcurs = 1
wait 1
set %strengthpotions #ltargetid
wait 10
}
Return
Is that setting my potions properly? OR should I just use finditem id/type and look at the property or color and cut that sub completely?
How do I reset all variables when the script starts? Sometimes when I was trying to fix this, I would stop the script and restart it with new code to fix something and it would go straight to tending plants instead of going through menu and setup.
-
1. How do I close a single gump with no exit button? Paul tried to help me with this, but its not working. Im doing something wrong.
Right click it - rember scripting emulates user action.. you close it the same way you manually would close it ... Click x y R
Next question ...Is this correct? Because sometimes its clicking sometimes it isint.
Yes the way you done it is correct. But rember the script emulates what you yourself do.. their for if you did some action to load the gump prior to clicking it .. you yourself dont click until you can actually see the gump.. sometimes the gump loads slower than other times due to lag... thier for if your script does use tool click... the gump might not be present when you click so you carnt click it.
you must use tool.. waitforgump... click..
Final question dealing with targeting an item, which I think I am doing something wrong...Now its not doing it for some reason. For all potions and water I got the same thing, so if I can figure this out, I think I can get the script running, to test further.
Rember the results from a finditem command are held in the #findid #findcol #findblablabla variables not in %water
This is setting up potions, poison, heal ect, for the subs similar to the above...does it look correct? Is that setting my potions properly? OR should I just use finditem id/type and look at the property or color and cut that sub completely?
That looks fine.. a pain in the backside to click on the potions each time but it will work... for easier setup an auto find sub would be nicer but either work.
How do I reset all variables when the script starts? Sometimes when I was trying to fix this, I would stop the script and restart it with new code to fix something and it would go straight to tending plants instead of going through menu and setup.
Impossible really to say but off the bat .. all vars should be reset on start.
But if you dont think they are write a setup sub that sets all vars to thier starting value.. ie set #menubutton N/a This is good codeing technique anyhow.