Author Topic: Tutorial 7 - Status Menu for P&B  (Read 6547 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 7 - Status Menu for P&B
« on: February 26, 2009, 10:45:05 AM »
+1
Squeeky just won't leave me alone... Now he wants a simple display of whats going on in the script  >:(

So lets see what we already have...

Code: [Select]
;=================================================================
; Script Name: Cerveza's Cure And Heal Pot Drinker w/Hotkey Bandages
; Author: Cerveza
; Version: 1.0
; Shard OSI / FS: OSI / FS OK
; Revision Date: 2/24/2009
; Purpose: Drink Cure/Heal Potions when needed, Applies bandages on hotkey
; Globals: None
;=================================================================

;************************ Setup **********************************
set %healpotHP ( #maxHits - 40 ) ; change this for how many points down to drink heal
set %timer_pot_heal #sCnt
set %bandage_hotkey F10 ; you can change this to whatever you want your bandage hotkey

;*********************** MainLoop ********************************
SUO:
repeat
  
  if C in #charStatus
    gosub DoIt NUF NONE ; %1=NUF %2=NONE
  
  if #hits < %healpotHP && #sCnt > %timer_pot_heal
  {
    gosub DoIt UUF NONE ; %1=UUF %2=NONE
    set %timer_pot_heal ( #sCnt + 10 )
  }
  wait 5

  onhotkey %bandage_hotkey
    gosub DoIt ZJF SELF ; %1=ZJF %2=SELF
  
until #CharGhost = YES
while #CharGhost = YES
  wait 0
GoTo SUO

;************************ Subs ***********************************
; %1 - Item TYPE to use. NUF=Cure Pot, UUF=Heal Pot, ZJF=Bandage
; %2 - Target. SELF to target self, all other will skip targetting
sub DoIt
  namespace push
  namespace local DIT ; short for DrinkIT
  wait 5
  findItem %1 C_ , #backpackID
  if #findKind = -1
    return
  set #lobjectID #findID
  set #ltargetKind 1
  event macro 17 0
  if %2 = SELF
  {
    target 3s
    event macro 23 0
  }
  namespace clear
  namespace pop
return

Now, I'm not the most knowledgeable dude on menus, but I can do some simple enough stuff. And I think I can help squeeky out here...

Before going any further, you really should go pick up EasyUO Menu Designer and you HAVE to get this older version of EUO to use with it - EasyUO V1.42 [Build 00B4].

Run the EUO v1.42 first, then start up the Menu Designer. Copy and paste this little "menu" into the EUO 1.42 and see what it looks like. You can go back and forth between the Menu Designer and the EUO 1.42 to see what different changes look like.

Code: [Select]
;--------- EasyUO Menu Designer Code Begin ---------
sub showEUOMenu1
  menu Clear
  menu Window Title Cerv's P & B %ver
  menu Window Color Lime
  menu Window Size 207 27
  menu Font Transparent #true
  menu Font Align Right
  menu Font Name MS Sans Serif
  menu Font Size 8
  menu Font Style
  menu Font Color WindowText
  menu Font Transparent #false
  menu Font Align Left
  menu Font BGColor Red
  menu Text c1 5 5 -
  menu Show 421 270
return
;--------- EasyUO Menu Designer Code End ---------

That code is just the menu. We still need to call the menu once to get it displayed, then we need to make menu changes any time we want to update the display.

In the setup portion of our script we're going to add:

gosub showEUOMenu1

Easy enough, it'll go to the menu and display it on screen.

Now we need some way of updating it. I put in this line throughout the script to show what the current status is:

menu set c1 Scanning..... - What that does is updates the "c1" field in the menu with the word "Scanning....."

I put that same line in different places in the script to show what the status is. Just a cool tip for you... you could do something like this also:

menu set c1 Drinking CURE Potion #time - Yep you can use variables (system or user) and it will display something like:

Drinking CURE Potion 093347 to let you know exactly what time the event is taking place.

Here's what I like to do in my scripts:

menu set c1 sub Do_IT #time 65 - That shows me where the script currently is, what time it got there, and what line it's on.

If only there were a way to just use something like #lineNumber.... (inside joke for TM).

OK, so now that we've updated our little Potion and Bandage (P&B) script with a status menu... lets see what it looks like.

Code: [Select]
;=================================================================
; Script Name: Cerveza's Cure And Heal Pot Drinker w/Hotkey Bandages
; Author: Cerveza
; Version: 2.0
; Shard OSI / FS: OSI / FS OK
; Revision Date: 2/24/2009
; Purpose: Drink Cure/Heal Potions when needed, Applies bandages on hotkey
; Globals: None
;=================================================================
; v1.0 First Release
; v1.1 Merged potions and bandages
; v1.2 Added cursor checks
; v2.0 Added status menu
;=================================================================
; Thanks: Definitely NOT squeeky
;=================================================================
set %ver v2.0

;************************ Setup **********************************
set %healpotHP ( #maxHits - 40 ) ; change this for how many points down to drink heal
set %timer_pot_heal #sCnt
set %bandage_hotkey F10 ; you can change this to whatever you want your bandage hotkey
gosub showEUOMenu1

;*********************** MainLoop ********************************
SUO:
repeat
  
  menu set c1 Scanning.....
  
  if C in #charStatus && #targCurs = 0 && #lliftedKind = 0
  {
    menu set c1 Drinking CURE Potion
    gosub DoIt NUF NONE ; %1=NUF %2=NONE
  }
  
  if #hits < %healpotHP && #sCnt > %timer_pot_heal  && #targCurs = 0 && #lliftedKind = 0
  {
    menu set c1 Drinking HEAL Potion
    gosub DoIt UUF NONE ; %1=UUF %2=NONE
    set %timer_pot_heal ( #sCnt + 10 )
  }
  wait 5
  
  onhotkey %bandage_hotkey
  {
    if #targCurs = 0 && #lliftedKind = 0
    {
      menu set c1 Applying BANDAGE
      gosub DoIt ZJF SELF ; %1=ZJF %2=SELF
    }
  }
  
until #CharGhost = YES
while #CharGhost = YES
  wait 0
GoTo SUO

;************************ Subs ***********************************
; %1 - Item TYPE to use. NUF=Cure Pot, UUF=Heal Pot, ZJF=Bandage
; %2 - Target. SELF to target self, all other will skip targetting
sub DoIt
  namespace push
  namespace local DIT ; short for DrinkIT
  wait 5
  findItem %1 C_ , #backpackID
  if #findKind = -1
  {
    menu set c1 Item NOT FOUND
    return
  }
  set #lobjectID #findID
  set #ltargetKind 1
  event macro 17 0
  if %2 = SELF
  {
    target 3s
    event macro 23 0
  }
  namespace clear
  namespace pop
return

;************************ Menu ***********************************
;--------- EasyUO Menu Designer Code Begin ---------
sub showEUOMenu1
  menu Clear
  menu Window Title Cerv's P & B %ver
  menu Window Color Lime
  menu Window Size 207 27
  menu Font Transparent #true
  menu Font Align Right
  menu Font Name MS Sans Serif
  menu Font Size 8
  menu Font Style
  menu Font Color WindowText
  menu Font Transparent #false
  menu Font Align Left
  menu Font BGColor Red
  menu Text c1 5 5 -
  menu Show 421 270
return
;--------- EasyUO Menu Designer Code End ---------

I added a little something to the setup also.... see if you can spot it. Remember to always keep your versions straight. If you make a change, no matter how simple, you should make a comment and change the date. You might not always need a new version number, but it's not a bad idea to change the version with each change. Keep copies of the older versions around, in case you break something and need to revert.

Well, there it is squeeky... hope you enjoy!
« Last Edit: September 20, 2011, 06:30:33 AM 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 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 7 - Status Menu for P&B
« Reply #1 on: September 20, 2011, 06:31:08 AM »
+1
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: