ScriptUO

Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: Superslayer on February 22, 2009, 04:38:54 PM

Title: Offset gumps
Post by: Superslayer on February 22, 2009, 04:38:54 PM
As I write my first script (the roam one going on 1500 lines without the rails even) I have some notes at the top as 'Goals' to achieve.  At this moment, I'm rather wondering, do I need to have an offset gump option available, and if so, how so?  Currently I play on a 1280 x 1024 20" screen and the UO options are 1024 x 768 full screen resolution option and the game play window at 800 x 600.  I have in my script, parts where gumps are moved to a place, clicks made, runebooks opened and click made and the such.
Title: Re: Offset gumps
Post by: TrailMyx on February 22, 2009, 04:45:31 PM
If you check out this little script:

http://www.scriptuo.com/smf/index.php?topic=505.0;highlight=click

I used this all the time to generate the correct click offsets for screen locations.

It works wonders; I use it just about every script I develop.
Title: Re: Offset gumps
Post by: OMGBurgers on February 22, 2009, 05:28:09 PM
Same thing I do.  Simple fool proof solution :)
Title: Re: Offset gumps
Post by: Superslayer on February 22, 2009, 06:13:35 PM
So as I understand it, I personally won't need to incorporate this sub in my script, but users of my script can use this sub?  Or...I can actually have it in my script, but keep it commented out for me, and just let users aware that it is there and can/should be used/uncommented?
Title: Re: Offset gumps
Post by: TrailMyx on February 22, 2009, 06:25:06 PM
The only thing you have to integrate into your script is this:

Code: [Select]
sub OffsetClick
  set %tempx %1 + #CONTPOSX
  set %tempy %2 + #CONTPOSY
  click %tempx %tempy f
return

Whether you write one yourself, or use that one.  Just about every scripter out there has generated a sub like this to adjust for gump coordinates mapped to the screen.  You start out coding all those clicks by hand, but you'll soon find that you are going to be using the same type of code a 100 times over.  So that's when you just make a little click sub out of it. 

The script I linked for you just help you generate the offset coordinates so you can cut/paste the resulting offset values.

A note on why we really need a sub like this

When you've coded enough, you might think that code like this should function:

Code: [Select]
  click %tempx + 200 %tempy + 200 f

However, in EasyUO it doesn't know how to parse this.  So that's why you have to do the math before you actually use the CLICK command. 

At this point, I get to poke fun at the lame EasyUO parser again..  ScriptUO knows how to parse this expression.  ;)
Title: Re: Offset gumps
Post by: Superslayer on February 22, 2009, 08:06:46 PM
Thanks TM, again.  It surprisingly makes sense.
Title: Re: Offset gumps
Post by: OMGBurgers on February 22, 2009, 08:15:05 PM
When you've coded enough, you might think that code like this should function:

Code: [Select]
  click %tempx + 200 %tempy + 200 f

Haha you have no idea how often I tried to make things like that work ;*(
It would make code so much cleaner though if you could do things like that ;/
Title: Re: Offset gumps
Post by: _C2_ on February 23, 2009, 06:29:37 AM
absolute life savers and allows everyone to use your code regardless of resolution.  I don't remember when I learned this but it was from cerv or TM and it is a life changer!
Title: Re: Offset gumps
Post by: Cerveza on February 23, 2009, 07:38:51 AM
absolute life savers and allows everyone to use your code regardless of resolution.  I don't remember when I learned this but it was from cerv or TM and it is a life changer!

Musta been TM, I'm only semi-literate.
Title: Re: Offset gumps
Post by: bliss on March 03, 2009, 10:56:09 AM
does this actualy move the gump to a diff spot? thats what i need to do. i need to open a crafting gump and move it off the main play screen i dont use full size res so i have some room
Title: Re: Offset gumps
Post by: TrailMyx on March 03, 2009, 11:01:57 AM
No, this just makes whatever gump you are addressing usable.  For you, just change the #CONTPOSX and #CONTPOSY.  Also, if you change the #NEXTCPOSX and #NEXTCPOSY before you open the gump, then it will open where you want it.
Title: Re: Offset gumps
Post by: bliss on March 03, 2009, 11:42:23 AM
does this move a gump ? lol sorry you replied fast to that one
Title: Re: Offset gumps
Post by: TrailMyx on March 03, 2009, 11:47:40 AM
#CONTPOSX and #CONTPOSY will move the current gump or container.
#NEXTCPOSX and #NEXTCPOSY will allow you to specify the position of the next opened gump/container.
Title: Re: Offset gumps
Post by: bliss on March 03, 2009, 12:06:57 PM
every time i think i have a grasp of what is going i realise i dont have a clue lol
Title: Re: Offset gumps
Post by: TrailMyx on March 03, 2009, 08:50:44 PM
Ah, you'll get it.  Best thing is to do what I did and just play with it.... ;)
Title: Re: Offset gumps
Post by: _C2_ on March 04, 2009, 06:22:18 AM
every time i think i have a grasp of what is going i realise i dont have a clue lol


I remember when all i knew to do with finditem was if #findkind = -1.

The more code you read and follow through , the more you will learn about how gumps are moved and placed, and different variables can be used and checked.  I just upgraded my pot maker to 2.0b and in the script i move the packs around to specific locations.  I also do it in other scripts including a really simple on, c2's keg emptier.  That is a good one to read through for reference.  It is over at winuo.org though.  I am starting to put a few scripts up here though too.  Need to put some out in public though.
Title: Re: Offset gumps
Post by: Superslayer on June 24, 2009, 11:10:31 AM
this thread can be deleted
Title: Re: Offset gumps
Post by: Cerveza on June 24, 2009, 11:11:59 AM
Good for others to learn from, I'll remove it if you really want.
Title: Re: Offset gumps
Post by: Superslayer on June 24, 2009, 11:14:25 AM
good point. I may actually reference it again as well.