mIRC Homepage
Posted By: learn3r trivia hint - 25/01/07 05:05 PM
Code:
alias trivhint {
  var %a, %b = $regsub($1,/(?<=\S{ $+ $2})\S/g,$replace($$3,\,\\,$,\$),%a)
  return %a
}

set %trivia.h1 $trivhint(%trivia.a,2,*)
set %trivia.h2 $trivhint(%trivia.a,3,*)
set %trivia.h3 $trivhint(%trivia.a,4,*)

this makes like this

1stHint: io******
2ndHint: iop*****
3rdHint: ioph****

But when the answwer is number it will do this

1stHint: 32
2ndHint: 32
3rdHint: 32

How to make this gives a hint randomly letters on the answer and also on numbers it wont show some hint

and if the letters on the answer only have 4 or less it shows all the answer...

Posted By: Riamus2 Re: trivia hint - 25/01/07 07:25 PM
Just put a check in...

Code:
if (%trivia.h1 !isnum) { set %trivia.h1 $trivhint(%trivia.a,2,*) }
else set %trivia.h1 $trivhint(%trivia.a,0,*)


That assumes 0 will work with your alias... I didn't test it. Personally, I prefer hints that give vowels, but that's up to you.

Note that instead of checking if it's a number, you could also check the $len instead. That will help for short answers that aren't numbers.
Posted By: learn3r Re: trivia hint - 26/01/07 02:38 AM
How to make this trivia hint gives only the vowels?
Posted By: Riamus2 Re: trivia hint - 26/01/07 03:52 AM
I don't know the regex method (which would be easier), but $replace is easy.

hint2 or hint3 could simply be:
Code:
$replace(%answer,b,*,c,*,d,*,f,*,g,*,h,*,j,*,k,*,l,*,m,*,n,*,p,*,q,*,r,*,s,*,t,*,v,*,w,*,x,*,z,*)



Yeah, it looks bad, but I don't know regex to do it that way for you. It does work, though. To leave your first hint(s), since they are the beginning letters, you can do:

Code:
$left(%answer,3) $+ $replace($right(%answer,-3),b,*,c,*,d,*,f,*,g,*,h,*,j,*,k,*,l,*,m,*,n,*,p,*,q,*,r,*,s,*,t,*,v,*,w,*,x,*,z,*)



That will show the first 3 characters and all of the vowels. Again, it might not look nice, but it works. smile
Posted By: learn3r Re: trivia hint - 26/01/07 03:13 PM
Code:
    if (%trivia.h1 !isnum) {
      set %trivia.h1 $trivhint(%trivia.a,1,*)
      set %trivia.h3 $left(%trivia.a,3) $+ $replace($right(%trivia.a,-3),b,*,c,*,d,*,f,*,g,*,h,*,j,*,k,*,l,*,m,*,n,*,p,*,q,*,r,*,s,*,t,*,v,*,w,*,x,*,z,*)
      set %trivia.h2 $replace(%trivia.a,b,*,c,*,d,*,f,*,g,*,h,*,j,*,k,*,l,*,m,*,n,*,p,*,q,*,r,*,s,*,t,*,v,*,w,*,x,*,z,*)
    }
    else {
      set %trivia.h1 $trivhint(%trivia.a,0,*)
      set %trivia.h2 $trivhint(%trivia.a,0,*)
      set %trivia.h3 $trivhint(%trivia.a,0,*)
    }



using this but doesnt seem to work on numbers
Posted By: HassanAbbas Re: trivia hint - 26/01/07 03:52 PM
goood smile
Posted By: Riamus2 Re: trivia hint - 26/01/07 10:17 PM
Sorry, forgot to include numbers. Just put those into the $replace as well. Contine from z,* :

z,*,1,*,2,*,3,*,4,*,5,*,6,*,7,*,8,*,9,*)
Posted By: DuXxXieJ Re: trivia hint - 26/01/07 10:19 PM
It doesn't work at mine mIRC....

