mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
trivia hint #169572 25/01/07 05:05 PM
Joined: Oct 2006
Posts: 342
L
learn3r Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Oct 2006
Posts: 342
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...



learn learn learn
Re: trivia hint [Re: learn3r] #169588 25/01/07 07:25 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
Re: trivia hint [Re: Riamus2] #169605 26/01/07 02:38 AM
Joined: Oct 2006
Posts: 342
L
learn3r Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Oct 2006
Posts: 342
How to make this trivia hint gives only the vowels?


learn learn learn
Re: trivia hint [Re: learn3r] #169611 26/01/07 03:52 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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


Invision Support
#Invision on irc.irchighway.net
Re: trivia hint [Re: Riamus2] #169649 26/01/07 03:13 PM
Joined: Oct 2006
Posts: 342
L
learn3r Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Oct 2006
Posts: 342
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


learn learn learn
Re: trivia hint [Re: learn3r] #169653 26/01/07 03:52 PM
Joined: Jan 2007
Posts: 8
H
HassanAbbas Offline
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
H
Joined: Jan 2007
Posts: 8
goood smile


Hey Join US At /server irc.7chatlovers.net And Join #allnitecafe
Re: trivia hint [Re: learn3r] #169683 26/01/07 10:17 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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,*)


Invision Support
#Invision on irc.irchighway.net
Re: trivia hint [Re: Riamus2] #169684 26/01/07 10:19 PM
Joined: Jan 2007
Posts: 280
DuXxXieJ Offline
Fjord artisan
Offline
Fjord artisan
Joined: Jan 2007
Posts: 280
It doesn't work at mine mIRC....

Something is wrong, i think.


Squee whenever a squee squee's. Squee whenever a squee does not squee.
Re: trivia hint [Re: DuXxXieJ] #169690 26/01/07 10:33 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Are you even using his script? His full script isn't displayed here. This is just part of it.


Invision Support
#Invision on irc.irchighway.net
Re: trivia hint [Re: Riamus2] #169705 27/01/07 12:05 AM
Joined: Oct 2006
Posts: 342
L
learn3r Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Oct 2006
Posts: 342
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


learn learn learn
Re: trivia hint [Re: learn3r] #169711 27/01/07 12:48 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
Re: trivia hint [Re: Riamus2] #169745 27/01/07 05:24 PM
Joined: Oct 2006
Posts: 342
L
learn3r Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Oct 2006
Posts: 342
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


learn learn learn
Re: trivia hint [Re: learn3r] #169749 27/01/07 06:31 PM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
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

Re: trivia hint [Re: learn3r] #169756 27/01/07 07:19 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
Re: trivia hint [Re: genius_at_work] #169761 27/01/07 07:29 PM
Joined: Oct 2006
Posts: 342
L
learn3r Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Oct 2006
Posts: 342
il w8


learn learn learn
Re: trivia hint [Re: Riamus2] #169762 27/01/07 07:29 PM
Joined: Oct 2006
Posts: 342
L
learn3r Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Oct 2006
Posts: 342
on numbers i want to give only the 1st character 1st 2nd 3rd hint


learn learn learn
Re: trivia hint [Re: learn3r] #169764 27/01/07 07:34 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
Re: trivia hint [Re: learn3r] #169878 30/01/07 05:07 AM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
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

Re: trivia hint [Re: genius_at_work] #169904 30/01/07 03:39 PM
Joined: Oct 2006
Posts: 342
L
learn3r Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Oct 2006
Posts: 342
don't know how to use this... blush


learn learn learn
Re: trivia hint [Re: learn3r] #169943 31/01/07 03:42 AM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
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

Page 1 of 2 1 2