mIRC Home    About    Download    Register    News    Help

Print Thread
Racking up a bill. #205822 01/11/08 07:32 PM
Joined: Oct 2008
Posts: 167
S
seanturner70 Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Oct 2008
Posts: 167
I am creating bar (activated by typing !bar)

When the user types !bar they are presented with a menu. I am wondering if it is possible to have a price for each item on the menu. Then when they type: !bill, they are presented with a final price.

e.g.
Quote:
<User> !bar
<Bot> Hello user , Welcome to the bar, on todays menu we have, !coke , !coffee , !chips
<User> !coffee
<Bot> That will be 1.99, do you want !white or !black?
<User> !White
* Bot hands User a white coffee
<Bot> Any !milk or !sugar?
<User> !chips
<Bot> That will be 0.86
* Bot Hands User a plate of chips
<User> !bill
<Bot> You bought: White Coffee with chips which cost a total of: 2.85.
<Bot> Do you wish to pay by !cash or !card?
<User> !ca...

Last edited by seanturner70; 01/11/08 07:39 PM.
Re: Racking up a bill. [Re: seanturner70] #205832 01/11/08 09:02 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Yes it's possible.
A few questions.. Do you want to allow them to pay in a different currency than the posted currency?
If payment is in a different currency, how do you want exchange handled?
Are there any taxes on the items? If so, what and how much?
Is there a different tax rate for drinks versus food?
Is there a different tax rate for alcoholic drinks?
Is there a different rate if the bill is over a certain amount?
Do you want to limit how high the bill can get before being presented for payment?
Do you want to retain bills between sessions, in case someone runs a bill and leaves without paying?
Do you want them to be able to carry a bill from one session to the next if they don't have enough money to pay the bill?
Do you want a surcharge for using the !card option?
Do you want to accept only certain cards?
Do you want Paypal as an alternative?

That's all I can think of at the moment, but it'll give you some things to think about that you might not have considered.

Re: Racking up a bill. [Re: RusselB] #205834 01/11/08 09:08 PM
Joined: Oct 2008
Posts: 167
S
seanturner70 Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Oct 2008
Posts: 167
Yes, if possible I would like the currency to be able to be changed.

I would like it if the bills could be retained.

But really, it is only to have a "cool" bot... Not a REAL payment system.

Re: Racking up a bill. [Re: seanturner70] #205837 01/11/08 09:44 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
My suggestion: don't dare something too "big" at once, but go for it step by step. Practice using if-then-else conditions, $calc-ulations, how to store data in global variables and maybe ini files later, etc.
Then, start with a simple structure, think about possible things to add later, but don't add it all at once. Let it grow instead.

You may start with a "plaintext" sketch of your script before you translate it to actual code, allowing to "play" different scenarios in your mind (and with your finger on the screen or paper), to find loopholes etc. Something like:
Code:
on text event {
  if its a valid order {
    if A orders coffee { ask white or black }
    elseif A orders white { pass white and increase %bill.of.A by ammount x }
    elseif A orders black { pass black and increase %bill.of.A by ammount x }
    elseif A orders peanuts {
      pass peanuts
      inform about the advantages of having a cold beer with the nuts
      increase %bill.of.A by ammount y
    }
    elseif... { ... }
  }
  elseif A orders the bill {
    if theres a %bill.of.A {
      inform A about the total of %bill.of.A 
      ask about payment method
    }
    else { laugh at A }
  }
  elseif A pays the bill {
    if he pays more {
      say thanks for the tip
      delete the %bill.of.A
    }
    elseif he pays less {
      decrease the %bill.of.A respectively
      inform A about the remaining debt
    }
    else {
      delete the bill.of.A
      bitch that there was no tip at all
    }
  }
}





Re: Racking up a bill. [Re: Horstl] #205838 01/11/08 09:48 PM
Joined: Oct 2008
Posts: 167
S
seanturner70 Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Oct 2008
Posts: 167
ok, thanks smile

Re: Racking up a bill. [Re: Horstl] #205870 02/11/08 01:13 PM
Joined: Oct 2008
Posts: 167
S
seanturner70 Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Oct 2008
Posts: 167
If its not too much bother, what would the "working" version look like?

Re: Racking up a bill. [Re: seanturner70] #205879 02/11/08 05:11 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
My personal experience is that one always will find something to add, change, or remove in "bot scripts" like this one - it's open ended, and thus it's of little use to write it down for you - 'cause first of all it should be/stay your script/bot, reflecting your own ideas and preferences.
You should write it, or try it at least. smile
We can/will provide help to solve specific problems you encounter and come along with, but it's inevitable that you learn (practise) e.g. to build your own "if-then-else" trees, which are indispensable in a bot script with a lot of varieties. You can find some examples e.g. in the "/help", or reading through similar scripts. Other catchwords for the /help file: if then else, /set, /inc, $calc

