egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

alice.tcl 1.4.0
Goto page Previous  1, 2
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Mon Jan 21, 2013 12:26 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Tue Jan 22, 2013 1:25 am    Post subject: Reply with quote

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
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Tue Jan 22, 2013 1:42 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Tue Jan 22, 2013 1:45 am    Post subject: Reply with quote

Really? Rolling Eyes

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
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Tue Jan 22, 2013 1:52 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Tue Jan 22, 2013 2:01 am    Post subject: Reply with quote

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
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Tue Jan 22, 2013 2:04 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Tue Jan 22, 2013 2:08 am    Post subject: Reply with quote

I have my doubts that bryanwny did the things correctly. Anyway. Rolling Eyes
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
bryanwny
Voice


Joined: 09 Sep 2012
Posts: 24

PostPosted: Tue Jan 22, 2013 11:01 am    Post subject: Reply with quote

Lets just say I didn't and that's that. Laughing

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! Laughing 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
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Tue Jan 22, 2013 11:54 am    Post subject: Reply with quote

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. Rolling Eyes 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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Jan 22, 2013 2:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber