Originally Posted By: blessing
Originally Posted By: Teksura

I tried doing something simple like %polloptions $+ $chan in the hopes that I'd be able to use %polloption#channelname as a variable, but that just seems to give me strange results when I try to actually call the variable. It'll generally just look at %polloptions and then just add the channel name to the end of whatever is at %polloptions.

Does anyone know how I can resolve that issue?

You can use $(text,N) identifier.
To understand this properly, you might want to try this to see how $(text,N) works.

//var %poll $+ $me hello world | echo -agt N = 0 is $($+(%,poll,$me),0) | echo -agt N = 1 is $($+(%,poll,$me),1) | echo -agt N = 2 is $($+(%,poll,$me),2)

$(var,0) will return plain text.
$(var,1) will return var itself.
$(var,2) will return value of var.



Ahh hah! I knew there had to be something. Thanks, that's exactly what I needed.


updated code for the OP is this:

Code:

;************************************************
;********************** POLL ********************
;************************************************


on *:TEXT:!poll *:#: {
  if (($nick !isop $chan) && ($$2 != results)) {
    msg $chan Only mods may use this feature.
  }
  else {
    ; *********
    ; OPEN POLL
    ; *********
    if ($$2 == open) {
      unset $($+(%,polloptions,$chan),1)
      unset $($+(%,pollvotes,$chan),1)
      unset $($+(%,hasvoted,$chan),1)
      set $($+(%,polloptions,$chan),1) $3-
      var %numberofoptions $numtok($3-,124)
      while ( %numberofoptions > 0 ) {
        dec %numberofoptions
        set $($+(%,pollvotes,$chan),1) $($+(%,pollvotes,$chan),2) 0
      }
      var %number $numtok($($+(%,polloptions,$chan),2),124)
      while (%number > 0) {
        if (%number == $numtok($($+(%,polloptions,$chan),2),124)) {
          var %finalresults %number - $gettok($($+(%,polloptions,$chan),2),%number,124) %finalresults
        }
        else {
          var %finalresults %number - $gettok($($+(%,polloptions,$chan),2),%number,124) || %finalresults
        }
        dec %number
      }
      msg $chan A new poll has been opened: %finalresults
    }

    ; ************
    ; POLL RESULTS
    ; ************
    elseif ($$2 == results) {
      if ($($+(%,polloptions,$chan),2) != $null) {
        msg $chan Current Results are: $pollresults
      }
      else {
        msg $chan Results for previous poll are: $($+(%,oldresults,$chan),2)
      }
    }
    ; **********
    ; POLL CLOSE
    ; **********
    elseif ($$2 == close) {
      msg $chan $nick has closed the poll! Results are: $pollresults
      set $($+(%,oldresults,$chan),1) $pollresults      
      unset $($+(%,polloptions,$chan),1)
      unset $($+(%,pollvotes,$chan),1)
      unset $($+(%,hasvoted,$chan),1)
    }
  }
}



alias pollresults {
  var %number $numtok($($+(%,polloptions,$chan),2),124)
  while (%number > 0) {
    if (%number == $numtok($($+(%,polloptions,$chan),2),124)) {
      var %finalresults $gettok($($+(%,polloptions,$chan),2),%number,124) : $gettok($($+(%,pollvotes,$chan),2),%number,32) votes %finalresults
    }
    else {
      var %finalresults $gettok($($+(%,polloptions,$chan),2),%number,124) $+ : $gettok($($+(%,pollvotes,$chan),2),%number,32) votes || %finalresults
    }
    dec %number
  }
  return %finalresults
}





on *:TEXT:!vote *:#: {
  if ( $($+(%,polloptions,$chan),2) == $null) {
    msg $chan There is no open poll to vote on!
  }
  elseif ($nick isin $($+(%,hasvoted,$chan),2)) {
    msg $chan $nick $+ , you have already voted in this poll!
  }
  elseif ($$2 !isnum 1 - $numtok($($+(%,pollvotes,$chan),2),32)) {
    msg $chan $$2- is not a valid poll option! 
  }
  else {
    set $($+(%,hasvoted,$chan),1) $($+(%,hasvoted,$chan),2) $nick
    var %voteupdate $gettok($($+(%,pollvotes,$chan),2),$$2,32)
    inc %voteupdate
    set $($+(%,pollvotes,$chan),1) $puttok($($+(%,pollvotes,$chan),2),%voteupdate,$$2,32)
    msg $chan $nick has voted for option $$2 $+ : $gettok($($+(%,polloptions,$chan),2),$$2,124)
  }
}



It now tracks polls for each channel independent of each other (as opposed to the original code which had 1 poll for everything).