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.

alice.tcl 1.4.0

Support & discussion of released scripts, and announcements of new releases.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

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
.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

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.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Really? :roll:

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.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

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
.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

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.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

I have my doubts that bryanwny did the things correctly. Anyway. :roll:
Once the game is over, the king and the pawn go back in the same box.
b
bryanwny
Voice
Posts: 24
Joined: Sun Sep 09, 2012 10:35 pm

Post by bryanwny »

Lets just say I didn't and that's that. :lol:

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! :lol: 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!
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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. :roll: 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.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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
Post Reply