Something is wrong, i think.
Posted By: Riamus2 Re: trivia hint - 26/01/07 10:33 PM
Are you even using his script? His full script isn't displayed here. This is just part of it.
Posted By: learn3r Re: trivia hint - 27/01/07 12:05 AM
Code:
    if (%trivia.h1 isnum) {
      set %trivia.h1 $trivhint(%trivia.a,1,*)
      set %trivia.h2 $trivhint(%trivia.a,1,*)
      set %trivia.h3 $trivhint(%trivia.a,2,*)
    }
    else {
      set %trivia.h1 $trivhint(%trivia.a,1,*)
      set %trivia.h2 $replace(%trivia.a,b,*,c,*,d,*,f,*,g,*,h,*,j,*,k,*,l,*,m,*,n,*,p,*,q,*,r,*,s,*,t,*,v,*,w,*,x,*,z,*,1,*,2,*,3,*,4,*,5,*,6,*,7,*,8,*,9,*,0,*)
      set %trivia.h3 $left(%trivia.a,3) $+ $replace($right(%trivia.a,-3),b,*,c,*,d,*,f,*,g,*,h,*,j,*,k,*,l,*,m,*,n,*,p,*,q,*,r,*,s,*,t,*,v,*,w,*,x,*,z,*,1,*,2,*,3,*,4,*,5,*,6,*,7,*,8,*,9,*,0,*)
    }


This is what the code looks like now but it's still returning the usual hints and doesnt return when its number
Posted By: Riamus2 Re: trivia hint - 27/01/07 12:48 AM
How about changing your $trivhint alias?

