Author Topic: Trailmyx's Open Check for Paperdoll and Backpack  (Read 10408 times)

0 Members and 1 Guest are viewing this topic.

Offline TrailMyxTopic starter

  • 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
Trailmyx's Open Check for Paperdoll and Backpack
« on: March 29, 2009, 10:27:50 AM »
0
These subs can be used to verify that your backpack and paperdoll are open.  If not, then the script will open the container at the coordinates you supply.  Test code included.

Code: easyuo
  1. gosub TM_CheckBackpack  200 200
  2. gosub TM_CheckPaperdoll 200 200
  3. stop
  4.  
  5. sub TM_CheckBackpack
  6.   namespace push
  7.   namespace local CP
  8.   set !cnt %0
  9.   set !x %1
  10.   set !y %2
  11.   finditem * C_ , #BACKPACKID
  12.   if #FINDKIND = -1
  13.   {
  14.     event macro 8 7 ; open backpackid
  15.     gosub GumpAndSizeWait container_gump 230_204
  16.     if !cnt > 0
  17.     {
  18.       contpos !x !y
  19.       wait 10
  20.     }
  21.   }
  22.   namespace pop
  23. return
  24.  
  25. ;-----------------------------------------------------------------------
  26. ; gosub TM_CheckPaperdoll 200 200
  27. ; %1 = optional x coord
  28. ; %2 = optional x coord
  29. sub TM_CheckPaperdoll
  30.   namespace push
  31.   namespace local CP
  32.   set !cnt %0
  33.   set !x %1
  34.   set !y %2
  35.   finditem ZJF C_ , #CHARID
  36.   if #FINDKIND = -1
  37.   {
  38.     event macro 8 1 ; open paperdoll
  39.     gosub GumpAndSizeWait paperdoll_gump 262_324
  40.     if !cnt > 0
  41.     {
  42.       contpos !x !y
  43.       wait 10
  44.     }
  45.   }
  46.   namespace pop
  47. return
  48. ;-----------------------------------------------------------------------
  49. ; gosub GumpAndSizeWait generic_menu 200_200 20
  50. ; %1 = contname
  51. ; %2 = contsize
  52. ; %3 = timeout (defaults to 5 seconds if left blank.)
  53. sub GumpAndSizeWait
  54.   namespace push
  55.   namespace local GASW
  56.   set #RESULT #FALSE
  57.   if %3 > 0 && %0 > 2
  58.     set !delay #SCNT + %3
  59.   else
  60.     set !delay #SCNT + 5 ; 5 seconds default
  61.   wait 5
  62.   repeat
  63.   until ( #CONTNAME = %1 && #CONTSIZE = %2 ) || #SCNT > !delay
  64.   if #SCNT > !delay
  65.     set #RESULT #TRUE ; error
  66.   namespace pop
  67. return #RESULT
  68.  
« Last Edit: May 05, 2017, 04:57:35 PM by TrailMyx »
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline Khameleon

  • Script Tester - Team Leader
  • Elite
  • *
  • *
  • Posts: 2574
  • Activity:
    0%
  • Reputation Power: 30
  • Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!
  • Gender: Male
  • Respect: +238
  • Referrals: 0
    • View Profile
Re: Trailmyx's Open Check for Paperdoll and Backpack
« Reply #1 on: March 29, 2009, 10:33:54 AM »
0
LOL I'm writing something that this sub would go great with.

Offline Khameleon

  • Script Tester - Team Leader
  • Elite
  • *
  • *
  • Posts: 2574
  • Activity:
    0%
  • Reputation Power: 30
  • Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!
  • Gender: Male
  • Respect: +238
  • Referrals: 0
    • View Profile
Re: Trailmyx's Open Check for Paperdoll and Backpack
« Reply #2 on: March 29, 2009, 10:48:30 AM »
0
sorry to do this to you TM, but you have the Item Type wrong for searching the profile backpack.
ZLF is clean bandaids
ZJF is a backpack

other wise it works great!

Offline TrailMyxTopic starter

  • 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: Trailmyx's Open Check for Paperdoll and Backpack
« Reply #3 on: March 29, 2009, 11:22:46 AM »
0
How the heck did that happen??  heh.  Thanks, fixed.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline Khameleon

  • Script Tester - Team Leader
  • Elite
  • *
  • *
  • Posts: 2574
  • Activity:
    0%
  • Reputation Power: 30
  • Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!
  • Gender: Male
  • Respect: +238
  • Referrals: 0
    • View Profile
Re: Trailmyx's Open Check for Paperdoll and Backpack
« Reply #4 on: March 29, 2009, 06:16:30 PM »
0
hehe, well I posted up for the elites a little script that might come in handy if they open spring cleaning again.

Offline Katu

  • Jr. Member
  • **
  • Posts: 43
  • Activity:
    0%
  • Reputation Power: 2
  • Katu has no influence.
  • Respect: +5
  • Referrals: 0
    • View Profile
Re: Trailmyx's Open Check for Paperdoll and Backpack
« Reply #5 on: March 13, 2010, 12:04:33 AM »
0
I was going to write something similar, but might aswell use yours!

Thanks.

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Trailmyx's Open Check for Paperdoll and Backpack
« Reply #6 on: September 03, 2010, 07:40:39 AM »
0
Interesting .. i never thourght of actually searching for the paperdoll/ backpack gumps.  My subs just reopen them if open but i like your method better as it doesnt change the existing contid unless its nessacary.
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline NObama

  • Everything I need to know, I learned from Miffy's Item Finder.
  • Elite
  • *
  • *
  • Posts: 3454
  • Activity:
    0%
  • Reputation Power: 43
  • NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.
  • Respect: +161
  • Referrals: 2
    • View Profile
Re: Trailmyx's Open Check for Paperdoll and Backpack
« Reply #7 on: September 03, 2010, 09:53:23 AM »
0
Darnit.  You people are just posting stuff like this to force me to learn namespace, aren't you?

Offline TrailMyxTopic starter

  • 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: Trailmyx's Open Check for Paperdoll and Backpack
« Reply #8 on: September 03, 2010, 10:38:28 AM »
0
Ah, well there's nothing magical going on there with namespaces.  I use them in that particular instance to be sure I don't step on anyones variables they might be using.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline Cerveza

  • 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: Trailmyx's Open Check for Paperdoll and Backpack
« Reply #9 on: September 03, 2010, 11:03:16 AM »
0
Namespace for subs - a guide for NOBama

When you use a sub that utilizes variables it's a good idea to use namespace. This keeps the rest of the variables used in the script separated from those used only in the sub routine.

Within the namespace all variable types can be used.

% - for variables used throughout the script.
* - for global variables that are stored in the registry and available to all scripts running.
! - for variables that are used within that particular namespace

There's really only 3 things to know.

sub Teach_NOBama_Namespace
namespace push
namespace local TNN

...
... sub stuff
...
nameSpace pop

Push - this saves all the variables you've used and setup to this point.
Local - this names the new variable working area (namespace). You can share them across scripts, but thats for the more advanced lessons.
Pop - restores all the variables from the Push.

So the correct way to use namespace in a sub is like shown above. Sub - Push - Local - Sub itself - Pop, and remember to pop right before EACH return from the sub.

Here's why you do this.

Code: [Select]
set %timer #sCnt ; sets the variable to whatever the #sCnt is right now
stuff
gosub dothis

sub dothis
stuff
set %timer 1000 ; you accidentally used the same variable you set to #sCnt before
return

Now the variable %timer is set to 1000 in the entire script.

Using a Namespace you avoid any mistakes like that.

Code: [Select]
set %timer #sCnt ; sets the variable to whatever the #sCnt is right now
stuff
gosub dothis

sub dothis
namespace push
namespace local DT1
stuff
set !timer 1000 ; notice how I use the ! variable
namespace pop
return

Now the variable !timer can be 1000 while the variable %timer is still #sCnt from before. No chance for "spillage".
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.

Scrripty

  • Guest
Re: Trailmyx's Open Check for Paperdoll and Backpack
« Reply #10 on: September 03, 2010, 12:13:00 PM »
0
If you use the namespace GLOBAL command when running a namespace, it makes all the ! variables available in any tab using the name given to the namespace also.  So if you did this:

Code: [Select]
namespace push
namespace global NOBAMASNAMESPACE
set !nobama noob
namespace pop

That !nobama variable would be available in ANY tab in the SAME EUO INSTANCE as long as you referenced it by it's namespace.  So in a completely different script, you could access that variable by calling the namespace NOBAMASNAMESPACE in the same way.  It's an easy way to communicate between scripts.  If you look at my waypoint pathfinder, I use that technique to communicate between the main and secondary scripts so the first character lays down waypoints, and the second character follows them by accessing the waypoints in the namespace that were already created as variables by the other script.  Then it just follows them in order by an index.  Easy.  If the main character is at index number 100.  And the secondary character is at index number 1, he just follows the waypoints in order from 1 to the current characters position.  Voila.  He's following me wherever I go.  The local namespace is local to the script you are in, global makes the variables available to all tabs in an instance of euo.

Offline NObama

  • Everything I need to know, I learned from Miffy's Item Finder.
  • Elite
  • *
  • *
  • Posts: 3454
  • Activity:
    0%
  • Reputation Power: 43
  • NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.
  • Respect: +161
  • Referrals: 2
    • View Profile
Re: Trailmyx's Open Check for Paperdoll and Backpack
« Reply #11 on: September 03, 2010, 03:00:05 PM »
0
Ah!  That actually made it easy.  Thanks, Cerv & Twinkle McNugget