Author Topic: SUOLootSub  (Read 4837 times)

0 Members and 1 Guest are viewing this topic.

Offline CervezaTopic starter

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
SUOLootSub
« on: October 04, 2011, 05:52:18 AM »
0
I propose that we put together a sub routine to loot items. It would then be very easy to include in various farming scripts.

Here's my thought for the sub.

gosub SUOLootSub {item ID's} {container to loot} {destination container} {ignore loot container YES/NO}

To use it in a script you could use something like...

Code: [Select]
finditem YFM G_2
if #findCnt > 0
  gosub SUOLootSub POF #findID #backpackID YES

Just a down and dirty loot sub.

Code: [Select]
sub SUOLootSub
namespace push
namespace local SUOLootSub
set !loot %1
set !source_container %2
set !destination_container %3
set !ignore_container %4
finditem !loot C_ , !source_container
if #findCnt = 0
  {
  namespace pop
  return
  }
...
...
...
namespace pop
return

Maybe include Neo's safe drag drop

Thoughts?
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline UoLugnutz

  • Full Member
  • ***
  • Posts: 123
  • Activity:
    0%
  • Reputation Power: 2
  • UoLugnutz has no influence.
  • Respect: +25
  • Referrals: 0
    • View Profile
Re: SUOLootSub
« Reply #1 on: October 04, 2011, 07:00:32 AM »
0
I think a looter like this would be great. Been slowly updating my Leather farmer to a more generic Sampire hunter and the looting part needed a lot of work next and an idea like this is perfect.
One option I would like to see is to search for multiple corpses but that's really not part of the Sub but more part of the script I guess.
Anyways i m doing tonnes of resources farming for points and can test as needed.

Offline camotbik

  • Sr. Member
  • *
  • Posts: 349
  • Activity:
    0%
  • Reputation Power: 3
  • camotbik has no influence.
  • Gender: Male
  • Hello! I'm a UO addict.
  • Respect: +38
  • Referrals: 0
    • View Profile
Re: SUOLootSub
« Reply #2 on: December 06, 2011, 02:20:56 PM »
0
Just interested, what is the point of using name spaces in a looter? I mean would you run it in a separated window or what?
What you witness -- is whatver..
uogamers hybrid.

Offline CervezaTopic starter

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: SUOLootSub
« Reply #3 on: December 06, 2011, 03:35:35 PM »
0
Namespace is a way to control variables in subs.
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline camotbik

  • Sr. Member
  • *
  • Posts: 349
  • Activity:
    0%
  • Reputation Power: 3
  • camotbik has no influence.
  • Gender: Male
  • Hello! I'm a UO addict.
  • Respect: +38
  • Referrals: 0
    • View Profile
Re: SUOLootSub
« Reply #4 on: December 06, 2011, 03:37:22 PM »
0
Ok, just wondering, could you give me an example for something i could not do with out namespaces working in a 1window script?
What you witness -- is whatver..
uogamers hybrid.

Offline Neo

  • Prime Program
  • Elite
  • *
  • *
  • Posts: 821
  • Activity:
    0%
  • Reputation Power: 13
  • Neo barely matters.Neo barely matters.
  • Respect: +155
  • Referrals: 3
    • View Profile
Re: SUOLootSub
« Reply #5 on: December 06, 2011, 03:47:20 PM »
0
Ok, just wondering, could you give me an example for something i could not do with out namespaces working in a 1window script?
Using local namespaces are pretty common in 1 window script... I use them in everything I write nowadays...

It's simply easier to organize and control the variables you use, that's all...

And also, it would make it easier to add new subs with new stuff to that script, even if it's someone else who's adding new things, not having to worry about conflicting var names...

Just my view on this of course...
Never refuse an invitation.
Never resist the unfamiliar.
Never fail to be polite.
And never outstay your welcome.

Offline DPeterson

  • Newbie
  • *
  • Posts: 6
  • Activity:
    0%
  • Reputation Power: 1
  • DPeterson has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: SUOLootSub
« Reply #6 on: December 07, 2011, 04:21:07 AM »
0
Ok, just wondering, could you give me an example for something i could not do with out namespaces working in a 1window script?

This is about the best example I could envision.  Notice I set the !var to blue inside the namespace.  But on the other side of the namespace the !var still shows as green.  That's what namespaces are for. ;)

Code: [Select]
set !var green

namespace push
namespace local !var
set !var blue
namespace pop

event sysmessage !var
halt

Offline camotbik

  • Sr. Member
  • *
  • Posts: 349
  • Activity:
    0%
  • Reputation Power: 3
  • camotbik has no influence.
  • Gender: Male
  • Hello! I'm a UO addict.
  • Respect: +38
  • Referrals: 0
    • View Profile
Re: SUOLootSub
« Reply #7 on: December 07, 2011, 04:45:20 AM »
0
Well but what is the purpose of this? I mean, you could use set, with even taking less space than with namespaces ( AND DO THE SAME THING!!!! )
Code: [Select]
set %var green

set %old_var %var
set %var blue
set %var %old_var

event sysmessage %var
stop
« Last Edit: December 07, 2011, 06:18:02 AM by camotbik »
What you witness -- is whatver..
uogamers hybrid.

Offline CervezaTopic starter

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: SUOLootSub
« Reply #8 on: December 07, 2011, 05:35:09 AM »
0
It's a way of controlling your variables more. You can use the same variable name for two different things by using namespace.

Code: [Select]
set %my_name Cerveza
msg %my_name $ ; returns Cerveza

namespace push
namespace local IMPOSTER
set %my_name NOT Cerveza
msg %my_name $ ; returns NOT Cerveza
namespace pop

msg %my_name $ ; I'm Cerveza again, yah!
halt
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline Crome969

  • Elite
  • *
  • *
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: SUOLootSub
« Reply #9 on: December 07, 2011, 10:32:04 PM »
0
I never used Namespaces in easyuo but i think its a good thing when you want consider Cases with using the same !var names.

Offline DPeterson

  • Newbie
  • *
  • Posts: 6
  • Activity:
    0%
  • Reputation Power: 1
  • DPeterson has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: SUOLootSub
« Reply #10 on: December 08, 2011, 07:53:23 AM »
0
Well but what is the purpose of this? I mean, you could use set, with even taking less space than with namespaces ( AND DO THE SAME THING!!!! )

camotbik, but without namespaces if you tried to use another persons sub in your script, you'd have to go through their code and make sure you both didn't use any of the same variables...  when you write subs for others to use, if you use a namespace to encapsulate  your code in the sub, and return your result, other's don't have to worry about your code, it's just drag and drop with your own code.  Even if it uses the exact same variables they wont interfere with each other.

Offline Crome969

  • Elite
  • *
  • *
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: SUOLootSub
« Reply #11 on: December 08, 2011, 08:07:46 AM »
0
I only know namespaces from C# and Java and they have a different manner.
But the base Idea of Namespaces is not bad. Unlucky it would be when the other script using namespaces as well with same namespace using. Then you are on the same thing as without. Or may i be wrong?

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13303
  • Activity:
    0.4%
  • 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: SUOLootSub
« Reply #12 on: December 08, 2011, 10:35:03 AM »
0
The main reason I use namespaces is to separate my variable names from others that might be used in a script.  That way, if I use a generic variable !test in different instances, the variable value will not get polluted or unintentionally changed in another section of code.

Another useful idea for namespace storage is for multidimensional arrays.  Take a look at this code so you can see how the data is "encapsulated" within each namespace:

Code: [Select]
; set up your times tables
for %x 1 12
{
  for %y 1 12
  {
    set %times %x * %y
    gosub AddToArray times_table %times %x %y
  }
}

gosub GetFromArray times_table 11 12
display ok 11 times 12 is , #SPC #RESULT

gosub GetFromArray times_table 5 7
display ok 5 times 7 is , #SPC #RESULT

gosub GetFromArray times_table 8 9
display ok 8 times 9 is , #SPC #RESULT

stop
; %1 = Arrayname
; %2 = Value to add
; %3 = index 1
; %4 = index 2
; ...
sub AddToArray
  namespace push
  namespace local Array , _ , %1
  set !var
  for !index 3 %0
     set !var % . !index , _ , !var
  set ! . !var %2
  namespace pop
return
; %1 = Arrayname
; %2 = index 1
; %3 = index 2
; ...
sub GetFromArray
  namespace push
  namespace local Array , _ , %1
  set !var
  for !index 2 %0
     set !var % . !index , _ , !var
  set #RESULT ! . !var
  namespace pop
return #RESULT
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline CervezaTopic starter

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: SUOLootSub
« Reply #13 on: December 08, 2011, 10:50:20 AM »
0
I make it write my name, TM makes it map a trajectory around 6 planets.
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13303
  • Activity:
    0.4%
  • 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: SUOLootSub
« Reply #14 on: December 08, 2011, 10:51:35 AM »
0
I make it write my name, TM makes it map a trajectory around 6 planets.

Everyone would be disappointed if I didn't do that.  ;)
Please read the ScriptUO site RULES
Come play RIFT with me!

Tags: