mIRC Home    About    Download    Register    News    Help

Print Thread
#272873 12/08/24 05:20 AM
Joined: Dec 2022
Posts: 15
M
Pikka bird
OP Offline
Pikka bird
M
Joined: Dec 2022
Posts: 15
The documentation states:

Quote
For more flexibility, you can also use Variables in place of both the matchtext and the channel parameters.

on 1:TEXT:%matchtext:%channel:/msg $nick You just said $1- on channel %channel

The value of %matchtext will be matched against whatever text the user sends, and the value of %channel will be matched against the channel to which the message was sent.

Although not explicitly stated, I imagine that the variables mentioned are global variables (the one in the ‘Variables’ tab).

However, the script I'm writing I have variables with dynamic names, like this:

Code
set %prefix_ $+ $chan my Value

Is it possible to create a event trigger like this?

Code
on *:TEXT:%prefix_ [ $+ [ $chan ] ]:#: { ... } 

Joined: Jul 2006
Posts: 4,180
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,180
You can use $() around the matchtext (which is the same as $eval) to create any dynamic parameter you want.

The problem is that $chan is unfortunately not set during the evaluation of the matchtext nor it is set in the channel evaluation part, you would have to use a filter such as * and then use /if to check your variable.

if ($($+(%,prefix_,$chan),2) == $1-) echo -ag just said $v1



@khaled, is it a bug that $chan is not set there?

Code
on *:TEXT:$($callme(1,$chan)):$($callme(2,$chan)): { msg $chan ok $!matchkey: $matchkey }
alias callme echo -ag !! $1- | return #mircscripting
Quote
!! 1
!! 2


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jan 2012
Posts: 323
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 323
Most likely you won't be able to do it the way shown in your example, but I have created another way to solve your idea.

You can try using this variant of the script code:
Code
on *:TEXT:*:#:{
  if ($var($+(prefix_,$chan),1).value isin $1-) {
    msg $chan Found dynamic variable with name04 $+(%,prefix_,$chan) and value:04 $v1
  }
}

Note: This script will only run if you have a global dynamic variable saved in your mIRC (for bot) with the name of the channel where a message was sent by another user whose text matches the text value of this variable.

For example, enter this command in your bot's #test channel window: //set -s %prefix_ $+ $chan New trigger text

This will create a global dynamic variable with the channel name "%prefix_#test" and the value "New trigger text" as an event trigger.


Screenshot of testing the script:

    [Linked Image from i.postimg.cc]


🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples

Link Copied to Clipboard