Re: Racking up a bill. [Re: Horstl] #205883 02/11/08 07:30 PM
Joined: Oct 2008
Posts: 167
S
seanturner70 Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Oct 2008
Posts: 167
Ok, I am sort of following it...

Would I change all those A's to $nick or similar?


Re: Racking up a bill. [Re: seanturner70] #205889 02/11/08 07:43 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Yes

Re: Racking up a bill. [Re: RusselB] #205901 02/11/08 11:40 PM
Joined: Oct 2008
Posts: 167
S
seanturner70 Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Oct 2008
Posts: 167
Ok, So far I have:
Code:
on text event {
  if its a valid order {
    if $nick orders coffee { ask white or black }
    elseif $nick orders white { pass white and increase %bill.of.$nick by ammount 0.82 }
    elseif $nick orders black { pass black and increase %bill.of.$nick by ammount 0.82 }
    elseif $nick orders peanuts {
      pass peanuts
      inform about the advantages of having a cold beer with the nuts
      increase %bill.of.$nick by ammount y
    }
    elseif... { ... }
  }
  elseif $nick orders the bill {
    if theres a %bill.of.$nick {
      inform $nick about the total of %bill.of.$nick 
      ask about payment method
    }
    else { laugh at $nick }
  }
  elseif $nick pays the bill {
    if he pays more {
      say thanks for the tip
      delete the %bill.of.$nick
    }
    elseif he pays less {
      decrease the %bill.of.$nick respectively
      inform $nick about the remaining debt
    }
    else {
      delete the bill.of.$nick
      bitch that there was no tip at all
    }
  }
}


Am I going wrong so far?

