mIRC Homepage

ON that changes based on variable

Posted By: FoxInABox

ON that changes based on variable - 20/10/16 09:42 PM

I have a variable in vars.ini that is:
Code:
%#channel.currency_name gem

and I'm trying to make it so that the events related to the currency change depending on that:

Just so each channel can name their currency differently

Code:
alias -l curr return $($+(%,$chan,.,currency_name),2)

; This does return gem as it should

; $(! $+ $($curr) $+ s)
; does return !gems as it should .. but the chat only reacts
; to !s .. the gem part is not included

ON *:TEXT:$(! $+ $($curr) $+ s):#:{
  var %topic $+($chan,.,$nick)
  msg # $nick has $readini(Points.ini,%topic,Points) total $curr $+ s.
}

Am I going about this the wrong way?
Posted By: FoxInABox

Re: ON that changes based on variable - 27/10/16 02:19 AM

I found out that I could not use a dynamic variable as the search text in ON (from what I understand), but it is fine to compare things to it in if statements, so I managed to make a workaround:
Code:
; OP can change currency name for this channel or clear it without using an argument
ON *:TEXT:!currency*:#:{
  if ( $nick !isop $chan ) halt
  if ( $2 == $null ) {
    unset %currency_name. [ $+ [ $chan ] ]
    echo -a currency reset to default
  }
  else {
    set %currency_name. [ $+ [ $chan ] ] $2
    echo -a currency set to $2
  }
}

;just so you can get the currency name with $curr at any time
alias -l curr return %currency_name. [ $+ [ $chan ] ]

ON *:text:*:#:{
  ;get the point name for this channel, if $null then use the default "points"
  var %curr $curr
  if ( %curr == %null ) %curr = points
  
  if ( $( ! $+ %curr ) == $1 ) {

    if ( $2 == $null ) {
      msg $chan $nick got $lookUpPoints %curr
    }
    elseif ( ($2 == add) || ($2 == remove) ) {
      ;command <add|remove> user value
      $pointsValue( $2 , $3 , $4 )
    }
  }
}


Just posting the code in case someone else want to do something like this (if there is some better way to do this then please tell)
Posted By: splinny

Re: ON that changes based on variable - 27/10/16 02:27 AM

Code:
%null
prob $null.
Why not to make a single on-text instead of 2 or more?
Code:
isop
can cause some errors at Twitch.
Posted By: FoxInABox

Re: ON that changes based on variable - 27/10/16 04:34 PM

Thanks, will fix that typo right away.

Well, I could merge all of them, making a lot of if checks for the strings, but I don't know if it is better or worse, have not seen anyone else that have taken that approach so far, so why should I merge them? .. I only had a few commands that needed to check for the currency name.

Hm, isop seem to work fine so far, but to be safe I guess I can swap it out with:
Code:
$nick == $right( $chan , -1 )


I'm a bit new to this, but I got a goal that I'm working towards ^^ so any input is much appreciated.

EDIT: seems that if one ON text triggers, then none of the below ON text's will do so..
Posted By: splinny

Re: ON that changes based on variable - 28/10/16 02:18 AM

Code:
$right( $chan , -1 )
is only for streamer, while "isop" was for moderators too. Check this: https://discuss.dev.twitch.tv/t/twitch-ircv3-tags/4450
© 2020 mIRC Discussion Forums