mIRC Home    About    Download    Register    News    Help

Print Thread
#187610 09/10/07 02:08 AM
Joined: Oct 2007
Posts: 6
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Oct 2007
Posts: 6
Malfunction is probably the wrong term, not functioning at all would be a better way of putting it. I'm pretty (alright, <I>really</I>) new at this, so I'm sure I screwed something up.

Code:
on *:Text:*!Bar*:#:{ 
msg $nick !ImpBeer/ !LungBlaster/ !HardLemonade / !Wine / !Grog / !VAle / !Margarita / !Pony/ }
. }

on *:Text:*!ImpBeer*:#:{ 
describe $active grabs a can of Imperial Stout Trooper and hands it to $nick }

on *:Text:*!LungBlaster*:#:{
describe $active hands $nick an Imperial Lung Blaster cigarette and lights it. }

on *:Text:*!Wine*:#:{ 
describe $active takes a flashlight and wanders to the celler, he returns twenty minutes later with a dusty bottle of wine and a coating of cobwebs. }

on *:Text:*!HardLemonade*:#:{ 
describe $active blinks at $nick . Please die. }

on *:Text:*!Grog*:#:{ 
describe $Active pulls out a bottle of Rum and a glass of water, regards the water with distaste and hands $nick the bottle. "Be a man!" }

on *:Text:*!VAle*:#:{ 
describe $Active tosses $nick a bottle of vader ale. }

on *:Text:*!Margarita*:#:{ 
describe $active calls $nick a fruitcake and hands them a poorly mixed drink. }

on *:Text:*!Pony*:#:{ 
describe $active screams "For Pony" and spears $nick with a fork. }

on *:join:#Drunk:{ 
if ($chan == $active) notice $nick Type I love you.



Now the first part (!Bar) works fine. For some reason the on join worked once, but never again. Any help would be greatly appreciated. I'm sure I either made a stupid mistake somewhere or have everything completely bassackwards.

Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Originally Posted By: Dionysus
Malfunction is probably the wrong term, not functioning at all would be a better way of putting it. I'm pretty (alright, <I>really</I>) new at this, so I'm sure I screwed something up.

Code:
on *:Text:*!Bar*:#:{ 
msg $nick !ImpBeer/ !LungBlaster/ !HardLemonade / !Wine / !Grog / !VAle / !Margarita / !Pony/ }
. }

on *:Text:*!ImpBeer*:#:{ 
describe $active grabs a can of Imperial Stout Trooper and hands it to $nick }

on *:Text:*!LungBlaster*:#:{
describe $active hands $nick an Imperial Lung Blaster cigarette and lights it. }

on *:Text:*!Wine*:#:{ 
describe $active takes a flashlight and wanders to the celler, he returns twenty minutes later with a dusty bottle of wine and a coating of cobwebs. }

on *:Text:*!HardLemonade*:#:{ 
describe $active blinks at $nick . Please die. }

on *:Text:*!Grog*:#:{ 
describe $Active pulls out a bottle of Rum and a glass of water, regards the water with distaste and hands $nick the bottle. "Be a man!" }

on *:Text:*!VAle*:#:{ 
describe $Active tosses $nick a bottle of vader ale. }

on *:Text:*!Margarita*:#:{ 
describe $active calls $nick a fruitcake and hands them a poorly mixed drink. }

on *:Text:*!Pony*:#:{ 
describe $active screams "For Pony" and spears $nick with a fork. }

on *:join:#Drunk:{ 
if ($chan == $active) notice $nick Type I love you.



Now the first part (!Bar) works fine. For some reason the on join worked once, but never again. Any help would be greatly appreciated. I'm sure I either made a stupid mistake somewhere or have everything completely bassackwards.


A) There's a . in the first on text event and an extra } it should be

Code:
on *:Text:*!Bar*:#:{ 
msg $nick !ImpBeer/ !LungBlaster/ !HardLemonade / !Wine / !Grog / !VAle / !Margarita / !Pony/ 
 }


this would fix all of your text events because of the extra bracket >>> this >>> } now... in order to make this cleaner I would suggest doing this...

