|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Ah ok, never had to use that 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.
|
|
|
|
Joined: Nov 2004
Posts: 332
Fjord artisan
|
OP
Fjord artisan
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
The Kodokan will move you, one way or another.
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
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
#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.
|
|
|
|
Joined: Nov 2004
Posts: 332
Fjord artisan
|
OP
Fjord artisan
Joined: Nov 2004
Posts: 332 |
The Kodokan will move you, one way or another.
|
|
|
|
Joined: Nov 2004
Posts: 332
Fjord artisan
|
OP
Fjord artisan
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.
|
|
|
|
Joined: Aug 2003
Posts: 1,831
Hoopy frood
|
Hoopy frood
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 }
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
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 ):
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.
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
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
Hoopy frood
|
Hoopy frood
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) } ... ...
|
|
|
|
Joined: Nov 2004
Posts: 332
Fjord artisan
|
OP
Fjord artisan
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.
|
|
|
|
Joined: Nov 2003
Posts: 2,327
Hoopy frood
|
Hoopy frood
Joined: Nov 2003
Posts: 2,327 |
The only other thing I can think of is a dialog table: dialog name {
controls and stuff
}
New username: hixxy
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
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.
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Hehe thanks I added it...hmm any others? I'm blank at this point lol.
Gone.
|
|
|
|
Joined: Nov 2003
Posts: 2,327
Hoopy frood
|
Hoopy frood
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: 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: alias test {
:echo some numbers {
echo -a 1
echo -a 2
}
:message a few channels {
msg #chan1 hi
msg #chan2 there.
}
}
New username: hixxy
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
#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
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
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.
|
|
|
|
Joined: Nov 2004
Posts: 332
Fjord artisan
|
OP
Fjord artisan
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.
|
|
|
|
Joined: Nov 2003
Posts: 2,327
Hoopy frood
|
Hoopy frood
Joined: Nov 2003
Posts: 2,327 |
#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
|
|
|
|
Joined: Aug 2003
Posts: 1,831
Hoopy frood
|
Hoopy frood
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.
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
yeah its more complexe than its worth, but what the heck. try this. #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),
|
|
|
|
|