mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Apr 2018
Posts: 83
E
Babel fish
OP Offline
Babel fish
E
Joined: Apr 2018
Posts: 83
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.

Notes:
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).

Code:
; 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.

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
you can delay the execution by using $! instead of just $

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

Joined: Apr 2018
Posts: 83
E
Babel fish
OP Offline
Babel fish
E
Joined: Apr 2018
Posts: 83
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


Link Copied to Clipboard