Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Dirty Bob

Pages: [1]
1
Alright, some coding help would be much appreciated.  So grabbed a spider, however, i have tried editing the part about the horse and changed it to "wolfspider" however i get the error message that i need a mount.

my code looks something like this...
return
SUB FindWolfSpider
finditem %mount G_3
set %animal #findid
if #findcnt < 1

something tells me "G_3" is the problem, how do i get the code/ know the code for the wolfspider, i think that is still the horse code.
 

The %mount is most likely the horse ID. But that is a variable being declared somewhere else. It would look like "set %mount XXXXXX", the Xs being letters or numbers. You would need to change the XXXXXX to whatever the ID of the spider is. The G_3 is telling the script to only look for the item within 3 ground tiles of your character. Your easiest way to find the ID of your spider would be to target it using anything then look in the system variables in EUO to find #LTARGETID. That will be the ID of the last thing you targeted. I also added code to the end of the post to help you get the type and ID.


Also i tried to swap out the club code with a dagger code.

finditem %weapon D_ , #charid

the Club code just had a C before the underscore, i swapped it to a D, with that work?? Thanks in advance

The %weapon is what you need to change. But like above, it is being declared or set somewhere else. The C_ , #charid is telling the script what container to look in. D_ isn't an argument for finditem.

Check out the documentation on FindItem and Variables. A lot of scripts just need you to edit variables and if you understand them a bit better you can get a lot of scripts to work for you.

Below is the part of the script you need to change. You should first start with a fresh unedited version of the original script. If you read the comments he left below in his code it says not to edit below the line. Most scripts are only going to have you edit variable values at the very beginning. You'll want to change set %weapon and set %mount. The %mount is going to be your spider ID. Don't change the name, just leave it as %mount to keep things easy. So use something like animal lore to target your spider than look up it's ID under #LTARGETID in the EUO variables. Do the same thing again for your weapon, targeting it with something to get #LTARGETID. The ID will be six digits. The script only has 3 digit items because he's looking for items by type but it's ok to replace it with your 6 digit ID for the sake of being easy. If your weapon breaks or something you will have to change the ID manually. You could also double click your weapon and see what the item type is bye looking under #LOBJECTTYPE and using it instead. Then you wouldn't have to worry about the weapon breaking since it'll just grab the next one.

Code: easyuo
  1. ; SET UP
  2. ;===========================================================================================
  3. chooseskill bush Bushido
  4. set %weapon YSF_QOH_ ; ID's the types of weapons - Mace, Club ---- Modify this to whatever weapon type
  5. ;                                                      you'll be using to train with
  6. set %mount SF_OF_; ID's the types of mounts/animals - White Horse, Brown Horse ---- Modify this to whatever animal
  7. ;                                                    type you'll be using to train with
  8. set %start #skill
  9. set %attempts 0
  10. set %gains 0
  11. set %starttime #scnt
  12. ;============================================================================================
  13. ;DO NOT EDIT BELOW THIS LINE
  14. ;============================================================================================


Here's a couple easy pieces of code to run to get the ID or Type of an target. Just run each as their own script to get what you want and it'll pop up with a display with the information.

Code: easyuo
  1. ;Finds the Type of an object
  2. ;When you press play a target will appear and you have 10 seconds to dlick an object
  3.  
  4. set #TARGCURS 1
  5. wait 10s
  6.  
  7. finditem #LTARGETID
  8. wait 5
  9. display ok #FINDTYPE $
  10. halt

Code: easyuo
  1. ;Finds the ID of an object
  2. ;When you press play a target will appear and you have 10 seconds to dlick an object
  3.  
  4. set #TARGCURS 1
  5. wait 10s
  6.  
  7. display ok #LTARGETID $
  8. halt



2
Scripting Chat / Re: What is the proper way to handle this
« on: May 18, 2020, 08:51:09 AM »
I guess scope was exactly what I was asking about. That's a lot of information that I have a ton of questions about after going through the documentation just now. I'm sure I'll be asking some more, but I'll go mess with some test scripts to see how many I can answer myself.   

For your first examples, when the code is in ThirdSub and calls FourthSub, now returns to ThirdSub... both %1 and %2 are the same thing. Yikes! So I would avoid that kind of construct, because eventually you will write something complex enough that it will betray you.

That was precisely what led me to pondering all of this in the first place. It was a simplified example of something I was doing in a script and it just seemed not right. I also thought about just always passing those first two arguments even when not needed to make it "standard" and that seemed ridiculous. I was trying to solve a problem with arguments that is clearly better to solve in other ways. I just want to learn good practices as I feel it'd help me in the future with any language.

I appreciate all of the help from you guys.

3
Scripting Chat / Re: What is the proper way to handle this
« on: May 17, 2020, 12:29:59 PM »
I don't think I asked the question very well, but I had been wondering about your [set %1 4] example. I had stayed away from doing that because I figured it might be an issue. I also just learned from your post there are EUO code boxes  on here, nice.

I guess what I'm asking more about is what is considered the better coding practice. I know the below code works, but is it good practice to do it this way or actually set the variable? The second way clearly takes more steps and the first way seems the best route to take, but it's all very simple and short.

Code: easyuo
  1. gosub ScanForWorldSave %2
  2. ; ####### Compared to #######
  3. set %someVariable %2
  4. gosub ScanForWorldSave %someVariable
  5.  

