One hotkey, two functions? (pause/play)

Discussion about the technical aspects of scripting. Ask about all issues involving your freelance projects here.
Locked
User avatar
Devlin
Legendary Scribe
Reactions:
Posts: 659
Joined: Thu Mar 18, 2010 12:50 pm

One hotkey, two functions? (pause/play)

Post by Devlin »

Currently Rearmer can pause/play but involves two hotkeys. I'd like to make it one hotkey that can toggle back and forth. Here's what the code is currently. I keep having glimpses of ideas that fade out so any suggestions would be lovely.

Code: Select all

          onhotkey %Hold
          {
          set %T_Hold #time 
          set %Sub2 CAOff
          }
          onhotkey %Play
          {
          set %Sub2 CAOn
          event sysmessage Casting has been resumed. Hit %hold to Pause.
          }
Resident Wiki Editor/Village Idiot

EasyUO Scripts
ReArmer
ReArmer (Old Version)
ReReader
Runebook Copier
---------------------------------------------
Combat Focus Guide (Godmode Formula)
User avatar
Xavian
Legendary Scribe
Reactions:
Posts: 485
Joined: Sun Dec 25, 2011 4:09 pm

Re: One hotkey, two functions? (pause/play)

Post by Xavian »

I'm not at my main comp to see for sure, but this is the type of pause my scripts use.

I use this section in the main code where I want the ability to pause:

Code: Select all

onhotkey %Pause
{
  set %T_Hold #time 
  set %Sub2 CAOff
  gosub Pause
}
Resume:
And this is just added at the end:

Code: Select all

Sub Pause
{
  onhotkey %Pause
  {
    set %Sub2 CAOn
    event sysmessage Casting has been resumed. Hit %hold to Pause.
    Goto Resume
  }
  gosub Pause
}
Dramoor
Legendary Scribe
Reactions:
Posts: 450
Joined: Wed Feb 23, 2011 7:37 pm

Re: One hotkey, two functions? (pause/play)

Post by Dramoor »

Or just add a pause menu Button to click. Is easier to click a button and wait for it to hit, than to sit and hold a hotkey waiting for that line to go.

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    menu clear                                                 ;
    set #menubutton none                                       ;
    menu window size 50 40                                     ;
    menu button pause 0 0 100 40 Pause                         ;
    menu show                                                  ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; A sub that just checks if you pushed pause                   ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
sub checkPause
{
 if #menubutton = pause
 {
  event exmsg #charid 3 0 Paused
  set #menubutton none
  while #true
  {
   wait 10
   if #menubutton = pause
   {
    event exmsg #charid 3 0 Resuming
    set #menubutton none
    return
   }
  }
 }
 return
}
User avatar
Xavian
Legendary Scribe
Reactions:
Posts: 485
Joined: Sun Dec 25, 2011 4:09 pm

Re: One hotkey, two functions? (pause/play)

Post by Xavian »

Far nicer that way. I haven't done a whole lot with windows other than changing a couple things in a previous script, but I may have to learn
Dramoor
Legendary Scribe
Reactions:
Posts: 450
Joined: Wed Feb 23, 2011 7:37 pm

Re: One hotkey, two functions? (pause/play)

Post by Dramoor »

Yeah menus are fun and with some things can be a lot easier than using a hotkey, since you have to wait for it to recognize the hotkey, the button stays pushed until next push so it will get recognized on its own. And yeah Menus are fun, I have a nice menu I wrote too that will pm a large group of players whatever you put in the field to say then hit Send and it auto sends that message to whoever u have on the list for it to send to. Far easier to call out a champ that way, as you have to wait for them to send....but you do not have to type [pm name message every time.
User avatar
Xavian
Legendary Scribe
Reactions:
Posts: 485
Joined: Sun Dec 25, 2011 4:09 pm

Re: One hotkey, two functions? (pause/play)

Post by Xavian »

I completely agree. I actually added menus to a couple of my scripts last night and learned a bit about them. I am gonna have to do that more often. I like that idea of the PM script. Certainly could be very useful, I hate sending a PM to a bunch of people like that
Locked