Last edited by seanturner70; 02/11/08 11:48 PM.
Re: Racking up a bill. [Re: seanturner70] #205902 03/11/08 12:02 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Looks good so far.
Next step is to convert it from pseudocode (which is what the kind of code you've been doing) to mIRC code.

You'll want to ensure that the help file is available, as it will be your best reference when changing it to a code that mIRC will understand.

Good luck, and if you run into something you can't figure out, don't hesitate to ask.

Re: Racking up a bill. [Re: seanturner70] #205924 03/11/08 08:01 AM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
This is my version of script based on what you requested for originally, but there's a drawback, that is, it can only calculate the total cost of two items purchased. I think I've covered all of the trigger commands you depicted. Nevertheless, this script could be further improved.

Code:
alias bill {
  var %b = %x + %y
  return %b
}
on $*:TEXT:$(/[!](coffee|chips)/Si):#: {
  if ($regml(1) == coffee) { 
    msg # that will be 1.99, do you want !white or !black?
    set %coffee coffee | set %x 1.99
  }
  if ($regml(1) == chips) { 
    msg # That will be 0.86. Thank you.
    .timerchips 1 3 describe # Bot hands $nick a plate of chips.
    set %chips chips | set %y 0.86 
  }
}
on *:TEXT:*:#: {
  if ($1 == !bar) { msg # Welcome $nick $+ , welcome to the bar! On today's menu we have, !coke , !coffee , and !chips }
  if ($1 == !milk) { describe # Bot hands $nick a teaspoon of milk. }
  if ($1 == !sugar) { describe # Bot hands $nick a teaspoon of sugar. }
  if ($1 == !bill) && (coffee isin %coffee) { msg # $nick $+ , you bought %coffee which cost:  $+ %x | msg # $nick !cash or !card ? }
  if ($1 == !bill) && (chips isin %chips) { msg # $nick $+ , you bought %chips which cost:  $+ %y | msg # $nick !cash or !card ? }
  if (coffee isin %coffee) && (chips isin %chips) { 
    msg # $nick $+ , your total comes down to:  $+ $bill | Do you wish to pay by !cash or !card ?
  }
  if ($1 == !cash) { describe # Bot took $nick $+ 's cash for the purchase and gave $nick a receipt. }
  if ($1 == !card) { describe # Bot took $nick $+ 's card for the purchase and match $nick $+ 's ID and signature. }
  elseif ($1 == !bill) && (coffee !isin %coffee) && (chips !isin %chips) { 
    msg # $nick $+ , you haven't bought anything yet. 
  }
  if ($regex($1-,[!](black|white))) {
    if ($regml(1) == black) { 
      describe # Bot hands $nick a cup of black coffee.
      .timerwb1 1 3 msg #  Any !milk or !sugar? 
    } 
    if ($regml(1) == white) { 
      describe # Bot hands $nick a cup of white coffee.
      .timerwb1 1 3 msg #  Any !milk or !sugar? 
    }
  }
}

Re: Racking up a bill. [Re: RusselB] #205938 03/11/08 07:56 PM
Joined: Oct 2008
Posts: 167
S
seanturner70 Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Oct 2008
Posts: 167
Ok, I am starting to struggle.

I think I need to drop doing the Full thing at first...

So, I am starting with:
Code:
on 1:text:*:#: {
 if ($me == no-nick) {
  if !bar { msg $chan 11 Hello $nick Welcome To Bullets Bar We Have on the menu today || $&
      !Beer , !Coffee , !Nuts , !Haribos , !Water , !Coke , !Pepsi , !Cola , !Chips , !ChickenWings , !Pizza.6 We also have !desserts 3 Remember to pay by typing, !bill } 
  if !Beer { msg $chan Heres13 Your Beer 11 $nick }
 {
{   


I am unsure how you would make the bill go up, and if I am doing it right just now.

Re: Racking up a bill. [Re: Tomao] #205940 03/11/08 08:02 PM
Joined: Oct 2008
Posts: 167
S
seanturner70 Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Oct 2008
Posts: 167
Thanks Tomao, But I think I will follow Horstl's advice.

Also, that script seems to flood - idk why.

Re: Racking up a bill. [Re: seanturner70] #205959 04/11/08 07:05 AM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
I just have an idea that you can convert the code you've shown here into something as such:

Code:
on *:TEXT:!bar:#: { 
  msg # $nick $+ , welcome to Bullets Bar! Here are what we have on the menu today:
  var %m = !Beer !Coffee !Nuts !Haribos !Water !Coke !Pepsi !Cola !Chips !ChickenWings !Pizza !desserts
  var %x = 1 | while $gettok(%m,%x,32) { inc %x | msg # 4 $+ $v1 }
} 

Last edited by Tomao; 04/11/08 07:19 AM.
Re: Racking up a bill. [Re: Tomao] #206099 07/11/08 05:22 PM
Joined: Oct 2008
Posts: 167
S
seanturner70 Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Oct 2008
Posts: 167
Hmm... I don't understand that.

Re: Racking up a bill. [Re: seanturner70] #206104 07/11/08 07:57 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Originally Posted By: seanturner70
Ok, I am starting to struggle.

I think I need to drop doing the Full thing at first...

So, I am starting with:
Code:
on 1:text:*:#: {
 if ($me == no-nick) {
  if !bar { msg $chan 11 Hello $nick Welcome To Bullets Bar We Have on the menu today || $&
      !Beer , !Coffee , !Nuts , !Haribos , !Water , !Coke , !Pepsi , !Cola , !Chips , !ChickenWings , !Pizza.6 We also have !desserts 3 Remember to pay by typing, !bill } 
  if !Beer { msg $chan Heres13 Your Beer 11 $nick }
 {
{   


I am unsure how you would make the bill go up, and if I am doing it right just now.



Floods? Look at your brackets... also ... !bar ? !beer? These are not variables or custom identifiers.

Allow me to explain the basic idea. With scripting the toughest part is figuring out how you want to do things. Once you have this figured out it's very easy to find the commands and identifiers and events you need to make it happen.

Let's make it real easy using an ini file to store customers purchases. Let's just assume money is unlimited and they can order whatever they like first.

A person orders a milk, script knows milk is $5. So you would want to $calc their existing bill PLUS $5.

Let's name the ini file bar.ini. We can name the section after the room later if you like, in case you want a seperate bill for each room you run it in. For now let's just make one big section for all customers. Name it bar.

Quote:
bar.ini

[bar]
Johnny=5
Mary=10


So! $readini(bar.ini,bar,Johnny) == 5

Johnny orders a beer that costs $7. So then the script will ...

Code:
/writeini bar.ini bar Johnny $calc($readini(bar.ini,bar,Johnny) + 7)


Now JOhnny's bill is:

$readini(bar.ini,bar,Johnny) == 12

/msg $chan Here you go $nick ! Your total bill is now $readini(bar.ini,bar,Johnny) $+ ! Thank You!

Not too tough yeah?

Now JOhnny wants to pay so you give him a command. "!pay 7"

When Johnny does this command the script will basically use $calc to subtract the amount he chose to pay from the amount in the ini file. You will want to check to make sure he has a balance owed and make sure his payment doesn't exceed it. Or maybe you will allow them to pay forward and give themselves a negative balance (future credit).

That's pretty much it! Keep it simple at first. Create the infrastructure, the basic engine for the bar game. Once it is smoothly running you can start adding features.

Re: Racking up a bill. [Re: DJ_Sol] #206106 07/11/08 08:04 PM
Joined: Oct 2008
Posts: 167
S
seanturner70 Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Oct 2008
Posts: 167
Kinda understanding... I will try.