Code:
alias trivhint {
  ; Use a var to save some space
  var %replace = b,*,c,*,d,*,f,*,g,*,h,*,j,*,k,*,l,*,m,*,n,*,p,*,q,*,r,*,s,*,t,*,v,*,w,*,x,*,z,*,1,*,2,*,3,*,4,*,5,*,6,*,7,*,8,*,9,*,0,*
  ; First letter only (first hint and also if $len < 4)
  if ($2 == 1 || $len($1) < 4) { return $left($1,1) $+ $right($replace($1, [ %replace ] ,a,*,e,*,i,*,o,*,u,*,y,*),-1)
  ; First 3 letters if $len > 3, else only display first character
  elseif ($2 == 2) { return $left($1,3) $+ $right($replace($1,% [ %replace ] ,a,*,e,*,i,*,o,*,u,*,y,*),-3)
  ; Display the first 3 characters (shown from the first hints) and also all vowels.
  elseif ($2 == 3) { return $left($1,3) $+ $right($replace($1,% [ %replace ] ),-3)
  else return ERROR: Incorrect hint number.
}


Then, to display the hints, use:
Code:
  msg $chan $trivhint(%trivia.a,%hint_number)


Replace %hint_number with whatever you use to know what hint you're on, or just put 1, 2, or 3 in there if you just run 3 timers.

You can change msg $chan to something else if you don't want to use that.

The alias will display hints like this:

Answer: Scripting is fun
Hint 1: S******** ** ***
Hint 2: Scr****** ** ***
Hint 3: Scri**i** i* f*n

If there are fewer than 4 characters in the answer, then it will only show the first character for all 3 hints...

Answer: Fun
Hint 1: F**
Hint 2: F**
Hint 3: F**

This is true for any answer... numerical or alphabetical or mixed.

If you want to do something else for hints, you can change how those are set up, or just ask and I can help... just show me how you want it.

And, again, regex could probably simplify that, but I just don't know it well enough.
Posted By: learn3r Re: trivia hint - 27/01/07 05:24 PM
Code:
alias trivhint {
  ; Use a var to save some space
  var %replace = b,*,c,*,d,*,f,*,g,*,h,*,j,*,k,*,l,*,m,*,n,*,p,*,q,*,r,*,s,*,t,*,v,*,w,*,x,*,z,*,1,*,2,*,3,*,4,*,5,*,6,*,7,*,8,*,9,*,0,*
  ; First letter only (first hint and also if $len < 4)
  if ($2 == 1 || $len($1) < 4) { return $left($1,1) $+ $right($replace($1, [ %replace ] ,a,*,e,*,i,*,o,*,u,*,y,*),-1) }
  ; First 3 letters if $len > 3, else only display first character
  elseif ($2 == 2) { return $left($1,3) $+ $right($replace($1,% [ %replace ] ,a,*,e,*,i,*,o,*,u,*,y,*),-3) }
  ; Display the first 3 characters (shown from the first hints) and also all vowels.
  elseif ($2 == 3) { return $left($1,3) $+ $right($replace($1,% [ %replace ] ),-3) }
  else return ERROR: Incorrect hint number.
}


still gives me 3 first letters on numbers and 4 letters answers
Posted By: genius_at_work Re: trivia hint - 27/01/07 06:31 PM
My trivia bot (PERL based) simply limits the length that users can ask for hints. If the question is shorter than 4 chars, hints are not available.

And just so you know, the method my bot uses arrays and hashes to allow hints like this:

--- ------ -- ----
T-- ------ -- ----
T-- a----- -- ----
T-- a----- i- ----
T-- a----- i- h---
Th- a----- i- h---

!vowel e

The a---e- i- he-e

etc...

If I feel ambitious today, I may try to convert it to mIRC script.

-genius_at_work
Posted By: Riamus2 Re: trivia hint - 27/01/07 07:19 PM
Originally Posted By: Riamus2
If there are fewer than 4 characters in the answer, then it will only show the first character for all 3 hints


I *did* say it would do that. If you want it to *not* give the first 3 characters on a 4 letter word, change the "< 4" part of the script to something larger and then it will only show the first character for words smaller than whatever number you entered.

As far as numbers, I still don't know what you want it to do. If you want numbers treated differently, then please give an example (or multiple examples) for how you want them to be displayed.
Posted By: learn3r Re: trivia hint - 27/01/07 07:29 PM
il w8
Posted By: learn3r Re: trivia hint - 27/01/07 07:29 PM
on numbers i want to give only the 1st character 1st 2nd 3rd hint
Posted By: Riamus2 Re: trivia hint - 27/01/07 07:34 PM
Code:
  ; First letter only (first hint and also if $len < 4 and also for numbers)
  if ($2 == 1 || $len($1) < 4 || $1 isnum) { return $left($1,1) $+ $right($replace($1, [ %replace ] ,a,*,e,*,i,*,o,*,u,*,y,*),-1) }


Change that part.

Again, that 4 is what you need to change if you want it to only give the first letter for words greater than 3.

As it is now, you have this:
Answer: Fun
Hint1-3: F**

Answer: Test
Hint1: T***
Hint2-3: Tes*

Answer: Three
Hint1: T****
Hint2: Thr**
Hint3: Three

If you want, you can increase 4 to 5 and then all 4 letter words will only have a 1 character hint for all hints. Increase to 6 and all 5 letter words will only get 1 character hints. Just decide what you want.
Posted By: genius_at_work Re: trivia hint - 30/01/07 05:07 AM
Here is the code I came up with. The code from my bot wasn't compatible with mIRC coding language, so I made this version that does the same thing:

Code:
alias disphint {
  ;$1 = Hint count, $2 = Hidden Character, $3- = Hint string

  tokenize 32 $1-

  var %nHintNum = $1
  var %cHintChar = $2
  var %sAnswer = $3-

  if (%nHintNum !isnum) { echo 4 -s Invalid hint count | return }
  if ($regex(%cHintChar,/^([a-z0-9º¬]|$)/i)) { echo 4 -s Invalid hint hidden character | return }
  if (%sAnswer == $null) { echo 4 -s Invalid hint string | return }

  var %sClue = %sAnswer
  var %nLength = $len(%sAnswer)

  %sClue = $regsubex(%sClue,/[^a-zA-Z0-9 ]/g,º)
  %sClue = $regsubex(%sClue,/ /g,¬)
  %sClue = $regsubex(%sClue,/[a-zA-Z0-9]/g,%cHintChar)

  if ($hget(hint)) hfree hint
  hmake hint 2

  ;;; Create hash table and insert vowels
  var %i = 0
  while (%i < %nLength) {
    inc %i
    hadd hint $+(a.,%i) $mid(%sAnswer,%i,1)
    hadd hint $+(c.,%i) $mid(%sClue,%i,1)
    if ($hget(hint,$+(a.,%i)) isin %sVowels) {
      hadd hint $+(c.,%i) $mid(%sAnswer,%i,1)
    }
  }

  hadd hint $+(p.1) 1
  var %j = 0, %nCurPart = 1
  while (%j < %nLength) {
    inc %j
    if ($hget(hint,$+(c.,%j)) != ¬) continue
    inc %j
    if (%j <= %nLength) {
      inc %nCurPart
      hadd hint $+(p.,%nCurPart) %j
    }
  }

  ;;; Calculate hint order
  var %nClues = $count(%sClue,%cHintChar)
  var %n = 0, %m = 0, %L = 1, %p, %h

  while (%L) {
    inc %n

    %p = $hget(hint,$+(p.,%n))
    %h = $hget(hint,$+(c.,%p))

    if (%p > %nLength) {
      %n = 0
      continue
    }
    if (%n > %nCurPart) {
      %n = 0
    }
    if (%m >= %nClues) {
      %L = 0
      continue
    }

    if (%h == %cHintChar) {
      inc %m
      hadd hint $+(h.,%m) %p
      hinc hint $+(p.,%n) 1
    }
    elseif (%h == º) {
      hinc hint $+(p.,%n) 1
      dec %n
      continue
    }
    elseif (%h == ¬) {
      continue
    }
    else {
      hinc hint $+(p.,%n) 1
    }
  }

  var %c, %i = 0
  while (%i < %nHintNum) {
    inc %i
    %c = $hget(hint,$+(h.,%i))
    hadd hint $+(c.,%c) $hget(hint,$+(a.,%c))
  }

  ;;; Build string from hash table values
  var %sClue, %h, %s = 0
  var %i = 0
  while (%i < %nLength) {
    inc %i
    %h = $hget(hint,$+(c.,%i))
    if (%h == ¬) { 
      %s = 1
      continue
    }
    else {
      if (%h == º) %h = $hget(hint,$+(a.,%i))
      %sClue = %sClue $+ $iif(%s,$chr(32)) $+ %h
      %s = 0
    }
  }

  if ($isid) return %sClue
  else echo -a %sClue
}


Usage: $disphint(<num>,<char>,<answer>)
or: /disphint <num> <char> <answer>

<num> = number of characters to show (0 shows no hint characters)
<char> = character to 'cover' hidden chars (can't be: º ¬ a-z 0-9)
<answer> = answer string (can contain any character including spaces, commas and º ¬)


The code also supports a 'vowel' feature. If you populate the %sVowels global variable with aeiou (or any other letter/number) all of those characters present in the answer will be shown.

The code doesn't hide special characters (commas, question marks, etc) (anything not a-z 0-9). If you want to limit the length of answers which can be hinted, your code should do that before allowing the hint to be shown.

Post questions/comments here.

-genius_at_work
Posted By: learn3r Re: trivia hint - 30/01/07 03:39 PM
don't know how to use this... blush
Posted By: genius_at_work Re: trivia hint - 31/01/07 03:42 AM
I don't know how you manage the questions and answers on your trivia bot. You need to figure out how to get the answer into a variable. Then you need to have a !hint command which does this:

Code:
set %trivia.hint 0
set %trivia.char -
msg %trivia.channel Hint: $disphint(%trivia.hint,%trivia.char,%trivia.answer)


Then, you need to start a timer which will call this alias after some length of time:

Code:
inc %trivia.hint 1
msg %trivia.channel Hint: $disphint(%trivia.hint,%trivia.char,%trivia.answer)


-genius_at_work
Posted By: Riamus2 Re: trivia hint - 31/01/07 02:26 PM
But does he want to use a !hint command? From the description, it sounds like he wants it automatic after a given time (which I much prefer to people continually typing !hint all of the time).
Posted By: genius_at_work Re: trivia hint - 01/02/07 02:10 AM
I'm just going by how my trivia bot does things. He's welcome to set it up however he likes.

-genius_at_work
© mIRC Discussion Forums