ScriptUO
Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: Coragin on November 24, 2009, 02:34:37 AM
-
Got a question about this here. With using waitforgump sub from masses relic machine if it takes too long, to halts the script. I want to make this a better sub, let me show you a small example.
Okay this calls to make an item, as you can see it will pause the script if the gump dont open....
Sub MakeItem
finditem %Tongs C_ , #BackPackid
set #lobjectid #findid
event macro 17
gosub waitforgump %cwin
if ! #result
{
display ok Problems with crafting menu. Dble Click tongs and click play ;<-----------HERE
pause
}
click %makelastx %makelasty
gosub waitforgump %cwin
if ! #result
{
display ok Problems with crafting menu. Dble Click tongs and click play ;<-----------HERE
pause
}
click %exitx %exity
finditem %boom C_ , #BackPackID
{
if #findcnt > 0
set %Madeboom #findid
gosub Smelt
}
Return
Now my idea here is this, can I change it to this....
Sub MakeItem
craftloop: ;<---------CHANGE
finditem %Tongs C_ , #BackPackid
set #lobjectid %CurrentTool ;<---------CHANGE
event macro 17
gosub waitforgump %cwin
if ! #result
{
goto craftloop ;<-----------CHANGE
}
click %makelastx %makelasty
gosub waitforgump %cwin
if ! #result
{
goto craftloop ;<-----------CHANGE
}
click %exitx %exity
finditem %boom C_ , #BackPackID
{
if #findcnt > 0
set %Madeboom #findid
gosub Smelt
}
Return
In essence changing
finditem %Tongs C_ , #BackPackid
set #lobjectid #findid
To
finditem %Tongs C_ , #BackPackid
set #lobjectid %CurrentTool
Instead of it being #findid it being current tool. So if the gump dont come up, it will return and try again.
-
Nevermind I got it myself lol.
-
Hmm... I see a problem. What if %tongs aren't found?
finditem %Tongs C_ , #BackPackid
set #lobjectid %CurrentTool ;<---------CHANGE
event macro 17
You don't have a bailout if %tongs aren't found, you just continue the script regardless.
finditem %Tongs C_ , #backpackID
if #findCnt < 1
gosub MakeTongs
set %CurrentTool #lobjectID ; you have this backwards, you set the first to the second
event macro 17
Then have a sub to make tongs if you didn't find one, it'll return to this spot and continue. Be sure to set the tongs to last object in the creation sub by doing a findID and setting it.
-
Thanks man
-
Of course, it's a pleasure to help someone who is really interested in learning.
You understand the logic there? Almost always you have to consider a bunch of "what ifs" when you script. What if your tool breaks after making something, what if your out of ingots, what if you can pathfind to whatever, what if.... the list goes on. Just handle them one at a time and you'll do fine.
-
I understand what if's to me, that is easy. As I said, many times over EUO is way similar to MQ2 for everquest www.macroquest2.com look at the scrips (called macros there). You will see they are almost identical. I was very adept at making those, learning the skill checks, and different calls on EUO is the hard part. And MQ2 has "plugins" that made it even more powerful, I mean WAY powerful. There was a plugin that let you swing any weapon at any delay you wanted regardless of the delay on the weapon. so a script for that would look like...
Sub Main
:loop
/attack (This is the command to make you swing your weapon)
/delay 1s (if you even wanted a delay, I usually set mine to /delay 1 or /delay 9)
/goto :loop
Return
So no matter if the weapon had a 1s delay or 9s delay it would swing as fast as you put the command in. In my case, depending on the creature 100ms or 900ms sometimes /delay 0 which was the shortest possible. Then you just find the highest dmg weapon and could take down Gods in like 10 seconds.
Anyways, Im rambling lol, but yes I understand the what if's and now understand the brackets too { }. Soon I am going to get into
for %i
ect and other things. I WANT to learn, I WANT to contribute, I WANT to help. Yes a lot of wants there, but they are all good wants. ;)
-
I've started to really like timeouts as fail safes for a lot of stuff. :) It's like a backup for a backup. hehe
-
I've started to really like timeouts as fail safes for a lot of stuff. :) It's like a backup for a backup. hehe
Now your talking .. everything i write these days is wrapped in at least two exit criteria...
-
I've started to really like timeouts as fail safes for a lot of stuff. :) It's like a backup for a backup. hehe
Now your talking .. everything i write these days is wrapped in at least two exit criteria...
I also really like repeat/untils... you showed me those. Repeat loops are a lot of fun, makes doing some things really easy. I have a LOT of stuff going on in between some things I do, but I want the timing to be exact. So I set the time right after I do the action, then I have all sorts of things going on, then before I do another action, I make sure that timer is up with a repeat until loop(timer up), and it makes the timing nearly right on. I love that. It accounts for the time the script spent doing other things then makes it wait for whatever is left of the time you wanted to wait. So instead of doing like a wait 40, you set a timer, do some stuff, then do a repeat until(time is up) and it waits whatever is left on the timer if anything to do the next action. Fun stuff. :) It allows you to utilize that wait 40 instead of just pausing the script for 40. (2 seconds) I've ALWAYS hated waits... I want to use that damn time. :)
Edit: One other interesting note about doing waits this way: You can put and EXEVENT SYSMSG or something in there and have it display the time it's waiting after your action, and say its waiting one second every time, you can do more stuff to eat some of that up... :) Lets you really optimize your timings and what you can do in between actions.