| View previous topic :: View next topic |
| Author |
Message |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Mon Jan 21, 2013 12:26 pm Post subject: |
|
|
First chunk of code is wrote so it requires both ops and voice:)
| caesar wrote: |
if {![isop $nick $chan] || ![isvoice $nick $chan]} return
|
That will return out, if you either don't have ops |or| don't have voice, double negatives can be very confusing. _________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Tue Jan 22, 2013 1:25 am Post subject: |
|
|
yes, that's the opposite of:
| Code: |
if {[isop $nick $chan] || [isvoice $nick $chan]} {
|
but instead to continue with that alice:pubquery proc it returns if any of the checks (op or voice) fails.
Your point? _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Tue Jan 22, 2013 1:42 am Post subject: |
|
|
not really... you needed more like this for yours to work correctly:)
| Code: | | if {![isop $nick $chan] && ![isvoice $nick $chan]} return |
The or (||) was what made yours not work. That was my point. _________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Tue Jan 22, 2013 1:45 am Post subject: |
|
|
Really?
According to the expressions page:
| Quote: |
&&
Logical AND. Produces a 1 result if both operands are non-zero, 0 otherwise. Valid for boolean and numeric (integers or floating-point) operands only.
||
Logical OR. Produces a 0 result if both operands are zero, 1 otherwise. Valid for boolean and numeric (integers or floating-point) operands only.
|
Again, your point?
| Code: |
if {[isop $nick $chan] || [isvoice $nick $chan]} { execute this code } else { return }
|
that translates to check if it's op OR if it's voice and if ANY of the statements returns true then executes this code. If none of the statements returns true then it will simply return.
that is the same as:
| Code: |
if {![isop $nick $chan] || ![isvoice $nick $chan]} { return } else { execute this code }
|
that translates into if the user isn't operator OR isn't voiced then return, else if ANY of the statements returns true then will execute this code.
The only difference is given by the position of return. _________________ Once the game is over, the king and the pawn go back in the same box.
Last edited by caesar on Tue Jan 22, 2013 2:00 am; edited 1 time in total |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Tue Jan 22, 2013 1:52 am Post subject: |
|
|
Again... your code required the person to be Both opped And voiced to execute the command.
That is Not what the user was shooting for:)
I am done arguing though on this string. _________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Tue Jan 22, 2013 2:01 am Post subject: |
|
|
Read again what I said above about expressions and look then on:
| Code: |
if {![isop $nick $chan] || ![isvoice $nick $chan]} return
|
I don't see any && in there, on ANY of the codes I've posted. I may be dumb but I'm not blind.
Here's something to see better:
| Quote: |
% set one "0"; set two "0"
0
% if {$one || $two} { puts "valid" } else { puts "false" }
false
% if {!$one || !$two} { puts "valid" } else { puts "false" }
valid
|
_________________ Once the game is over, the king and the pawn go back in the same box.
Last edited by caesar on Tue Jan 22, 2013 2:07 am; edited 1 time in total |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Tue Jan 22, 2013 2:04 am Post subject: |
|
|
double negative with an or operator works like an and,
whatever... mine worked, yours didn't.... nuff said:) _________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Last edited by SpiKe^^ on Tue Jan 22, 2013 2:11 am; edited 1 time in total |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Tue Jan 22, 2013 2:08 am Post subject: |
|
|
I have my doubts that bryanwny did the things correctly. Anyway.  _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
bryanwny Voice
Joined: 09 Sep 2012 Posts: 24
|
Posted: Tue Jan 22, 2013 11:01 am Post subject: |
|
|
Lets just say I didn't and that's that.
EDIT: Curiosity got the better of me. Yes, I killed the bot entirely and reloaded it. Yes, I made sure 'alter-alice.tcl' was loaded in the .conf after alice.tcl. As you can see below, I was opped and the bot didn't respond. Gave myself a + as well, and it answered. Took the @ away, leaving the +, no response. Took both the @ and + off, no response. It would appear that SpiKe is correct. Sorry caesar! Psst, you did all the hard work and SpiKe only had to change a couple characters! thank you both!
| Quote: |
[10:11am] <@Bryan> ANC hi there!
[10:11am] * Bryan sets mode: +v Bryan
[10:11am] <@Bryan> ANC hi there!
[10:12am] <@ANC> Hello .
[10:12am] * Bryan sets mode: -v Bryan
[10:12am] <@Bryan> ANC hi how are you?
[10:13am] * Bryan sets mode: +v-o Bryan Bryan
[10:13am] <+Bryan> ANC whats your name?
[10:14am] * ChanServ sets mode: +o Bryan
[10:14am] * Bryan sets mode: -v Bryan
[10:14am] * Bryan sets mode: -o Bryan
[10:15am] <Bryan> ANC hi there!
|
|
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Tue Jan 22, 2013 11:54 am Post subject: |
|
|
I will do some tests on my own cos I still don't get what's wrong in there. Following my logic I'd would have said that:
| Code: |
if {![isop $nick $chan] || ![isvoice $nick $chan]} return
# execute code
|
if any of the two statements (if the user isn't channel operator or he doesn't have voice) returns true it would return, else would execute code, and:
| Code: |
if {[isop $nick $chan] || [isvoice $nick $chan]} {
# execute code
}
return 0
|
if any of the two statements (if the user is channel operator or he has voice) returns true it would execute code, else would return.
Edit: you are right. I don't understand why this double negation expressions with an or operator works like an and expression, not like an or expression as it should. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Jan 22, 2013 2:31 pm Post subject: |
|
|
Ceasar:
Try the both codes in a logic table.. And read up on De Morgan's law.
| Code: | | (!expression_A || !expression_B) => !(expression_A && expression_B) |
In extension:
| Code: | | !(!expression_A || !expression_B) => !(!(expression_A && expression_B)) => (expression_A && expression_B) |
| Code: | /---+---+------------+---------------------\
| A | B | !A or !B | !(A and B) |
| 0 | 0 | 1 or 1 = 1 | !(0 and 0) = !0 = 1 |
| 0 | 1 | 1 or 0 = 1 | !(0 and 1) = !0 = 1 |
| 1 | 0 | 0 or 1 = 1 | !(1 and 0) = !0 = 1 |
| 1 | 1 | 0 or 0 = 0 | !(1 and 1) = !1 = 0 |
\---+---+------------+---------------------/
|
Edit: Added logic/truth-table _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
|