ScriptUO
Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: Monoxide on October 03, 2011, 02:50:39 PM
-
Alright, im trying to make a script that recalls to two locations on a rune book. buys from one npc vendor, bucklers and battle axes. (which i have razor buy agent on background to make the buying part easy in my script) then recall back and donate both.
so i do have a plan
Look for runebook
Open runebook
chose first rune
click npc choose buy
recall to spot #2
double click npc
chose bucklers
enter 20
double click npc
chose battle axes
enter 20
repeat
well that being said i got this so far
findItem ZBN EGSD , #backpackID
if if #findKind = -1
halt
set #lobjectID #findID
set #ltargetKind 1
event macro 17 0
wait 5
but its not opening my runebook. i think its finding it because it stays on play.. unlike when i had a different backpack id then it just kept halting. but i thought event macro was to use it?
ill be playing around with it for more time. but also if i do figure this out, and i get it opened.. would i have it look for the rune spot 1 by using coords? or is there an easier way incase rune book opens up somewhere else?
-
sorry, i just relized i post this in the wrong section, and i also realized the first problem. i made the mistake of putting in
if #findKind = -1
halt.
i guess it was messing up because runebooks do not have a counter? hmm anyhow back to getting this going!
-
findItem ZBN EGSD , #backpackID
if if #findKind = -1
halt
set #lobjectID #findID
set #ltargetKind 1
event macro 17 0
wait 5
What is this EGSD here? I'm not familiar with that... I think you should use Finditem ZBN C_ , #backpackid
also, no reason to set #ltargetkind to 1, that's necessary for event macro 22 (last target) sometimes... You also have 2 consecutive "ifs" in there...
What you're trying to do should look sth like this:
findItem ZBN C , #backpackID
if #findKind = -1
halt
set #lobjectID #findID
event macro 17 0
wait 5
-
Okay so i got my script looking like this.. and it may look silly to you guys, but its my first born and actually does something!!! amazing!!
findItem ZBN
set #lobjectID #findID
set #ltargetKind 1
event macro 17 0
wait 5
set #contPosX 10
set #contPosY 10
contpos
wait 5
click 144 80
halt
now so far it gets my rune book, and recalls me to my first location. which is the blacksmith i want. Im trying to read thru tutorials to find something that will help me find the npc, then choose buy. ohhh and looks like im gonna need to add in a check to see if i actually recalled to the spot too.. man now i understand why these can get so long.. im just doing simple stuff!!!
-
Okay so i got my script looking like this.. and it may look silly to you guys, but its my first born and actually does something!!! amazing!!
findItem ZBN
set #lobjectID #findID
set #ltargetKind 1
event macro 17 0
wait 5
set #contPosX 10
set #contPosY 10
contpos
wait 5
click 144 80
halt
now so far it gets my rune book, and recalls me to my first location. which is the blacksmith i want. Im trying to read thru tutorials to find something that will help me find the npc, then choose buy. ohhh and looks like im gonna need to add in a check to see if i actually recalled to the spot too.. man now i understand why these can get so long.. im just doing simple stuff!!!
Actually, a script to recall properly requires some pretty advanced scripting knowledge in my opinion... Don't think it should be your first script... You could always use someone else's recall/travel sub to do this, and focus on writing the rest of the script yourself... I've been using recall/sj in my scripts for some time now, but not until a month ago or so I decided to write my own travel sub...
-
yea i figured is i could get the runebook gump to move to the certain location and i have it click on the blue buttons it should work alright.. i didnt want to get it too complicated because its only 2 rune locations.
-
Yes, recall a good recall sub is key.
As for being able to buy from the npc, look up exevent popup , and then contpos and click.
When I started learning, I'd find scripts that do the same type of thing, or at least has something similar in their code, then learn how they coded it and know what all the code does, then adjust it to your preferences. You could find a script that clicks a blue beetle, or donates, or something of the like.
-
okay i found some info on exeevent popup and i found this, but i dont understand this one line
finditem %vendor G_10 <------ where is the g_10 coming from? should that be an item id #?
if #FINDCNT > 0
exevent Popup #findid 1
halt
-
okay i found some info on exeevent popup and i found this, but i dont understand this one line
finditem %vendor G_10 <------ where is the g_10 coming from? should that be an item id #?
if #FINDCNT > 0
exevent Popup #findid 1
halt
You should really consider reading up on EUO Wiki, when you find stuff you don't understand in a script... You'll find answers to most (all?) of your questions there...
The answer to this one can be found here:
http://wiki.easyuo.com/index.php?title=FindItem
-
Okay that makes sense :P now one last stupid question then i should be good for the night lol. when i recall into the shop the npc is different, has different id# is there another way around this? i tried using %vendor but its not registering.
-
Okay that makes sense :P now one last stupid question then i should be good for the night lol. when i recall into the shop the npc is different, has different id# is there another way around this? i tried using %vendor but its not registering.
You have to search for #findtype, and then it will give you findid...
Let's say the item TYPE for vendors is HS and IS...
You can set up a variable (read up on variables here -> http://wiki.easyuo.com/index.php?title=Variables) with the item types for vendors.
set %vendor HS_IS
Now, when you use "finditem %vendor" it will look for item types HS and IS.
Once one of those "items" are found, the #findid variable will hold the ID of the item that was found...
That's why you're gonna use something like:
finditem %vendor G_10 ;-> will look up HS_IS whithin 10 tiles of your char
exevent popup #findid ;-> assuming a vendor type was found, it's ID will be held in #findid, so you're popping up this particular vendor's gump
Hope this was clear enough...
-
hmm, well i did find anything that helped me get good id types, i dont know if my sever is using dif code? but the ones i keep running into not working. anyhow though i got this much.. now it does what i want it to do, but is a bit glitchy.
findItem ZBN
set #lobjectID #findID
set #ltargetKind 1
event macro 17 0
wait 20
set #contPosX 10
set #contPosY 10
contpos
wait 20
click 144 80
wait 50
msg vendor buy$ <---- got away from needing to find type, but i know in future ill need to know
wait 20
findItem ZBN
set #lobjectID #findID
set #ltargetKind 1
event macro 17 0
wait 20
set #contPosX 10
set #contPosY 10
contpos
wait 20
click 144 95
wait 100
finditem BGKH G_20
if #FINDCNT > 0
click 443 303 d f
click 443 303 d f <---- this double click gets glitchy why i put it in 3 times but still rough.
click 443 303 d f
wait 20
set #contPosX 10
set #contPosY 10
contpos
wait 20
click 316 352
wait 5
click 316 352
wait 5
click 48 180
wait 5
msg 20$
wait 5
set #contPosX 10
set #contPosY 10
contpos
wait 20
wait 5
click 316 352
wait 5
click 316 352
wait 5
click 50 250
wait 5
msg 20$
loop
its my rough copy, i guess i gotta add in checks to make sure things happened right.. and put in a save pauser so it doesnt get messed up in world saves.
-
congrats on the first script... glitches and all. :)
-
thank you, and i feel like such an idiot!!! my double clicking glitch was such a stupid glitch, all i had to do was after the findid was to set ltarget = findid then event 17 0..
-
thank you, and i feel like such an idiot!!! my double clicking glitch was such a stupid glitch, all i had to do was after the findid was to set ltarget = findid then event 17 0..
No no no don't say that.....your farther along than I am...what does that make me? And I've been lurking around these boards for far too long. ???
I've looked at those wiki tutorials and I'm not a huge fan of them. Wiki could go much more in depth and give more examples...better examples!
Cerveza has written some good tutorials that explain step by step what the hell is going on with the code. Wiki...I'm sorry I'm not a fan and I wish there was an alternate resource besides that one.
Sure you guys that are natural coders and programmers it comes easy to ..then there's guys like me that need an explanation of exactly what the hell is happening put into laymens terms. What I'd really like is a book...UO Scripting Basics like one of my current school books where I go and do lessons and answer questions! ;)
Not everyone learns the same way!
Granted I need more patience and should take ALOT more time learning the coding but my interest hasn't been there. Some of you guys...coders...love the stuff more than playing the game! Going to school taking computer courses my interest in coding and all stuff pertaining to computers has grown however it doesn't come easy for some of us.
I'll have to post my fish cutting sub for everyone to tear to pieces. I'm so proud I got the FaFer to cut up all the fish! It's not pretty but it works. I pieced it together looking at C2's code. 8)
Anyways nice job Monoxide on your first script! I'm right there with you...well maybe a couple of steps behind. We'll get there.... ;)
-
I agree. Congrats Monoxide... there is A LOT to learn.
Laymens terms FTW! I don't know much, and sure would like to see more examples of code, torn down and interpreted line by line, variable by variable... In english, not computer science. That would be awesome. I spent about 3 hours shredding through google, trying to learn a little more about namespaces. I got almost nowhere, I am sure if it were explained in english, I could figure it out eventually, with a little help from the natives... But I got lost on a programming site that was trying to teach me java script, and C++ and some other stuff that wont help me sleep tonight.
:-\
-
Chaka, you can do it!
I would say you should check some Subs on this Board or Easyuo.com.
They have some good Subroutines for Recall\Buy\Sell then u only need to know how to use:)
-
Yea im a mechanic so im right there with you, this stuff can go over my head fast! What i learned help me thru this script is what i learned in one of the tutorials is think of what you want and to write it down. simple steps.. then put in what u want checked for that one step. Also if i got stuck one trying to figure out codes, i either bothered these guys lmao. or i read into some scripts that did what i wanted to do and play around.
i been writing the script from top to bottom, and testing every few lines by putting halt at the end and seeing if it did what i wanted, i also put all my wait times up high for testing so if it did mess up i can push pause and see where im at. You can always speed up your script at then end. this one here does it super fast for me. but it's also set up to my comp connection. so if u did want to use it play around with the times by adding if too fast. def cant be to slow.. lmao
; Created by Monoxide
; Date 10/4/2011
; Created to Help getting Mace and Shield Glasses
;
; <<< THIS ONLY WORKS FOR SERVERS THAT HAVE INSTANT SPAWN NPCS FOR FAST BUYING. IF YOU ARE LOOKING FOR SOMETHING THAT SITS >>>
; <<< THERE TO STOCKUP THE PILE GO SOMEWHERE ELSE!!! >>>
;
;
;
;
;
; Setup
; You will need 1 runebook, no more no less or things will get funny.
; 1st rune the npc vendor selling Bucklers And War Axes within a tile, unless your server allows vendor buy further.
; 2nd rune to the library donation npc (close enough to reach out and touch him)
; 3rd rune the bank somewhere you know u have access to banker and withdrawl money
; You will need razor buying agent enabled, and set to bucklers and war axes, or whatever you want. i believe it will skip over it.. not really sure guess u find out
event macro 8 2
Start
if #gold < 1100
gosub gotta_get_gold
findItem ZBN
set #lobjectID #findID
set #ltargetKind 1
event macro 17 0
wait 5
set #contPosX 10
set #contPosY 10
contpos
wait 5
click 144 80
wait 20
findItem ZBN
set #lobjectID #findID
set #ltargetKind 1
event macro 17 0
wait 20
set #contPosX 10
set #contPosY 10
contpos
wait 10
msg vendor buy$
wait 20
click 144 95
wait 50
finditem BGKH G_20
if #FINDCNT > 0
set #lobjectID #findID
event macro 17 0
wait 10
set #contPosX 10
set #contPosY 10
contpos
wait 10
click 316 352
wait 5
click 316 352
wait 5
click 48 180
wait 10
msg 20$
wait 5
set #contPosX 10
set #contPosY 10
contpos
wait 10
wait 5
click 316 352
wait 5
click 316 352
wait 5
click 50 250
wait 10
msg 20$
wait 20
loop
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
sub gotta_get_gold
findItem ZBN
set #lobjectID #findID
set #ltargetKind 1
event macro 17 0
wait 20
set #contPosX 10
set #contPosY 10
contpos
wait 20
click 142 110
wait 50
msg withdrawl 5000$
wait 50
msg withdrawl 5000$
wait 50
return
-
I will later show you an example how i structure my scripts;). I will take your Script. You working a lot of with clicks, then u should not set the gump to an contpos, set the click to the gump;)But you learning processs seems be good:)
Crome
-
findItem ZBN
set #lobjectID #findID
set #ltargetKind 1 ; < --- you are not really using any targeting in the script, why are you using this?
event macro 17 0
wait 5
Well your main problem is you dont check where to look for the item, and if you have found the item or not. And you are missing brackets in which case even if you havent found the item, the following lines will be executed - and that's wrong. But if you are having brackets and the statement is true( the way you want it ) it will execute only the code within the brackets. So this little code should look something like this.
finditem ZBN C_ , #backpackid ; looking for zbn in your main backpack.
if #findcnt > 0 ; if found more than 0
{ ; open statement found more than 0
set #lobjectID #findID ; set last objectid from #findid
event macro 17 0 ; use last object
wait 5 ; wait 0,25s
} ; close statement found more than 0
else ; if nothing found
{ ; open statement else
display did not find ZBN ; displays [ok] messagebox with text "did not find ZBN"
stop ; stops the script
} ; close statement else
set #contPosX 10
set #contPosY 10
contpos
wait 5
you could just use
contpos 10 10
msg vendor buy$
To prevent errors(as this "msg" is direct key pressing - and you may have some writen stuff allready -, so I would suggest to use the method bellow, which is just a direct messaging trough event
event macro 1 1 vendor buy
Then you have a looping error. The line 27 says "Start", and the line 100 says "loop".
But it should be
Start:
.....................
goto Start
I would recomend you using ScriptUO software, that has syntax error checker inside. It would help you prevent many problems you may encounter. Hope this will help and you will understand what I have writen here down.Anyway, keep on working, it's a good start.
-
Do not know if this will help but think of namespaces as boxes.
-Imagine you are standing in a huge box that contains all the Variables you can see %myVar %MyVar2 etc.
- Now imagine that you surrounded by Loads of smaller boxes that have no name and are closed but could hold variables !myvar, !myvar2.
- You also notice that one of the small boxes is open and its called Standard namespace. Its currently empty but could hold variables !myvars (! not %) You decide to set one (set !MyTest standardbox)
-So you grab one of the other small boxs and say i'm gona have a look inside this box, but i don't want it contents to conflict with my existing ! variables
-So you take the open (standard) small box, close it and push it to the side on a stack of empty boxes (namespace push).
-After stacking your closed box you pickup one of the other small boxes and say thats it i'm gona name this box and open it (namespace local myboxname)
-After opening it you see their is nothing inside so you decide to put something inside (set !MyTest testBox)
- Now happy after such achievements you pine for your original small box and think it would be so be great to close this box and pop the last one back open... (namespace Pop)
- you check you var and low and behold !mytest = standardbox
in code
set !myTest standardbox
display ok TestVar: !mytest
namespace push
namespace local TestBox
set !myTest TestBox
display ok TestVar: !mytest (Im using a different namespace)
namespace pop
display ok TestVar: !mytest (Back to my original namespace)
display ok SElect Tools from EUO MEnu, do a var dump $ note you have a serveral !Mytest vars $ one Std (default box) and one from the defined box
halt
After running code to a var dump, tools menu option var dump, scroll all the way to the botton you will see you have 2 MYTest Vars, One in Standard namespace one in TestBox namespace.
!L~STD~MYTEST: Defaultbox
!L~TESTBOX~MYTEST: TestBox
Hope this box analogy helps to explain this mystery.
Going to add this into turorials... maybe it will help others.
Also moved this topic to correct section Script debug