Author Topic: Tutorial 2 - Selecting and Using an Item  (Read 16489 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
Tutorial 2 - Selecting and Using an Item
« on: February 24, 2009, 12:53:01 PM »
0
Before learning anything about selecting and using... you have to know a couple of definitions.

Item TYPE = the KIND of item, either a 2 or 3 letter code.
Item ID = the SPECIFIC items identification.

Make sure you know the difference between these right now.

A group of 100 bandages will have an Item TYPE of ZJF. One bandage will have a TYPE of ZJF. A stack of 20,000 bandages will have an TYPE of ZJF.

A stack of bandages will have some unique Item ID (something like AQBBJHD). Each bandage will have a different ID.

Ok, got it?

Now we can learn how to use stuff. Lets put a bandage on ourselves. If you've already read the script flow post, and the first and second script posts, you'll see this stuff... if not it's no big deal, reading this first will help a little when you get to those posts.

1 - What do we want to do?
Apply a bandage to myself when I hit F10

2 - Define that a little more
Hit the F10 Key
Find a bandage in my pack - quit if not found
Use the bandage
Target Myself

Code: [Select]
SUO:
repeat

onhotkey F10
  gosub UseBandage

until #CharGhost = YES
while #CharGhost = YES
  wait 0
GoTo SUO

That's my now famous mainloop with a gosub in the main portion. The gosub is called whenever the F10 key is pressed. The command onhotkey tells the script to react when it sees the F10 key press. Then the script will execute the code within the sub routine "UseBandage"

Code: [Select]
sub UseBandage
  findItem ZJF C_ , #backpackID
    if #findKind = -1
      halt
  set #lobjectID #findID
  set #ltargetKind 1
  event macro 17 0
  target 3
  event macro 23 0
  wait 5
return

Ok, lets see whats happening in the sub.

findItem ZJF C_ , #backpackID
Finds an ITEM of ZJF (meaning ANY bandage or pile of bandages... remember ITEM TYPE) in a container (C_ , ) with the ID of your backpack.

It's worth noting, we're only interested in finding the item TYPE of bandages, we don't care what color, what stack, or anything else, we only care about finding ANY bandages.

if #findKind = -1
  halt


This line says, if you DON'T FIND ANY then execute the next line of code (halt).

set #lobjectID #findID

Since we're here, we know that at least one bandage type (ZJF) was found in our pack. When it (or they) were found, the system automatically got the ITEM ID from it (or them) and stored it in the #findID register. If you were to look at #findID on the right side of EUO right now, you'd see something like ERGJAR which would be the ID of the individual bandage (or stack) that was found.

We want that ID set as last target, so we can use a built in UO macro to use it. So this line sets the Last Object ID as the found bandage.

set #ltargetKind 1

This sets the internal thinking of EUO to use the item type of an object. It's CRITICAL to do this as not to confuse EUO to thinking it's a tile or something.

event macro 17 0

That line is the same thing as making a UO macro to "use last item" which was set as the found bandage.

target 3

Waits up to 3 seconds for the target cursor to appear. If it comes up quicker the script simply continues then instead of waiting.

event macro 23 0

This is the UO macro for "target self". This would be the same thing as clicking yourself now that the bandage has been used and the target cursor is up.

wait 5

Short 1/4 second wait to allow the events to complete before going back through the cycle.

So there it is. Your completed "find a bandage and use it when I press F10" script:

Code: [Select]
;=================================================================
; Script Name: Cerveza's Hotkey Bandage
; Author: Cerveza
; Version: 1.0
; Shard OSI / FS: OSI / FS OK
; Revision Date: 2/24/2009
; Purpose: Use Bandage on Hotkey
; Globals: None
;=================================================================

;************************ Setup **********************************

;*********************** MainLoop ********************************
SUO:
repeat

onhotkey F10
  gosub UseBandage

until #CharGhost = YES
while #CharGhost = YES
  wait 0
GoTo SUO

;************************ Subs ***********************************
sub UseBandage
  findItem ZJF C_ , #backpackID
    if #findKind = -1
      halt
  set #lobjectID #findID
  set #ltargetKind 1
  event macro 17 0
  target 3
  event macro 23 0
  wait 5
return
« Last Edit: August 03, 2010, 12:48:23 PM by Cerveza »
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 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: Selecting and Using an Item
« Reply #1 on: February 24, 2009, 01:41:02 PM »
0
nice write up...

Offline UOMaddog

  • Maddog
  • Elite
  • *
  • *
  • Posts: 1625
  • Activity:
    0%
  • Reputation Power: 22
  • UOMaddog might someday be someone...UOMaddog might someday be someone...UOMaddog might someday be someone...UOMaddog might someday be someone...
  • Gender: Male
  • Biggest B@D@$$ of the Universe
  • Respect: +165
  • Referrals: 8
    • View Profile
    • Insane UO
Re: 2 - Selecting and Using an Item
« Reply #2 on: April 19, 2009, 09:23:07 AM »
0
You should probably have it "return" instead of "halt" if it doesn't find any! Just picking on ya!!  ;)
There are 10 kinds of people in this world: those that understand binary and those that don't!

Windows:  A 64-bit tweak of a 32-bit extension to a 16-bit user interface for an 8-bit operating system based on a 4-bit architecture from a 2-bit company that can't stand 1 bit of competition!

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: 2 - Selecting and Using an Item
« Reply #3 on: April 19, 2009, 09:24:04 AM »
0
You should probably have it "return" instead of "halt" if it doesn't find any! Just picking on ya!!  ;)

Or even a nice "display ok DOOOD! Get some Bandies!"  :p
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline El_Remo

  • Jr. Member
  • **
  • Posts: 92
  • Activity:
    0.4%
  • Reputation Power: 2
  • El_Remo has no influence.
  • Gender: Male
  • Respect: +17
  • Referrals: 0
    • View Profile
Re: Tutorial 2 - Selecting and Using an Item
« Reply #4 on: April 15, 2011, 08:12:15 PM »
0
Thanks for these tutorials. Im really wanting to learn this stuff and this looks idiot proof as long as i have a little patience.

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: Tutorial 2 - Selecting and Using an Item
« Reply #5 on: April 16, 2011, 06:00:36 AM »
0
And be sure to ask if you have any questions. These were written in a way that should show people how to do things relatively easily (that was my hope).
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 El_Remo

  • Jr. Member
  • **
  • Posts: 92
  • Activity:
    0.4%
  • Reputation Power: 2
  • El_Remo has no influence.
  • Gender: Male
  • Respect: +17
  • Referrals: 0
    • View Profile
Re: Tutorial 2 - Selecting and Using an Item
« Reply #6 on: April 16, 2011, 06:14:54 AM »
0
For instance. Your instructions here..  A group of 100 bandages will have an Item TYPE of ZJF. One bandage will have a TYPE of ZJF. A stack of 20,000 bandages will have an TYPE of ZJF.

A stack of bandages will have some unique Item ID (something like AQBBJHD). Each bandage will have a different ID.

How do I find out exactly what the unique ID for the stack of bandages would be?
I assume to get the Type of item, there is a database that tells us, but i wasnt sure how to begin to find what the unique ID would be. Im sure this may be elementary but ive no clue where to start.
Most of the other tutorials ive seen seem to go on the premise of the scritor knowing how to find these ID numbers..  Thanks for the follow up..
Or is it even necessary to know the Unique ID?
« Last Edit: April 16, 2011, 06:39:29 AM by Chancy055 »

Offline gimlet

  • Very Super Secret
  • Global Moderator
  • *
  • *
  • Posts: 6190
  • Activity:
    3%
  • Reputation Power: 71
  • gimlet is awe-inspiring!gimlet is awe-inspiring!gimlet is awe-inspiring!gimlet is awe-inspiring!gimlet is awe-inspiring!gimlet is awe-inspiring!gimlet is awe-inspiring!gimlet is awe-inspiring!gimlet is awe-inspiring!gimlet is awe-inspiring!gimlet is awe-inspiring!gimlet is awe-inspiring!
  • Gender: Male
  • Respect: +273
  • Referrals: 3
    • View Profile
Re: Tutorial 2 - Selecting and Using an Item
« Reply #7 on: April 16, 2011, 09:43:39 AM »
0
I think bandages are  ZLF

but one way is to use easyuo and another is to use TM 's program

http://www.scriptuo.com/index.php?topic=188.0;highlight=findinfo

Offline Ultima

  • Insane Scripter
  • *
  • Posts: 1580
  • Activity:
    0%
  • Reputation Power: 26
  • Ultima is on the verge of being accepted.Ultima is on the verge of being accepted.Ultima is on the verge of being accepted.Ultima is on the verge of being accepted.Ultima is on the verge of being accepted.
  • Gender: Male
  • Respect: +160
  • Referrals: 4
    • View Profile
Re: Tutorial 2 - Selecting and Using an Item
« Reply #8 on: April 16, 2011, 09:49:03 AM »
0
Good Write up Cerveza! Now it makes sense the way you explain it and break it down in laymans terms step by step. This is what I've needed. I'm inspired to have to look through a few more of these tutorials.


What is this function? :

Code: [Select]
until #CharGhost = YES
while #CharGhost = YES

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: Tutorial 2 - Selecting and Using an Item
« Reply #9 on: April 16, 2011, 03:10:32 PM »
0
It's just the end of the loop...

It will repeat whatever is in between the repeat and the until. It will keep cycling everything between those unless the condition set in the UNTIL is met.

Repeat
cerveza rocks
until cerveza doesn't rock

See, that will repeat forever because I will never fail to rock.

Repeat
whatever
until #false

That's another forever repeater. Until will never be #false, so it just keeps looping. Lots of people use that one. But what happens when you die and you don't have mana or whatever to continue the script?

That's why the

repeat
whatever
until #charGhost = YES

So... it will repeat whatever is in the middle until the character becomes a ghost. And then it does the next part...

while #charGhost = YES ; so while you are a ghost it does whatever is in the next section between the {} OR whatever is on the next line if there are no {}
wait 1 ; wait

So if you are a ghost, it goes to the while line and will wait until you are no longer a ghost to continue.

Good point to talk about repeat and while... remind me and I'll wright something up. And I'll mention the evils of the goto....
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 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: Tutorial 2 - Selecting and Using an Item
« Reply #10 on: September 20, 2011, 06:33:08 AM »
0
stickied
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.

Tags: