mIRC Home    About    Download    Register    News    Help

Print Thread
Page 2 of 3 1 2 3
#108040 17/01/05 01:02 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Ah ok, never had to use that smile and glad about it too might i add!

Oh it turns out he had made a custom alias after all: check:

aliases
/flood {
set -s %i on
timer 1 5 unset -s %i
}


Greets

Last edited by FiberOPtics; 17/01/05 01:03 AM.

Gone.
#108041 17/01/05 01:08 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
OP Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
thanks for the wisdom on shortening my whole code
ill try to carry this through my whole script
which should half its size

ill keep working on those brackets smile


The Kodokan will move you, one way or another.
#108042 17/01/05 01:14 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
[edit]
just added them outer most { }, thanks for the pointout FiberOPtics
/me is making mistakes becuase hes to lazy to make the help.txt file, and clone in to trigger the events, to check his code frown


Code:
#help on
on *:text:!help:*:{
  if (%i != on) { 
    play -t!help $nick help.txt 2000 
    set -su5 %i on
  }
}
on *:text:!help !*:*:{
  if ((%i != on) && ($istok(!say !die !join !part !cycle !enable !disable !ruser !pass,$2,32))) { 
    play -t $+ $2 $nick help.txt 2000
    set -su5 %i on
  }
}
#help end

1st event does !help
2nd event does !help !* and then checks if $2 being the !* matches one of your options, if so plays it, the SET needs no timer unset becuase the -u5 unsets it in 5 seconds


Im sure theres a method of getting if a section header exists in an INI but i cant think of what it is, maybe someone else can adjust the code for it. as well

Last edited by DaveC; 17/01/05 01:57 AM.
#108043 17/01/05 01:20 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
OP Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
fixed
anything else?