Code:
on *:Text:*:#:{ 
  if ($1 == !bar) { msg $nick !ImpBeer/ !LungBlaster/ !HardLemonade / !Wine / !Grog / !VAle / !Margarita / !Pony/ }
  if ($1 == !ImpBeer) { describe $active grabs a can of Imperial Stout Trooper and hands it to $nick }
  if ($1 == !LungBlaster) { describe $active hands $nick an Imperial Lung Blaster cigarette and lights it. }
  if ($1 == !Wine) { describe $active takes a flashlight and wanders to the celler, he returns twenty minutes later with a dusty bottle of wine and a coating of cobwebs. } 
  if ($1 == !HardLemonade) { describe $active blinks at $nick . Please die. }
  if ($1 == !Grog) { describe $Active pulls out a bottle of Rum and a glass of water, regards the water with distaste and hands $nick the bottle. "Be a man!" }
  if ($1 == !Vale) { describe $Active tosses $nick a bottle of vader ale. }
  if ($1 == !Margarita) { describe $active calls $nick a fruitcake and hands them a poorly mixed drink. }
  if ($1 == !Pony) { describe $active screams "For Pony" and spears $nick with a fork. }
}

on *:join:#Drunk:{ 
  if ($chan == $active) notice $nick Type I love you.
}


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Oct 2007
Posts: 6
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Oct 2007
Posts: 6
You are a lovely human being.

Thanks a bunch.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
You really need to change all of those IFs (except the first one, of course) to ELSEIFs instead.


Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Originally Posted By: Riamus2
You really need to change all of those IFs (except the first one, of course) to ELSEIFs instead.


Actually ElseIF is not neccasary in this scenerio there's only a simple command to be called and that would be the ! trigger. There's no loss of speed, or a failure to communicate. Weither you use ElseIF or regular IF statements has a recall in the script its fine.

The structure of programming with IF elseif and else statements are as follows

if command is this.... perform
if command is this.... perform

works...

elseif is better used in scenarios like

if command is this.... perform
>>>>>>>and check if theres another match "ElseIF"<<<<<<<<<<<<
elseif command is this... perform

what im trying to say is that the elseif commands checks on top of the IF command while if the IF statement has a matching trigger found the whole script stops and doesnt continue while an elseif check continues the script.


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Dec 2002
Posts: 503
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
Originally Posted By: Lpfix5
Actually ElseIF is not neccasary in this scenerio there's only a simple command to be called and that would be the ! trigger. There's no loss of speed, or a failure to communicate. Weither you use ElseIF or regular IF statements has a recall in the script its fine.

If you're going to pull the speed card out of the deck, then you lose.

if/elseif/elseif will be faster. Period.

With the way the script is above, it will check if $1 equals something 9 times, regardless of whether it matches with the first or ninth match.

Using an if/elseif/elseif structure, it will only do the first 'if', the remaining 8 will be skipped. At worst, it will do 9 if's.

If you're only talking 1 value, then it's a moot point. When you start getting a large number of value checks, doing individual if's is always slower than doing if/elseif structures.

Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
oh well i can be wrong laugh


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Oct 2007
Posts: 6
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Oct 2007
Posts: 6
Yeah, this things all of nine lines(-ish)so it's not a big deal, working fine. If it gets any bigger I'll make the appropriate changes. Anyway, thanks.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yes, like Bekar mentioned, IF/ELSEIF is better because it reduces the number of unnecessary comparisons. In a small script, it really doesn't matter. However, from a support standpoint, anytime you help someone who is learning anything, it's better to show the best way to do something so they learn how to do it that way. If you teach someone to always use a ton of IFs without ELSEIF, then they may always do that, even in really large scripts. If you teach someone to use ELSEIF when appropriate, then they don't fall into that trap.

Note: Obviously, when I say it's better to show the best way, I don't mean that you should show the absolute best way if it means the script gets too complicated to understand for a new scripter. But for something like this, ELSEIF isn't any more difficult to understand, so it's good to show that method. As long as it won't complicate the script beyond understanding for a new scripter, then showing the best method is good.


Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Originally Posted By: Riamus2
Yes, like Bekar mentioned, IF/ELSEIF is better because it reduces the number of unnecessary comparisons. In a small script, it really doesn't matter. However, from a support standpoint, anytime you help someone who is learning anything, it's better to show the best way to do something so they learn how to do it that way. If you teach someone to always use a ton of IFs without ELSEIF, then they may always do that, even in really large scripts. If you teach someone to use ELSEIF when appropriate, then they don't fall into that trap.

Note: Obviously, when I say it's better to show the best way, I don't mean that you should show the absolute best way if it means the script gets too complicated to understand for a new scripter. But for something like this, ELSEIF isn't any more difficult to understand, so it's good to show that method. As long as it won't complicate the script beyond understanding for a new scripter, then showing the best method is good.


Im an old buck, I just go for quick way out when I see something that someone wants ill write it in the quickest way I can think of, I don't in theory think about disadvantages and advantages but oh well...

The scripts I write within my own mIRC environment is different for sure.. I even cut on size with new alias events for commands that are lenghty and repeat. That way its cleaner and easier to manipulate a million times if neccesary


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }

Link Copied to Clipboard