But what about when you take that same argument through multiple subs. In this example below I'm needing to access #JINDEX that was passed when the first sub was called but I don't need to access it until it made its way through four other subs on the way. Is passing the argument over and over until you reach the point you need it a good practice like in the first way I did it below? Or is it better to just declare a variable to use when you need it later down the line like in the second way I did it below.
Code: easyuo
  1. gosub firstSub #TIME #JINDEX
  2.  
  3. sub firstSub
  4. gosub secondSub %1 %2
  5. return
  6.  
  7. sub secondSub
  8. gosub thirdSub %1 %2
  9. return
  10.  
  11. sub thirdSub
  12. gosub fourthSub %1 %2
  13. return
  14.  
  15. sub fourthSub
  16. gosub fifthSub %2
  17. return
  18.  
  19. sub fifthSub
  20. journalScan %1
  21. return
  22.  
  23. ; ####### Compared to #######
  24.  
  25. gosub firstSub #TIME #JINDEX
  26.  
  27. sub firstSub
  28. set %neededJINDEX %2
  29. gosub secondSub
  30. return
  31.  
  32. sub secondSub
  33. gosub thirdSub
  34. return
  35.  
  36. sub thirdSub
  37. gosub fourthSub
  38. return
  39.  
  40. sub fourthSub
  41. gosub fifthSub
  42. return
  43.  
  44. sub fifthSub
  45. journalScan %neededJINDEX
  46. return
  47.  
  48.  


4
Scripting Chat / What is the proper way to handle this
« on: May 17, 2020, 10:17:45 AM »
So I just recently started sending parameters through gosub and I'm trying to figure out what is considered the correct way or proper way to handle those parameters through multiple subs. Is it proper to send a parameter to a new sub using a parameter from the current sub you're in like:

Code: [Select]
gosub TimeAndSaveCheck #TIME %2
:or
gosub ScanForWorldSave %2

I feel like I even forget at times what variables I'm trying to call on when I get a few subs deep. At the same time it's localized and reusable with variation and easy to trace back if you need to. This is a larger example of what I'm doing in one script using some pseudo code

Code: [Select]
set %mainLoop TRUE
repeat
{
      gosub Step1 #TIME #JINDEX
      gosub Step2 #TIME #JINDEX
      gosub Step3 #TIME #JINDEX
}
until %mainLoop = FALSE

sub Step1
Do Work
gosub TimeAndSaveCheck %1 %2
return

sub Step2
Do Work
gosub TimeAndSaveCheck %1 %2
return

sub Step3
Do Work
gosub TimeAndSaveCheck #TIME %2
Do More Work
gosub ScanForWorldSave %2
return

sub TimeAndSaveCheck
if %1 > #TIME - 60
   return TRUE
gosub ScanForWorldSave %2
return FALSE

sub ScanForWorldSave
for %i %1 #JINDEX
{
    scanjournal %i
    if The_world_is_saving in #JOURNAL || The_world_will_save in #JOURNAL
    {
       wait 30s
       break
    }
}
return



5
New member introductions / An Introduction
« on: May 16, 2020, 09:21:49 PM »
Hello everyone. I've been playing UO on and off since '98. I can still remember making my way to the Brit cemetery on my first day to quickly die then make a new character thinking that was that. When I died a second time I figured I was missing something because I was running out of slots. Luckily I learned a bit more about UO over the years. I switched over to mostly free shards after about a year.

I started scripting with UO Auto Pilot. At some point, I think looking for an auto looter, I stumbled upon EUO. I had no idea how to use it at all. After quite awhile I was able to figure out what a variable was and that was what I needed to change to tweak the scripts for free shards. It was definitely my first introduction to programming. I had no idea how anything actually worked though. Over the years I would learn more about the workings of EUO. I started adding my own subs to scripts. Then eventually I would mangle together parts of scripts to make some pretty workable automated scripts. I started playing browser incremental games and started using JS to write some scripts to automate those. I started to realize I got more enjoyment out of the problem solving involved with scripting than playing the game. I would jump back and forth between UO and browser games spending a couple months a year scripting before I'd hit a wall and I just couldn't expand my abilities. I'd generally come back in a year or so and could progress a little further but never truly get it. 

Having some extra time recently I felt the scripting bug again. It's probably been a good 5 or 6 years since I played UO so I figured I was going to finally make myself a fully automated mining script from scratch. This time around it has all kind of clicked. I started out easy and started with a simple base that I could continue to expand on. After two weeks I can say it's pretty much finished, along with a good deal of other smaller scripts. I learned a lot along the way too. The documentation didn't look like a foreign language, it all made sense for the most part. I finally figured out where these %1, %2, etc variables were coming from in people's scripts. I guess I never grasped parameters being passed and using return to pass results, and definitely didn't understand how to access the parameters once in the sub. It really opens up the ability to reuse code with variations required by the individual functions that call it. It also makes me want to rewrite all of my scripts. It's made me reflect on a couple of languages I've tried to learn and the concepts I wasn't understanding. I think its time for me to actually follow all the way through with learning a language.

I stumbled upon here trying to find some information about certain functions in EUO. Apparently I had registered here years ago and never introduced myself and forgot about it. Reading through some of the forum it looks like I missed out on a nice community. I figured I'd introduce myself and see who still is out here for this old game. I may throw some stuff at you guys to see where I could improve. 

Anyways, I guess the moral of the story is after 22 years I finally started to comprehend automation I was doing in UO. In another 22 years who knows what I can achieve. A LJ script?

Pages: [1]