Author Topic: FINDCOL  (Read 8228 times)

0 Members and 1 Guest are viewing this topic.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • Activity:
    0%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: FINDCOL
« Reply #15 on: July 17, 2017, 08:49:29 PM »
0
Heh, I'm going to nit-pick you here.  Here's pretty much exactly the same code you have, but "worded" in a way that's a bit clearer:

Code: easyuo
  1. sub ClearPack2
  2.   namespace push
  3.   namespace local CP2
  4.   set !color %1
  5.   set !item %2
  6.   set !destination %3
  7.   finditem !item C_ , #backpackid
  8.   if #findcnt > 0
  9.   {
  10.     for #findindex 1 #findcnt
  11.     {
  12.       if #FINDCOL = !color
  13.       {
  14.         exevent drag #findid #findstack
  15.         exevent dropc !destination
  16.         wait 20
  17.       }
  18.     }
  19.   }
  20.   namespace pop
  21. return
  22.  

1) I've found it's always a bit clearer to name your input arguments and list them as assignments at the beginning of a function.  It's just easier to read once you find their referneces down in the code
2) Try like mad to make sure there's only one exit from a sub.  Sometimes it's not very clear where the returns are, so just flipping your IF comparison, I managed to make the code flow from top to bottom better
3) If you really want me to help you understand the namespace push/pop and your used of !color vs. %color or something else, we can get into that.  Here's at least a starting explanation I put together some time ago:

http://www.scriptuo.com/index.php?topic=108.msg370#msg370
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline CrisisTopic starter

  • Global Moderator
  • *
  • *
  • Posts: 2998
  • Activity:
    3.4%
  • Reputation Power: 41
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +205
  • Referrals: 2
    • View Profile
Re: FINDCOL
« Reply #16 on: July 17, 2017, 09:34:04 PM »
0
I appreciate the nitpicking, it makes me better.  8)

I will check out the link and get back to you. I am all for learning more, scripting can be nerve-wracking at times but I really enjoy it.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • Activity:
    0%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: FINDCOL
« Reply #17 on: July 18, 2017, 06:55:40 AM »
0
I appreciate the nitpicking, it makes me better.  8)

I will check out the link and get back to you. I am all for learning more, scripting can be nerve-wracking at times but I really enjoy it.

That's really the only reason why I mention it.  It seems  like you are all over the learning thing.  Also, we've observed how people learn to script over the years here and since most people don't really have a classical programming background like some of us, then it makes sense that people learn the best from code examples.  Knowing that, it's just helpful to leave your code as helpful and clear as possible.  I had no idea people would cut my stuff up and use it for their own thing, but it's kinda cool knowing that's going on. :)
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline CrisisTopic starter

  • Global Moderator
  • *
  • *
  • Posts: 2998
  • Activity:
    3.4%
  • Reputation Power: 41
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +205
  • Referrals: 2
    • View Profile
Re: FINDCOL
« Reply #18 on: July 18, 2017, 07:21:05 AM »
+1
As I understand things better, I can get closer and closer to writing my own subs. The sub that I was originally using was my own mishmash, I was trying to incorporate different things that I found when looking for findcol. When you showed me how to do the findcol, I tried to incorporate that into my original clear pack. Thats the good and bad thing about coding. Due to the programming rules, there are only so many ways to do something original but at the same time, because of that, people can look and see what others have done. It wasn't too long ago that I had no idea what %1 %2 etc meant but now I totally get it. Before looking at the sub you wrote for findcol, I did not know that you could set things as !color !container etc. I also understand the easyuo wiki better though many of their examples are too simplistic to help much.

My goal as I get better is to one day soon, write all subs and a script from scratch without looking at anything that anyone has done including myself. I try not to just look at something and use it, but adapt it to fit my needs and learn from it as well. I quickly found I was in over my head with a miner program so I am going to start small. My next project will be to write a new buying program to recall and buy from vendors. What I hope to do is plan out all my subs in an outline to see what I will need and then start making them one at a time from scratch and see how I can do. Then I am going to try and swap them in other working scripts that I have to test them. Once they are working, make a sub library for myself to borrow from to craft new things. I may not write a bunch of scripts that have not been done before but hopefully they will work better than older ones due to changes and people will want to use mine. I have a lot of big plans and looking forward to getting them started. I am so proud of my legendary scribe script right now because I know how much I have had to work I had to put in to trouble shoot problems, especially since it is so big. One day I may be able to use only subs from my library to make it better and shorter!! I know I am thinking ahead of my skills right now but I will get there!!
« Last Edit: July 18, 2017, 07:22:44 AM by Crisis »

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • Activity:
    0%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: FINDCOL
« Reply #19 on: July 18, 2017, 08:30:51 AM »
0
You'll enjoy having your own library of subs to draw from.  I find that after I got my subs up and running, throwing together a script is no big deal because I just cut/paste the subs in and write a little bit of glue-code to make it go.  Mostly then its just making the UI function correctly.  That's why I started with the basics like journal handling and data storage.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline BobOzarius

  • Full Member
  • ***
  • Posts: 103
  • Activity:
    0%
  • Reputation Power: 2
  • BobOzarius has no influence.
  • Respect: +26
  • Referrals: 0
    • View Profile
Re: FINDCOL
« Reply #20 on: August 03, 2017, 10:51:36 PM »
0
Eventually you'll get to a point where you never want to use other people's subs because it's annoying to read them and debug them. Using your own code is much simpler. Write some basic standard subs and start to learn the call function, and you'll be well on your way to writing your own library. I have a few files that have standard subs for literally everything, written to my standards. And I just use a military SOP type procedure to update the subs inside those files. When I find a better way, I update. Overall, your entire library will benefit and as you add more and more standard subs to the file, you'll require less and less time to create large scripts. Because most everything will already be written by you and callable from your called standard sub files.  ;)  Sorry, SOP stands for Standard Operating Procedure. That just means when you find a better way, you adopt it. It makes it easy to keep your scripts updated, because when you update one sub, you literally update every script you have in your library that calls that file.

Tags: