| View previous topic :: View next topic |
| Author |
Message |
ComputerTech Master

Joined: 22 Feb 2020 Posts: 393
|
Posted: Fri Jun 26, 2020 11:00 am Post subject: Bar Total Amount Tab |
|
|
Hmm not exactly sure if i can explain what my idea is , but i'll try
so this idea is for my bar script and the part i am requesting is,
when a user types !beer it will do the usual putserv privmsg stuff
but the part i need to add is everytime a user types !beer it will add to a amount of say 20 per !beer command so i need a way to make it gather all of those 20's and make a total each time, almost like a bar tab , cheers in advanced all those who help me with this hehe
(I'll try and make something like above myself and post my code ) _________________ ComputerTech |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Fri Jun 26, 2020 1:13 pm Post subject: |
|
|
If you plan to extend this to other drinks as well, I suggest having a look at dict and have all the drinks like:
| Code: |
dict set drinks "beer" 20
dict set drinks "vodka" 50
dict set drinks "tea" 5
|
and can get it's price with something like:
| Code: |
[dict get $drinks $drink]
|
for example after you make sure it exist, for example:
| Code: |
if {[lsearch -nocase [dict keys $drinks] $drink] != -1} {
puthelp "PRIVMSG $chan :Price for $drink is [dict get $drinks $drink]"
}
|
_________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
ComputerTech Master

Joined: 22 Feb 2020 Posts: 393
|
Posted: Fri Jun 26, 2020 9:17 pm Post subject: |
|
|
hmm i see but this is for prices i think , would this work in gathering like this
?beer thats 5
?beer thats 10
and so on
would dict work for that?
so every time a user types ?beer it will add 5 to the total amount Until the user types
?pay _________________ ComputerTech |
|
| Back to top |
|
 |
ComputerTech Master

Joined: 22 Feb 2020 Posts: 393
|
Posted: Sat Jun 27, 2020 9:23 am Post subject: |
|
|
I think i found what i needed to use incr
http://suninet.the-demon.de/056.htm
seems to add digits to a variable, exactly what i need hehe
i'll go try it and if it works i'll post my code  _________________ ComputerTech |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Sat Jun 27, 2020 12:36 pm Post subject: |
|
|
| ComputerTech wrote: |
...
i'll go try it and if it works i'll post my code
|
And if it doesn't work, post your code if you want. You might get some help and/or ideas.  _________________ For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia ! |
|
| Back to top |
|
 |
|