This is just a simple fun script that lets you give and take away cookies.
This wasn't meant to be a serious script, Just made it for my friend to prove I could :P
Thanks jsg55 for the $newnick thing ^_^
Right click a nickname in chat and/or nicklist and it will be in the menu.
I know this probably could have been done a lot easier, I just prefer doing things the longer way :P
menu query,nicklist {
Cookie
.Give Cookies:{
if ($readini(cookies.ini, cookies, $1) != $null) {
set %g.cookies $$?="Number of cookies to give?"
writeini cookies.ini cookies $1 $calc($readini(cookies.ini, cookies, $1 + %g.cookies $+ ))
DESCRIBE $chan has given %g.cookies cookies to $1 $+ , $1 now has $readini(cookies.ini, cookies, $1) cookies!
}
else {
writeini cookies.ini cookies $1 0
set %g.cookies $$?="Number of cookies to give?"
writeini cookies.ini cookies $1 $calc($readini(cookies.ini, cookies, $1 + %g.cookies $+ ))
DESCRIBE $chan has given %g.cookies cookies to $1 $+ , $1 now has $readini(cookies.ini, cookies, $1) cookies!
}
}
.Take Cookies:{
if ($readini(cookies.ini, cookies, $1) != $null) {
set %t.cookies $$?="Number of cookies to take?"
writeini cookies.ini cookies $1 $calc($readini(cookies.ini, cookies, $1 - %t.cookies $+ ))
DESCRIBE $chan has taken %t.cookies cookies away from $1 $+ , $1 now has $readini(cookies.ini, cookies, $1) cookies!
}
else {
writeini cookies.ini cookies $1 0
set %t.cookies $$?="Number of cookies to take?"
writeini cookies.ini cookies $1 $calc($readini(cookies.ini, cookies, $1 - %t.cookies $+ ))
DESCRIBE $chan has taken %t.cookies cookies away from $1 $+ , $1 now has $readini(cookies.ini, cookies, $1) cookies!
}
}
}
on *:nick: {
if ($readini(cookies.ini, cookies, $nick) != $null) {
var %x $readini(cookies.ini, cookies, $nick)
remini cookies.ini cookies $nick
writeini cookies.ini cookies $newnick %x
}
}
WorldDMT
Yes, I understand all that and yet it won't affect 'accuracy' (once in awhile someone gets cookies and then has them taken away until they have zero and then change nicks). This script is gonna end up with a big pile of broke after awhile anyway. It's never gonna really be able to accurately keep track of cookies over any period of time anyway with people changing nicks, leaving, coming back as their original nick etc. More than anything else it needs a 'once a month empty the data file' routine.
this cant be done with a on text event?
Just make it randomize some cookie name u made up. And put it in a .txt file.
on *:text:!cookie*:#: {
if ($(,$+(%,flood,$nick))) { return }
set -u3 $+(%,flood,$nick)
var %cookie = $read(Cookie.txt)
var %cookie2 = $readini(Cookie.ini,cookie,$nick)
var %true = 1
var %false = 0
if ( %cookie2 == %true ) { notice $nick You already have a cookie. You can get rid of it by eating it. (Syntax: !eat cookie) | return }
describe $chan $2 Received a %cookie .
writeini cookie.ini Cookie $nick %true
halt
}
on *:text:!eat cookie:#: {
if ($(,$+(%,flood2,$nick))) { return }
set -u3 $+(%,flood2,$nick)
if (%cookie2 == 0) { notice $nick Sorry but you dont have a cookie. Get one by typing: !cookie | Return }
if (%cookie2 == $null) { notice $nick Sorry but you dont have a cookie. Get one by typing: !cookie | Return }
if (%cookie2 == 1) {
notice $nick You just ate your cookie!
writeini Cookie.ini Cookie $nick %false
halt
}
The -l switch restricts the alias to local so it can not be called
for instance from the command line or a different script file.
Mostly unnecessary.
Yup, the $iif() is an inline if/else condition statement.
"do extras on the end of alias's" ??? ..do you mean pass arguments?
Well, yup the cookie($1 give) passes those two items as $1 and $2
(I kept $1 first on purpose if I had said cookie(give $1) then it
could have worked just the same as long as I changed it around in
the alias to match which can get confusing.)
Okay...Now can I ask a little about that? :P
What does the -l do in the alias?
and I think this is right, but $iif is like...$iff(4 = 4,this,that) is the same as if (4 = 4) { this }
else { that }
?
And I also never knew you could do extras on the end of alias's. That's interesting...That will be helpful.
You could also maybe do something like this.
menu query,nicklist {
Cookie
.Give Cookies:cookies($1 give)
.Take Cookies:cookies($1 take)
}
alias -l cookies {
var %cookies $iif($readini(cookies.ini,cookies,$1),$v1,0)
var %x.cookies $$?="Number of cookies to $2?"
%cookies = $calc(%cookies $iif($2 = give,+,-) %x.cookies)
writeini cookies.ini cookies $1 %cookies
DESCRIBE # has $2 $+ n %x.cookies cookies $iif($2 = give,to,away from) $1 $+ , $1 now has %cookies cookies!
}
}
__________________________________________________________________________________________________________________
Hmm, Yeah, Yours is equivalent. I'm still kinda learning all this stuff, I mean, I can get a lot of stuff done, but I take a lot more steps then I end up having to.
Thanks for all the input.
And about the negatives, I wasn't really trying to avoid it. It's mostly just for fun, So giving people negative's is more fun that it saying "They don't have any cookies to take!" ;)
menu query,nicklist {
Cookie
.Give Cookies:{
var %cookies $iif($readini(cookies.ini,cookies,$1),$v1,0),%g.cookies $$?="Number of cookies to give?"
%cookies = $calc(%cookies + %g.cookies)
writeini cookies.ini cookies $1 %cookies
DESCRIBE # has given %g.cookies cookies to $1 $+ , $1 now has %cookies cookies!
}
.Take Cookies:{
var %cookies $iif($readini(cookies.ini,cookies,$1),$v1,0),%t.cookies $$?="Number of cookies to take?"
%cookies = $calc(%cookies - %t.cookies)
writeini cookies.ini cookies $1 %cookies
DESCRIBE # has taken %t.cookies cookies away from $1 $+ , $1 now has %cookies cookies!
}
}
______________________________________________________________________________________________________________
This should be functional equivalent to the original menu although you may wish do do something about taking cookies away from someone who has none thus avoiding negative cookies.
"I'm trying to figure out when someone changes their nick...It will change the ini to match the new nick. If anyone can help me with that, That'd be great :D"
how about
on *:nick: {
if ($readini(cookies.ini, cookies, $nick) != $null) {
var %x $readini(cookies.ini, cookies, $nick)
remini cookies.ini cookies $nick
writeini cookies.ini cookies $newnick %x
}
}
if thats what your asking for lol
i apologize if its not the most compact piece of work ever