echo not being performed
#137176
09/12/05 02:08 AM
|
Joined: Mar 2005
Posts: 212
NeUtRoN_StaR
OP
Fjord artisan
|
OP
Fjord artisan
Joined: Mar 2005
Posts: 212 |
ok i have this rigged up so if they try to switch something the way it already is it echos and tell them its already on or off respectively the second echo for each of the autoback buttons isnt firing the first is firing fine i originally just had it as an else as you see in the rest of the code but i tried a elseif just in case though it shouldnt make a difference
#away on
alias away.off {
if (%away = on) {
/set %away off
echo 5 -a Away is off.
set %chan 1
set %cnum $chan(0)
while (%chan <= %cnum) {
notice $chan(%chan) $me is back.
inc %chan
}
}
else {
echo 5 -a away is already off.
}
}
alias away.on {
if (%away = off) {
/set %away on
echo 5 -a Away is on.
set %chan 1
set %cnum $chan(0)
while (%chan <= %cnum) {
notice $chan(%chan) $me is away.
inc %chan
}
}
else {
echo 5 -a away is already on.
}
}
on *:Connect: {
.timeraway 0 10 away.idle
}
alias away.idle {
if (($idle >= 600) && (%away != on)) {
away.on
}
}
menu channel {
auto away
.auto back
..on {
if ($group(#autoback) == off) {
enable #autoback
echo 5 -a auto back is on
elseif ($group(#autoback) == on) {
echo 5 -a auto back is already on
}
}
}
..off {
if ($group(#autoback) == on) {
disable #autoback
echo 5 -a auto back is off
elseif ($group(#autoback) == off) {
echo 5 -a auto back is already off
}
}
}
.on {
away.on
}
.off {
away.off
}
}
on *:text:*:?:{
if (%away == on) {
msg $nick I'm currently away from the keyboard
closemsg $nick
}
}
#away end
#autoback on
on *:input:#:{
if (%away = on) {
away.off
}
}
#autoback end
|
|
|
Re: echo not being performed
#137177
09/12/05 02:33 AM
|
Joined: Dec 2002
Posts: 1,245
MikeChat
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
while I didn't test this, I made some changes toyour
alias away.off {
if (%away = on) {
/set %away off
echo 5 -a Away is off.
set %chan 1
set %cnum $chan(0)
amsg $me is back.
disable #autoback
}
else {
echo 5 -a away is already off.
}
}
alias away.on {
if (%away = off) {
set %away on
echo 5 -a Away is on.
set %chan 1
set %cnum $chan(0)
amsg $me is away.
enable #autoback
}
else {
echo 5 -a away is already on.
}
}
on *:Connect: {
.timeraway 0 10 away.idle
}
alias away.idle {
if (($idle >= 600) && (%away != on)) {
away.on
}
}
menu channel {
auto away
.auto back
..on {
if ($group(#autoback) == off) {
enable #autoback
echo 5 -a auto back is on
elseif ($group(#autoback) == on) {
echo 5 -a auto back is already on
}
}
}
..off {
if ($group(#autoback) == on) {
disable #autoback
echo 5 -a auto back is off
elseif ($group(#autoback) == off) {
echo 5 -a auto back is already off
}
}
}
.on {
away.on
}
.off {
away.off
}
}
#away on
on *:text:*:?:{
if (%away == on) {
msg $nick I'm currently away from the keyboard
closemsg $nick
}
}
#away end
#autoback on
on *:input:#:{
if (%away = on) {
away.off
}
}
#autoback end
I moved the #away group heading so it would conflict with the menu and controls if that group were off (what did you want it to do?) also included the enable/disable to the aliases you have removed the while loops to msg the channels and replaced with amsg which is a mIRC built in "message all channels" see /help /amsg Keep after it, eventually you will hve the script you want.
|
|
|
Re: echo not being performed
#137178
09/12/05 02:48 AM
|
Joined: Mar 2005
Posts: 212
NeUtRoN_StaR
OP
Fjord artisan
|
OP
Fjord artisan
Joined: Mar 2005
Posts: 212 |
the irony is i'm not writting this for myself; i appreciate your input the #away was just force of habit i imagine just like i have a habit of reinventing the wheel(the loops)
any idea why the echos for the autoback buttons werent firing in my original version thats what i really want to know
Last edited by NeUtRoN_StaR; 09/12/05 02:49 AM.
|
|
|
Re: echo not being performed
#137179
09/12/05 02:57 AM
|
Joined: Dec 2002
Posts: 1,245
MikeChat
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
again, I didnt test it either way, but as a guess maybe the #group was off
|
|
|
Re: echo not being performed
#137180
09/12/05 03:02 AM
|
Joined: Mar 2005
Posts: 212
NeUtRoN_StaR
OP
Fjord artisan
|
OP
Fjord artisan
Joined: Mar 2005
Posts: 212 |
i tested it pretty thoroughly i don't think i missed any groups being off or anything to that effect
but based on your answer im assuming that you don't see any reason they wouldnt be firing either?
i'm betting i overlooked something stupid
but the code there is the same thing i tested so hopefully someone else will spot it
Last edited by NeUtRoN_StaR; 09/12/05 03:04 AM.
|
|
|
Re: echo not being performed
#137181
09/12/05 03:19 AM
|
Joined: Aug 2004
Posts: 7,252
RusselB
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
Your elseif statements aren't lining up with corresponding if statements. I've given your code a bit of a rewrite..let me know what you think alias away.off {
if (%away = on) {
set %away off
echo 5 -a Away is off.
set %chan 1
set %cnum $chan(0)
while (%chan <= %cnum) {
notice $chan(%chan) $me is back.
inc %chan
}
}
else {
echo 5 -a away is already off.
}
}
alias away.on {
if (%away = off) {
set %away on
echo 5 -a Away is on.
set %chan 1
set %cnum $chan(0)
while (%chan <= %cnum) {
notice $chan(%chan) $me is away.
inc %chan
}
}
else {
echo 5 -a away is already on.
}
}
on *:Connect: {
.timeraway 0 10 away.idle
}
alias away.idle {
if (($idle >= 600) && (%away != on)) {
away.on
}
}
menu channel {
auto away
.auto back
..on {
echo 5 -a auto back is $iif($group(#autoback) != off,already) on
$iif($group(#autoback) == off,.enable #autoback)
}
..off {
echo 5 -a auto back is $iif($group(#autoback) != on,already) off
$iif($group(#autoback) == on,.disable #autoback)
}
.on {
away.on
}
.off {
away.off
}
}
on *:text:*:?:{
if (%away == on) {
msg $nick I'm currently away from the keyboard
closemsg $nick
}
}
#autoback on
on *:input:#:{
if (%away = on) {
away.off
}
}
#autoback end
|
|
|
Re: echo not being performed
#137182
09/12/05 03:22 AM
|
Joined: Mar 2005
Posts: 212
NeUtRoN_StaR
OP
Fjord artisan
|
OP
Fjord artisan
Joined: Mar 2005
Posts: 212 |
i originally had them as just else the elseif was just something i tried when the echo wasnt working anyways i dont see how they "don't line up" would you mind illustrating
sorry to be so much trouble but i hate having anything that isnt original
Last edited by NeUtRoN_StaR; 09/12/05 03:25 AM.
|
|
|
Re: echo not being performed
#137183
09/12/05 03:24 AM
|
Joined: Aug 2004
Posts: 7,252
RusselB
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
As to being else or elseif, in this case, is irrelevant, as the problem appears to be the alignment of the lines in reference to the corresponding original if statment.
|
|
|
Re: echo not being performed
#137184
09/12/05 03:26 AM
|
Joined: Oct 2005
Posts: 1,741
genius_at_work
Hoopy frood
|
Hoopy frood
Joined: Oct 2005
Posts: 1,741 |
-
Last edited by genius_at_work; 09/12/05 03:27 AM.
|
|
|
Re: echo not being performed
#137185
09/12/05 03:31 AM
|
Joined: Mar 2005
Posts: 212
NeUtRoN_StaR
OP
Fjord artisan
|
OP
Fjord artisan
Joined: Mar 2005
Posts: 212 |
that is the code im reffering to not working and it was originally just an else due to the fact that the echo wasnt working i tried changing it to a ifelse although as far as i could see it shouldnt have made any difference and in fact it didnt
so i guess im sitting here waiting on russel's explanation that i requested
|
|
|
Re: echo not being performed
#137186
09/12/05 03:46 AM
|
Joined: Mar 2005
Posts: 212
NeUtRoN_StaR
OP
Fjord artisan
|
OP
Fjord artisan
Joined: Mar 2005
Posts: 212 |
i suppose i could just scrap the damn thing
|
|
|
Re: echo not being performed
#137187
09/12/05 04:09 AM
|
Joined: Aug 2004
Posts: 7,252
RusselB
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
As to being else or elseif, in this case, is irrelevant, as the problem appears to be the alignment of the lines in reference to the corresponding original if statment. I've eliminated the if/elseif statements in the code I provided, using $iif instead.
|
|
|
Re: echo not being performed
#137188
09/12/05 09:54 AM
|
Joined: Jan 2003
Posts: 53
Zonk
Babel fish
|
Babel fish
Joined: Jan 2003
Posts: 53 |
you might wanna take a look at the if-comparison... in the aliases you're using if (%away = on) { but you want if (%away == on) {
you're version will set %away to 'on' everytime and since thats successfull, it will evaluate true and go on with the first stuff...
|
|
|
Re: echo not being performed
#137189
09/12/05 02:18 PM
|
Joined: Feb 2004
Posts: 2,019
FiberOPtics
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Nah, it won't set %away to anything, although I agree it's "better" to use the correct syntax, which is ==
Gone.
|
|
|
Re: echo not being performed
#137190
09/12/05 04:23 PM
|
Joined: Mar 2005
Posts: 212
NeUtRoN_StaR
OP
Fjord artisan
|
OP
Fjord artisan
Joined: Mar 2005
Posts: 212 |
|
|
|
Re: echo not being performed
#137191
09/12/05 05:15 PM
|
Joined: Dec 2002
Posts: 1,245
MikeChat
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
ok, I played with this a bit, still using you
alias away.off {
if (%away != off) {
set %away off
echo 5 -a Away is off.
amsg $me is back.
disable #autoback
}
elseif (%away == off) {
echo 5 -a away is already off.
echo 4 -a $+(%,away) %away
}
}
alias away.on {
if (%away != on) {
set %away on
echo 5 -a Away is on.
amsg $me is away.
enable #autoback
}
elseif (%away == on) {
echo 5 -a away is already on.
echo 4 -a $+(%,away) %away
}
}
on *:Connect: {
.timeraway 0 10 away.idle
}
alias away.idle {
if (($idle >= 600) && (%away != on)) {
away.on
}
}
menu channel {
auto away
.auto back
..on {
if ($group(#autoback).status == off) {
enable #autoback
echo 5 -a auto back is on
}
elseif ($group(#autoback).status == on) {
echo 5 -a auto back is already on
}
}
..off {
if ($group(#autoback).status == on) {
disable #autoback
echo 5 -a auto back is off
}
elseif ($group(#autoback).status == off) {
echo 5 -a auto back is already off
}
}
.on {
away.on
}
.off {
away.off
}
}
#away on
on *:text:*:?:{
if (%away == on) {
msg $nick I'm currently away from the keyboard
closemsg $nick
}
}
#away end
#autoback off
on *:input:#:{
if (%away == on) {
away.off
}
}
#autoback end
several things As pointed out using == not = when checking the value of a variable (or any other comparison) will avoid false matches and other problems. your %away was never set in the3 script, so it always failed Note how i changed the test to if it is not eaual to on, set it on instead of "if it is equal to off set it on" while the logic may seem the same, it really isnt because if %away == $null (no value) then it didn't equal off (what you tested against) so it failed to set it on. also where you tested the status of the group, you didnt use the .status modifier, while it works in menus like that I have seen that it doesnt work elsewhere so adding the .status and it begins to have a valid comparison. I think thats it, look it over and continue testing. Also think about how you can make the code smaller, can you combine the coding in the menu with the coding in the aliases? do you need the group for the autoback? (good way to test a value rather than a global variable?) keep at it and I think you will be very happy with what you make. and as always post questions here (we need the mental excercise)
|
|
|
Re: echo not being performed
#137192
09/12/05 07:27 PM
|
Joined: Mar 2005
Posts: 212
NeUtRoN_StaR
OP
Fjord artisan
|
OP
Fjord artisan
Joined: Mar 2005
Posts: 212 |
the autoback group is there because its easy to see how the actual autoback script could prove bothersome for the person using the script so i wanted a independant switch for just that part the group isnt necessary per say i could have just as well done a variable switch the = instead of == were type os and im betting i could easily compress the code down further and certainly make it more modular, but you've seen my code so its fairly obvious im an amateur so for right now all i ask of my code is that it functions unless its something i plan to publish which i've only released one thing and that was to mirc.net which is down for some time now 
|
|
|
Re: echo not being performed
#137193
09/12/05 10:58 PM
|
Joined: Dec 2002
Posts: 1,245
MikeChat
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
I have stayed with your code because I think that is the way you will learn and have some fun.
I could post a way (or a few ways) to do the same thing and maybe more efficient or less code or whatever, I dont know that it will help you learn to code or not. if you want to see another way to do an away "system" use the search feature on the forum and expand it to a 5 year search. there will be more examples there than you can read in a day im sure. other than that, make what you have Work, then make what you have work more efficient, and when you cant figure something out post like you did and you most likely will get several people posting solutions.
|
|
|
|
|