8ball (IMPORVED) + dialog and extra

By slub77 on Oct 24, 2009

UPDATED

Simple script:

Commands
S9 what is
S9 where is
S9 can
S9 what color

The menu Includes:
A dialog for all round commands
A menu for each category to: Add, Look up or remove

REMEMBER TO ADD SOME STUFF BEFORE YOU TEST IT OUT

#qq on

on *:TEXT:*:#:{
  if $1-3 == S9 where is {
    :again
    if $readini(Reply.ini, whereis, $rand(1,99)) { msg $chan $2- : $ifmatch } 
  else { goto again } }

  if $1-2 == S9 can {
    :again1
    if $readini(Reply.ini, can, $rand(1,99)) { msg $chan $2- : $ifmatch } 
  else { goto again1 } }

  if $1-3 == S9 what color {
    :again2
    if $readini(Reply.ini, color, $rand(1,99)) { msg $chan $2- : $ifmatch } 
  else { goto again2 } }

  if $1-3 == S9 what is {     
    :again3
    if $readini(Reply.ini, whatis, $rand(1,99)) { msg $chan $2- : $ifmatch } 
  else { goto again3 } }

}

alias -l theloop {
  if $1-3 == S9 where is {
    :again
    if !$readini(Reply.ini, whereis, $rand(1,99)) { goto again } 
  else { return $ifmatch } }
  if $1-2 == S9 can { msg $chan $readini(Reply.ini, can, $rand(1,99)) }
  if $1-3 == S9 what color { msg $chan $readini(Reply.ini, color, $rand(1,99)) }
  if $1-3 == S9 what is { msg $chan $readini(Reply.ini, whatis, $rand(1,99)) }
}

#qq end

#pp off

on *:TEXT:S9 where is*:#:/notice $nick $read(where.txt)
on *:TEXT:S9 can*:#:/notice $nick $read(Can.txt)
on *:TEXT:S9 what colour*:#:/notice $nick $read(colour.txt)
on *:TEXT:S9 what is*:#:/notice $nick $read(what.txt)
on *:TEXT:S9 *:#:/notice $nick $read(can.txt)

#pp end

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

on 6:TEXT:S9off:*:{
  enable #pp 
  disable #qq
  notice $chan S9 will now reply via notice and can be used by soldiers now
}

