This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see this announcement post . Click the X in the top right-corner of this box to dismiss this message.
Support & discussion of released scripts, and announcements of new releases.
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Mon Jan 21, 2013 12:26 pm
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.
caesar
Mint Rubber
Posts: 3778 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Tue Jan 22, 2013 1:25 am
yes, that's the opposite of:
Code: Select all
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.
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Tue Jan 22, 2013 1:42 am
not really... you needed more like this for yours to work correctly:)
Code: Select all
if {![isop $nick $chan] && ![isvoice $nick $chan]} return
The or (||) was what made yours not work. That was my point.
caesar
Mint Rubber
Posts: 3778 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Tue Jan 22, 2013 1:45 am
Really?
According to the expressions
page :
&&
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: Select all
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: Select all
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 .
Last edited by
caesar on Tue Jan 22, 2013 2:00 am, edited 1 time in total.
Once the game is over, the king and the pawn go back in the same box.
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Tue Jan 22, 2013 1:52 am
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.
caesar
Mint Rubber
Posts: 3778 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Tue Jan 22, 2013 2:01 am
Read again what I said above about expressions and look then on:
Code: Select all
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:
% 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
Last edited by
caesar on Tue Jan 22, 2013 2:07 am, edited 1 time in total.
Once the game is over, the king and the pawn go back in the same box.
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Tue Jan 22, 2013 2:04 am
double negative with an or operator works like an and,
whatever... mine worked, yours didn't.... nuff said:)
Last edited by
SpiKe^^ on Tue Jan 22, 2013 2:11 am, edited 1 time in total.
caesar
Mint Rubber
Posts: 3778 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Tue Jan 22, 2013 2:08 am
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.
bryanwny
Voice
Posts: 24 Joined: Sun Sep 09, 2012 10:35 pm
Post
by bryanwny » Tue Jan 22, 2013 11:01 am
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!
[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!
caesar
Mint Rubber
Posts: 3778 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Tue Jan 22, 2013 11:54 am
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: Select all
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: Select all
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.
nml375
Revered One
Posts: 2860 Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 » Tue Jan 22, 2013 2:31 pm
Ceasar:
Try the both codes in a logic table.. And read up on De Morgan's law.
Code: Select all
(!expression_A || !expression_B) => !(expression_A && expression_B)
In extension:
Code: Select all
!(!expression_A || !expression_B) => !(!(expression_A && expression_B)) => (expression_A && expression_B)
Code: Select all
/---+---+------------+---------------------\
| 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