The Kodokan will move you, one way or another.
#108044 17/01/05 01:27 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
OP Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
mildly confused about
"Oh my... I'm amazed the parser allows { as the first character in a line!}
is that reffering to the on *:text:*:*: {
that you later told me to use


The Kodokan will move you, one way or another.
#108045 17/01/05 01:28 AM
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
$ini()

//if $ini(mirc.ini,text) { echo -a $ini(mirc.ini,$v1) is the $ord($v1) header in the file containing $ini(mirc.ini,$v1,0) items }

#108046 17/01/05 01:30 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
on *:text:*:*: {

the brace isn't the first on the line, the first on the line there is "on" :tongue:

Opening braces never go alone on a line as the first char...ever.


Opening chars are only used when:
  • The start of an alias, right after the alias name (although its not necessary, if the commands or constructs are either all piped on one full line, or if there's simply only one command)

    alias myalias {
    do things
    }
  • For opening an event, whether that is a regular event, raw event, ctcp event etc.

    on *:TEXT:*:*: {
    do things
    }

    Same comments as with the alias, they are only needed to group multiple commands or if then else constructs
  • For creating popup menu's for nicklist, channel, etc;

    menu channel {
    popups
    }
  • For ordering if then else constructs:

    if (condition) {
    stuff
    }
    elseif (other condition) {
    do other stuff
    }
    else {
    do default stuff
    }

    A while condition is actually an if condition (or multiple ones) in a while loop, so they go with this category.

    while (condition) {
    do things
    }
  • Opening a dialog (thanks tidy smile):

    dialog mydialog {
    dialog code
    }


    There could be more, but to be honest, I have been up for 24 hours and 42 minutes now, a person tends to forget things at that time :tongue:

Greets

Last edited by FiberOPtics; 17/01/05 01:56 AM.

Gone.
#108047 17/01/05 01:31 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Well Dave accidentally misused the brackets as well, but Im sure he'll fix em up in a minute.

It has evolved pretty far huh from your original way? I know some ways that could do it with even less code, but that's irrelevant at this point. It looks good.

You could add some small things here and there, but for now, is more than good, and soooo much shorter.

Cya around!


Gone.
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
I believe it was about these ones
on *:text:!help:*:{
if (%i = on) { halt }
else { msg $nick $read(help.txt,n,1) }
{ msg $nick $read(help.txt,n,2) }
{ msg $nick $read(help.txt,n,3) }
{ msg $nick $read(help.txt,n,4) }
...
...

#108049 17/01/05 01:49 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
OP Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
well now i have to run around and get all the brackets off the start of lines


The Kodokan will move you, one way or another.
#108050 17/01/05 01:52 AM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
The only other thing I can think of is a dialog table:

Code:
dialog name {
  controls and stuff
}


New username: hixxy
#108051 17/01/05 01:53 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Well, only the opening brackets but yeah, it would be a good idea to go over all your code that you have, to check that out.

Cya!


Gone.
#108052 17/01/05 01:56 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hehe thanks I added it...hmm any others? I'm blank at this point lol.


Gone.
#108053 17/01/05 02:03 AM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
They can actually be used pretty much anywhere, i've seen people use them where they have absolutely no use at all, but the code works fine, eg:

Code:
alias test {
  goto test
  return
  :test {
    echo -a test
    echo -a 1 2 3
  }
}


In fact, I suppose you could use that to name or describe blocks of code without using comments:

Code:
alias test {
  :echo some numbers {
    echo -a 1
    echo -a 2
  }
  :message a few channels {
    msg #chan1 hi
    msg #chan2 there.
  }
}


New username: hixxy
#108054 17/01/05 02:10 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Code:
#help on
on *:text:!help:*:{
  if (%i != on) { 
    play -t!help $nick help.txt 2000 
    set -su5 %i on
  }
}

on *:text:!help !*:*:{
  if ((%i != on) && ($ini(help.txt,$2))) { 
    play -t $+ $2 $nick help.txt 2000
    set -su5 %i on
  }
}
#help end

2nd on uses the HELP.TXT file to make sure u have help for that topic, then displays it
you could incoperate the 1st event into it, but i think it would make the code more complexe than its worth.

Thanks for $ini Iori

/me looks around sheepishly becuase he couldn't think of the indentifier for INI file data

#108055 17/01/05 02:11 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Well ok, though the examples I gave him are the ones that are used with a purpose.

I know you can do: on *:TEXT:!test:#:{ { { { msg # matched !test } } } }

As long as the opening brackets match the opening ones, all is good, but they are obsolete.

Nice to mention it though, I hadn't seen it used in a goto like that, even though they don't serve a purpose there at all.

Cya tidy

Edit: lol that commenting is nice, I never really use goto statements though, aside for a select statement.

Last edited by FiberOPtics; 17/01/05 02:13 AM.

Gone.
#108056 17/01/05 02:12 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
OP Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
its done no brackets on starts
no openers any ways
plently of closers
my code dropped about 20 lines
and almost half that is just
}
}
so altogether no too shabby
im glad my topic could inspire so much conversation among u guys
thanks again

Last edited by ricky_knuckles; 17/01/05 02:13 AM.

The Kodokan will move you, one way or another.
#108057 17/01/05 02:18 AM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Code:
#help on
on *:text:!help*:#:{
  if ($1 == !help) {
    if ($2 == $null) { tokenize 32 $1 $1 }
    if ($ini(help.txt,$2)) && (%i != on) {  
      play -t $+ $2 $nick help.txt 2000
      set -su5 %i on
    }
  }
}
#help end


New username: hixxy
#108058 17/01/05 02:24 AM
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Q. Why does %i exist? The code is inside a #group. If the group is 'on' the code executes, if the group is 'off' it won't. You could enable|disable the group from wherever it is you set "%i" and eliminate that condition check. smile

#108059 17/01/05 02:43 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
yeah its more complexe than its worth, but what the heck.

try this.

Code:
#help on
on *:text:!help*:#:{
  if (%i != on) && ($1 == !help) {
    if ($2 == $null) { tokenize 32 - Help }
    if ($ini(help.txt,$2)) {  
      play -t $+ $2 $nick help.txt 2000
      set -su5 %i on
    }
  }
}
#help end


checked %i first since if its ON you never do anything anyway
tokenize 32 - Help , since $1 isnt needed and its fractionally faster to uses a hardcoded filler also default help section was [help] (but that could have been changed in the text file),

Page 2 of 3 1 2 3

Link Copied to Clipboard