on *:TEXT:S9 *:#:{
  if ($group(#pp) = off) && ($group(#qq) = off) { /notice $nick Sorry S9 is not on }
  else { halt }
}

on 6:TEXT:S9on:*:{
  enable #qq
  disable #pp
  notice $chan MEssage is now on
}

on 6:TEXT:S9end:*:{
  disable #qq
  disable #pp
  notice $chan S9 is now off
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

menu channel {
  S9 commands
    .The Dialog:/dialog -dm test test

  .Where is
  ..Write where is:$whereis 

  ..Look up:/$ewhereis
  ..Remove line:/$rwhereis

  .Can I
  ..Write Can I:/$can  
  ..Look up:$ecan
  ..Remove line:/$rcan

  .What color
  ..Write what color:/$whatc 
  ..Look up:$ewhatc
  ..Remove line:/$rwhatc

  .What is
  ..Write what is:/$whati
  ..Look up:$ewhati
  ..Remove line:/$rwhati

}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

alias  can {
  echo $?=" Enter the new word that you would like to show when said "
  if !$! { halt }
  else {

    set %x $calc($lines(reply.ini) + 1)
    set %word $!
    set %b 1

    :loop

    if %b == %x {
      writeini reply.ini can %b %word
    echo Written }
    else {
      if $readini(reply.ini, can , %b) {
        inc %b
        goto loop 
      }
      else { 
        writeini reply.ini can %b %word
      echo Written }
    }
  }
}

alias  whatc {
  echo $?=" Enter the new word that you would like to show when said "
  if !$! { halt }
  else {

    set %x $calc($lines(reply.ini) + 1)
    set %word $!
    set %b 1

    :loop

    if %b == %x {
      writeini reply.ini color %b %word
    echo Written }
    else {
      if $readini(reply.ini, color, %b) {
        inc %b
        goto loop 
      }
      else { 
        writeini reply.ini color %b %word
      echo Written }
    }
  }
}

alias  whati {
  echo $?=" Enter the new word that you would like to show when said "
  if !$! { halt }
  else {

    set %x $calc($lines(reply.ini) + 1)
    set %word $!
    set %b 1

    :loop

    if %b == %x {
      writeini reply.ini whatis %b %word
    echo Written }
    else {
      if $readini(reply.ini, whatis, %b) {
        inc %b
        goto loop 
      }
      else { 
        writeini reply.ini whatis %b %word
      echo Written }

    }
  }
}

alias  whereis {
  echo $?=" Enter the new word that you would like to show when said "
  if !$! { halt }
  else {

    set %x $calc($lines(reply.ini) + 1)
    set %word $!
    set %b 1

    :loop

    if %b == %x {
      writeini reply.ini whereis %b %word
    echo Written }
    else {
      if $readini(reply.ini, whereis, %b) {
        inc %b
        goto loop 
      }
      else { 
        writeini reply.ini whereis %b %word
      echo Written }

    }
  }
}

;;;;;;;;;;;;;;;;;;;;

alias ewhereis {
  $?="Enter The number for the Sentance"
  if $readini(reply.ini, whereis, $!) { echo $! : $ifmatch }
  else { echo No record for that number is saved }
}
alias ewhati {
  $?="Enter The number for the Sentance"
  if $readini(reply.ini, whatis, $!) { echo Line $! : $ifmatch }
  else { echo No record for that number is saved }
}
alias ecan {
  $?="Enter The number for the Sentance"
  if $readini(reply.ini, can, $!) { echo $! : $ifmatch }
  else { echo No record for that number is saved }
}
alias ewhatc {
  $?="Enter The number for the Sentance"
  if $readini(reply.ini, color, $!) { echo $! : $ifmatch }
  else { echo No record for that number is saved }
}
;;;;;;;;;;;;;;;;;;;;

alias rwhati {
  $?="Enter The number for the Sentance to remove"
  if $readini(reply.ini, whatis, $!) {
    echo $! removed : $ifmatch
    remini reply.ini whatis $! 
  }
  else { echo No record for that number is saved }
}

alias rwhereis {
  $?="Enter The number for the Sentance"
  if $readini(reply.ini, whereis, $!) { 
    echo $! : $ifmatch 
    remini reply.ini whereis $! 
  }
  else { echo No record for that number is saved }
}

alias ecan {
  $?="Enter The number for the Sentance"
  if $readini(reply.ini, can, $!) { 
    echo $! : $ifmatch
    remini reply.ini can $! 
  }
  else { echo No record for that number is saved }
}
alias ewhatc {
  $?="Enter The number for the Sentance"
  if $readini(reply.ini, color, $!) { 
    echo $! : $ifmatch
    remini reply.ini color $! 
  }
  else { echo No record for that number is saved }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

dialog test {

  title Script Questions

  size -1 -1 110 100

  option dbu

  tab "Where", 1, 5 5 100 90

  tab "What", 2

  tab "Color", 3

  tab "Can", 4

  button  "Add Where", 11, 30 25 50 12, ok tab 1
  button  "Look up", 18, 30 50 50 12, ok tab 1
  button  "Remove", 20, 30 75 50 12, ok tab 1

  button  "Add what", 12, 30 25 50 12, tab 2
  button  "look up", 17, 30 50 50 12, tab 2
  button  "Remove", 21, 30 75 50 12, ok tab 2

  button  "Add color", 13, 30 25 50 12, tab 3
  button  "look up", 16, 30 50 50 12, tab 3
  button  "Remove", 22, 30 75 50 12, ok tab 3

  button  "Add can", 14, 30 25 50 12, tab 4
  button  "Look up", 15, 30 50 50 12, tab 4
  button  "Remove", 23, 30 75 50 12, ok tab 4

}
on 1:dialog:TEST:sclick:20: {
  $rwhereis
}
on 1:dialog:TEST:sclick:21: {
  $rwhati
}
on 1:dialog:TEST:sclick:22: {
  $rwhatc
}
on 1:dialog:TEST:sclick:23: {
  $rcan
}

on 1:dialog:TEST:sclick:11: {
  $whereis
}
on 1:dialog:TEST:sclick:12: {
  $whati
}
on 1:dialog:TEST:sclick:13: {
  $whatc
}
on 1:dialog:TEST:sclick:14: {
  $can
}
on 1:dialog:TEST:sclick:15: {
  $ecan
}
on 1:dialog:TEST:sclick:16: {
  $ewhatc
}
on 1:dialog:TEST:sclick:17: {
  $ewhati
}
on 1:dialog:TEST:sclick:18: {
  $ewhere
}

Comments

Sign in to comment.
slub77   -  Jan 17, 2010

Ok edited now has dialog and has some extra changes, Ini files are used, menu is better, commands are different

 Respond  
slub77   -  Jan 09, 2010

lol wtf, 26 comments i stopped reading after a while because it just became an argument, and my script is just sitting in the background crying at your insults.

And yes i would of probably used ini files, but at the time of making the script, i was crap with ini's (in someways still am) but as this script does the job ok, and all it needs doing is your own personal touch, that you have posted anyways :p.

i hope i don't start an argument between you lot about hask and ini's etc that will go on through about 10 more snippets, all i did is make an 8 ball sniipet :s

 Respond  
Ghost-writer   -  Oct 29, 2009

ahh for frig tarts sake :| somone just remake the code for him, and tbh inis are better that hash tables for long term storage, i dont want to hload the hash table everytime i start and inis are not bad for small things but tbh a variable would be better since its only 1 thing and your only using 4 :|, and tbh setting a variable -e is as good as using hash tables.

 Respond  
Jethro   -  Oct 28, 2009

Oh man guess who's back, back again? Napa! lol How ya been dude....nice seein' ya 'round.

 Respond  
napa182   -  Oct 28, 2009

lmao...... most people that act alike hash is more work dont really understand them so just agree an move on it's just another magic 8 ball script ffs.

old version i made long ago
ask in the form of a question

on $*:text:/^(8ball\s(.+)\?)$/S:#:{ if (!$($+(%,ball8flood),2)) { set -u3 $+(%,ball8flood) $nick | if ($sock(8ball)) .sockclose 8ball | sockopen 8ball pages.cs.wisc.edu 80 | .sockmark 8ball #  } }
on *:SOCKOPEN:8ball: { sockwrite -nt $sockname GET /~craft/8ball.cgi HTTP/1.1 | sockwrite -nt $sockname Host: $+(pages.cs.wisc.edu,$str($crlf,2)) }
on *:SOCKREAD:8ball: {
  var %8ball | sockread %8ball
  if ($regex(%8ball,/<h4>(.+)<\/h4>/)) { msg $sock(8ball).mark 14[04The magic 8ball says:14] $regml(1) | sockclose 8ball }
}
 Respond  
sunslayer   -  Oct 28, 2009

so please don't quote my quoteLOL
id have to agree with Jethro_ tho, in hash table vs. ini, hashes are usually the better choice unless your gonna be using a very large amount of data
for ~10 lines using an ini is a waste imo

 Respond  
Jethro   -  Oct 28, 2009

Dude, don't get vehement over what I quoted you. Why would there be an extra work for using hash tables? Explain.

 Respond  
Aucun50   -  Oct 27, 2009

tbh using a hash table here would just be extra work when an ini file does it fine. Also i was making a point about ini files not hash tables, so please don't quote my quote and change my words around thanks.

 Respond  
Jethro   -  Oct 27, 2009

Does no one care to use ini files anymore?Does no one care about the use of ini files or hash tables anymore?

 Respond  
Aucun50   -  Oct 27, 2009

Does no one care to use ini files anymore?

 Respond  
Jethro   -  Oct 25, 2009

Aucun50, you fogot to mention hash tables.

 Respond  
Aucun50   -  Oct 25, 2009
on *:LOAD:{
write where.txt IN A BIN
write can.txt No you can't
write color.txt RED!
write what.txt A balloon
write where.txt IN A HOUSE
write can.txt maybe..
write color.txt RED!
write what.txt A Dragon with not one not two but 3 heads!
write can.txt SAY PLEASE
}

Does no one care to use ini files anymore? This would be a great time to start. One ini looks better then 4 txt files.

[8ball]
where=IN A BIN,IN A HOUSE
can=No you can't,maybe..,SAY PLEASE
color=RED!,BLUE!
what=A balloon,A Dragon with not one not two but 3 heads!

Throw in a $readini, $r, $numtok and $gettok and your set.

 Respond  
Jethro   -  Oct 25, 2009

Dude...It's like spreading the word about your birthday when it's supposed to be a surprise, right? lol

P.S. But I've given you a 4 for your effort and to make you happy.

 Respond  
slub77   -  Oct 25, 2009

amazing 15 comments (16 noew) yet no one liked or gave it a good rating ;-;

 Respond  
Jethro   -  Oct 25, 2009

I think Ghost-writer is being a funny loudmouth.

 Respond  
xplo   -  Oct 25, 2009

you should put all the files in a folder

on *:load: { mkdir 8balz }

because people have allrady a lot of files in their $mircdir. it would be less annoying when its time for cleaning

 Respond  
slub77   -  Oct 25, 2009

lol

 Respond  
sunslayer   -  Oct 25, 2009

the code is right there?

 Respond  
Ghost-writer   -  Oct 25, 2009

Sunslayer :| you should make that a script!

 Respond  
slub77   -  Oct 25, 2009

lol i aint very good at scokects been meaning to get around to learning how to use em just have not yet also this script was actually smaller and simpler because i used it but when i uploaded it i though i would put more detail in to it aka the menu ect but i was looking through all the 8balls and they are all mainly the same ect that dialog one that was good but other then that they were the same just with different names %var ect lol

 Respond  
Jethro   -  Oct 24, 2009

the /'s arent needed but im glad to see that its different from all other of the 30-40 some 8ball scripts on here <- I hope you don't mean the difference being the slashes. lol Just kidding...

 Respond  
sunslayer   -  Oct 24, 2009

the /'s arent needed but im glad to see that its different from all other of the 30-40 some 8ball scripts on here

another approach could be using a socket to get many more possibilities

alias 8ball {
  sockopen 8ball web.ics.purdue.edu 80
  sockmark 8ball $replace($1-,$chr(32),_)
}
on *:sockopen:8ball: {
  sockwrite -n $sockname GET $+(/~ssanty/cgi-bin/eightball.cgi?question=,$sock($sockname).mark)  HTTP/1.1
  sockwrite -n $sockname HOST: web.ics.purdue.edu $+ $crlf $+ $crlf
}
on *:sockread:8ball: {
  var %a | sockread %a 
  if ($regex(%a,/<center><h1>Magic Eight Ball</h1> <hr /> <img src="/~ssanty/images/\d.gif" alt="(.*?)" /> <hr /> Question:/i)) {
    echo -a $replace($sock($sockname).mark,_,$chr(32)) $+ : $regml(1)
  }
}

that site doesnt have that many responses but its just an example

 Respond  
slub77   -  Oct 24, 2009

i could have swore that i did ;-; rating 2 ;-;

 Respond  
Testor   -  Oct 24, 2009
on @:TEXT:!8m:*:{
  enable #qq
  disable #pp
  msg chan 8 ill reply via msg now
}

You forgot to change to $Chan :3.

 Respond  
slub77   -  Oct 24, 2009

well i though u may like making ur own up :( ok let me edit

EDIT:

ok put some in for you :)

Please rate and like i wana get this one up as all the others are all most the same thing

 Respond  
Ghost-writer   -  Oct 24, 2009
on *:TEXT:!8 where is*:#:/notice $nick $read(where.txt)
on *:TEXT:!8 can*:#:/notice $nick $read(Can.txt)
on *:TEXT:!8 what color*:#:/notice $nick $read(color.txt)
on *:TEXT:!8 what is*:#:/notice $nick $read(what.txt)
on *:TEXT:!8 *:#:/notice $nick $read(can.txt)

Could all be put in 1 on text event :p.
Btw, you should put an on load and not have us have to put it in ourselves :(!

 Respond  
slub77   -  Oct 24, 2009

good eye had not noticed that thanks and i changed it to msg chan as it is meant to be an announcement.

 Respond  
Testor   -  Oct 24, 2009

Line 34

  notice chan 8 ill reply via msg now 

Should be Notice $Chan.
However, that's even worse than /Msg $Chan as everyone gets beeped, so you should do notice $Nick.
You can also delete a bracket from line 75-78 because you forgot the space after { /Halt} so that'd cut down a line if you remove that line + add a space.

 Respond  
slub77   -  Oct 24, 2009

What no comments :(

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.