mIRC Home    About    Download    Register    News    Help

Topic Options
#265022 - 17/02/19 06:37 PM Help, please, with timer command and an alias
Erasimus Offline
Babel fish

Registered: 26/04/18
Posts: 72
Code is trying to deal with an IdleRPG game, and the idlebot returning to the channel, having been offline.

Issue is that script would have to log-in again, but, after a delay (while the bot sets itself back up).

The bot then compares channel users with the names of logged in users when it went off line and voices those that match. Logged in (to the game) users are voiced (+v).

I therefore have a CheckIfVoiced alias that is called from an On Join event where the joined user is found to be the bot name.

In this case (below) a test alias is set to be almost the same as the on join code but can be triggered by a '/test' command rather than wait for a bot off & online event to happen.

1)code has to deal with more than one irpg game, and thus I have to pass the game number as a parameter.

2)The irpg bots and channel names are stored in 2 variables as tokenised lists (csv).

; Check if you have been voiced in the targetted IRPG channel
; $1 is the game number to check (currently 1 or 2)
Alias CheckIfVoiced {
  var %ChannelName = $gettok(%PTMIRPGChannels, $1, 44)
  if ($me isreg %ChannelName) { $LogIntoIdleRPG($1) }
  else { 
    //echo %PTMALalertmsg -st Currently voiced in %ChannelName - you are already logged-in 

; alias to test if thing operate as hoped. Some variables are set in code rather than being 
; set by an On Join event where the bot name would be used and searched for rather than being explicitely
; coded as in the 'var %Game' line below
Alias Test {
  var %Game = $findtok(%PTMIRPGBots, idlebot , 1, 44)
  var %Bot = $gettok(%PTMIRPGBots, %Game, 44)
  var %Channel = $gettok(%PTMIRPGChannels, %Game, 44)
  var %IRPGWait = 4
  //echo -st Game is %Game : Bot is %Bot : Channel is %Channel
  //echo 2 -st %Bot hath returned unto the  %Channel Realm.
  TimerPIRPGAA 1 %IRPGWait $CheckIfVoiced(%Game)
  //echo -st Finished. Check should happen 4 seconds after this
  ; }

The Timer command evaluates everything on that line when the parser gets to it, resulting in the command being executed then, instead of only after the time period (4 seconds here). It then fails with -
'* /timerpirpgaa: insufficient parameters (line 107 ...'
4 seconds after the /echo -st Finished line.

I did read something about this evaluation issue with timers a while back, but cannot locate that forum-thread/web article/whatever to reference it for ideas.

I suspect the failure at the end is as a result of no longer being within the alias section and %Game (local variable) no longer exists.

How can I deal with thia situation.
Any help would be grovellingly appreciated.

#265023 - 17/02/19 07:51 PM Re: Help, please, with timer command and an alias [Re: Erasimus]
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 1144
you can delay the execution by using $! instead of just $

example: //timer 5 1 echo -a $!asctime

#265024 - 17/02/19 08:45 PM Re: Help, please, with timer command and an alias [Re: maroon]
Erasimus Offline
Babel fish

Registered: 26/04/18
Posts: 72
Big thank you.

I thought I had tried that, but it hadn't worked.

Maybe I tried !$ instead of $!

Anyway. It works perfectly now.

Thanks again (grovel, grovel) smile