ScriptUO
Ultima Online Fan Board => UO-Related Tutorials => Topic started by: cybercasper on December 13, 2015, 02:02:10 PM
-
I have been looking and looking trying to read as much as possible but I am still either dumb or blind. I saw that someone was willing to help people start learning to script with a small script where you pick a chest or crate in ur house and drag and item like a sword to the chest. would anyone be willing to spare sometime and let me try and get this to work and maybe help me along in my scripting career. I would really like to contribute something even if it is just some knowledge of what I learn on the way if I never become really good at it.
-
This is what I got so far
finditem WW ; the weapon type
if #FINDCNT > 0
{
Exevent Drag #findID ; finding the weapon and picking it up
wait 10
Exevent Dropc #CONTID PEDWYND ; dropping it into the container of choice
wait 10
halt
}
-
This is quick and basic and I cannot check it but it should give you an idea to get you going
set %weapon WW
set %secure PEDWYND
finditem %weapon C_ , #backpackid
if #FINDCNT > 0
for #findindex 1 #findcnt
{
exevent drag #findid
exevent drop %secure
}
return
-
Ok cool just trying to learn and that is what he was offering kind of teaching I got it to work the way I did but ur way looks so much easier and nicer than mine
-
just tried yours out something weird is going on with it the weapon disappears until I log out an back in
-
and could u point to another easy script to try so I can see if I can figure it out. it would be much appreciated
-
Try this one http://www.scriptuo.com/index.php?topic=10657.0
-
ok will do ill start on it tomorrow when I get off work and I will post and see if u can help me if you don't mind
-
ok so I started looking in there and the code I have to start with is this
finditem * C_ , #BACKPACKID
if #FINDCNT > 0
{
display ok There are #FINDCNT items in your backpack!
}
if #FINDCNT < 1
{
display ok No items were found in your backpack!
}
halt
it is telling me what how many items I have in my bag now from there I need to figure out what command will drag and drop which I have that already with exevent drag command and exevent dropc command but where do I put those and am I going to have to write a gosub and if so how do I do that is it like this
gosub remove items
sub remove it
Exevent drag #findID
wait 5s
Exevent dropc #CONTID
wait 5s
-
I would recommend a sub for your item movement.
Through the teachings of many around here over the years I've found that breaking your scripts up into small pieces makes them more efficient and a lot easier to debug when you run into a little hangup. Not to mention you then have a sub library (Thx EN) that you can reference on your next project. No need to write something multiple times if you can do it just once.
You might play around with something along these lines:
repeat
finditem LOL C_ , #BACKPACKID
if #FINDCNT > 0
gosub MoveIt
until #FINDCNT < 1
halt
sub MoveIt
;; Your drag and drop commands go in here.
return ;; < Always remember to return out of your subs.
Use F7 to step through your scripts one line at a time so you can see how it works.
-
so this is what I got so far I get it to open my paperdoll then open my back pack and it will even attempt to take something out of my bag but then puts it right back in there so it never does the exevent dropc part. so do I have to manually set and #contid for it or is there a way to set it up with out that where it will find it. and or can I set up another event macro for that. and then it keeps trying to drag same item so does the have to be something else besides #findid #findstack
event macro 8 1
wait 5s
event macro 8 7
wait 5s
FINDITEM * C_ , #backpackID
if #FINDCNT > 0
gosub MoveIt
until #FINDCNT < 1
halt
sub MoveIt
exevent drag #findid #findstack
wait 10
exevent dropc #contid
wait 10
repeat
now I could have a
set %secure XXXXX setup for my exevent dropc but do I need that
-
The #findStack system variable contains the number of stacked items in the object returned by findItem. You won't want to use it for a weapon, it is used for stacked items like ingots, ore, bandgaes, regs, etc.
set %secure XXXXXX tells the script which container to put the item in. In yours, you are not identifying what container to drop it in.
The EUO Wiki will really help you learn some of the different commands. http://wiki.easyuo.com/index.php?title=Documentation
I would also look at the tutorials on EUO http://www.easyuo.com/forum/viewforum.php?f=9 and here on SUO. http://www.scriptuo.com/index.php?board=17.0
-
I think Crisis hit this one right on the head. Check the EUO resources and I think you will get it figured out.
Setting your container somewhere in there is generally if not always a good idea for easy reference.
Sounds like you're trying to do a fairly simple, get something + move it here = make money kinda script.
The examples provided in the thread here should be more than enough to easily get it figured out. I'm sure you can do it.
-
ok I got everything to finally work and what is the reason I use * after finditem I could find out why except for it is a semicolon. and would there be any other way to write it besides how I did. I know MeWonUo said always return out of sub but on this I put repeat should I have done something else.
set %chest CUABDSD ;This would be set to XXXXXXX so anyone could set there own container
event macro 8 1 ; take this out if u don't want to open paperdoll each time
wait 5s ; could change wait to 20
event macro 8 7 ;opens backpack
wait 5s ;change to wait 20
FINDITEM * C_ , #backpackID
if #FINDCNT > 0
gosub MoveIt
until #FINDCNT < 1
{
display ok No items were found in your backpack!
}
halt
sub MoveIt
exevent drag #findID #findstack
wait 10
exevent dropc %chest
wait 10
repeat
-
and please can someone give me something else I can try so I can keep progressing maybe something that I could start like a step by step one so I can do one and then build on it
-
You need to start with tutorials and the wiki that I linked earlier. That is the best way to learn.
-
I have been trying too sir it is just hard when a lot of the tutorials are written prior to easyuo 1.5 so a lot of commands have been changed/ or don't need anymore at least from what I read in wikiand I have wiki up when I try and script but even with that being said I can follow along with the ones on scriptuo but being someone that needs to beable to figure it out on his own if not I want to copy and paste it is hard. I do thank you for helping me though I really do appreciate it
-
Did you go here to the tutorials? http://www.scriptuo.com/index.php?board=17.0
Cerveza walks you through making a script, finding things in your pack, checking health status, etc. If you follow along and create the same things as he does it will teach you a lot. I am not a programmer at all, I just started following scripts, reading through subs trying to understand their logic, and then trying to modify scripts to fit my needs. It isn't easy but isn't as hard as it it sometimes feels when you hit a wall.
The big thing to remember is that no one can really choose scripts to help you other than tutorials. Find a script that you like, follow the subs and how it calls for them and what they do. You will start to get a feel for it. Use scripts that you like and that you use quite often, especially smaller scripts. Look through all of the subs that people have posted for others to use. I believe that EN has a ton posted. ;D
-
ok thank you I understand that I have to come up with the idea hehe and I will for sure check out cerceza's tutorials. but I cant do the easyuo ones they are outdated it seems like everyone left there and came here. but thank you for all the help mad respect for helping. I know I will still have many questions after this do u mind if I post some more question in here.
-
Not at all, ask away! 8)
-
so ok question when I am reading cerveza's third tutorial I see he starts to include {} in his scripts but never really explains why he put them in. I know it is used for a statement but how and when will I know where to put them.
-
I don't have a great way to explain it and I am sure others can do a better job but I will give it a shot
if C in #charStatus
{
findItem NUF C_ , #backpackID
if #findKind = -1
halt
set #lobjectID #findID
set #ltargetKind 1
event macro 17 0
wait 5
}
First you always need to close, very important. Second it goes with the statement if C in #charStatus is true then the script will do what is within those then go to the next, if it is false then it will go on. it is hard for me to explain when to use them but after altering some scripts and working on your own, you will get a better feel for it.
-
ok I am done with tutorial 3 and it seems like it is coming together a little bit at a time. still kind of confusing but I have been reading up on everything I can I might tweek that tutorial and try to see if I can figure out how to drop a weapon if I have one in my hand
-
So I have a question I know the event macro 8 2 will open the status but what do I have to write inorder to moniter that so I can drink a pot like refresh or agility when needed since I don't believe there is a timer for those except for how long they last.
-
ok finished the 5 tutorial and it said the homework was to put in a total refresh pot. so I did and I put 5 of them in my bag and it drank all 5 should I put a wait on them or is there another way