|
Joined: Jan 2015
Posts: 3
Self-satisified door
|
OP
Self-satisified door
Joined: Jan 2015
Posts: 3 |
Hey guys! So I've been working on a custom bot for my Twitch channel for a while. I have a very basic points system and was looking for a way to code a !spin command. Here's what I'd like this command to do: Allow members to !spin for a random amount, with a range from -250 to 250, of points. They're not gambling any of their previously earned points. There needs to be a time limit on how often this command can be used. I'd like it to be set at about 10 minutes, so that every 10 minutes, a person can !spin.Like I stated before, I'm new to coding things from scratch. I can edit and pick apart things relatively well, but this is what I have so far. I'm so lost, I haven't even put much effort in because I have no idea where to start. on *:TEXT:!spin:#: { var %r = $rand(-250,250) Msg # $caps($nick) You received %r points! }
Thank you!
|
|
|
|
Joined: Dec 2013
Posts: 779
Hoopy frood
|
Hoopy frood
Joined: Dec 2013
Posts: 779 |
on *:text:!spin:#: {
flood spin 600
var %r $+($iif($r(1,2) == 1,+,-),$r(1,250))
msg # $upper($nick) received %r points!
}
alias flood {
if (YOURNICK !isin $1-) {
if ($1 !isnum) {
if ($($+(%,flood.,#,.,$1),2)) { echo 4 # Flood control | halt }
set -z %flood. $+ # $+ . $+ $1 $2
}
else {
if ($($+(%,flood.,#),2)) { echo 4 # Flood control | halt }
set -z %flood. $+ # $1
}
}
} Untested
Nillens @ irc.twitch.tv Nillen @ irc.rizon.net
|
|
|
|
Joined: Apr 2014
Posts: 170
Vogon poet
|
Vogon poet
Joined: Apr 2014
Posts: 170 |
So, I kind of like the simplicity of this script and game itself. However, I'm trying to make it add/remove the points automatically but for some reason I can't. I'm using the basic !points that you see everywhere (since it's easier to find/alter scripts around) and have tried making points.ini write with %r but haven't yet gotten it. I figured it may have had something to do with there being a -,+ randomness (which I'd like to keep but if not possible, not a big deal) so I removed that from the script entirely making it just a 1-50 point win chance. But still, nothing. So, I'm thinking it's just the %r factor and using that inside of $calc isn't working? Any tips/hints would be greatly appreciated since I don't want to have to do "!points add user XX" everytime someone plays and I don't want my OP's to have to do it either. Thanks  BTW Nillen, the script you wrote works great.
Last edited by Bramzee; 08/01/15 03:35 PM.
|
|
|
|
Joined: Dec 2013
Posts: 779
Hoopy frood
|
Hoopy frood
Joined: Dec 2013
Posts: 779 |
I believe the syntax for that is doaddpoints $nick value or dorempoints $nick value - don't have the script lying around tho So, to make it clearer: Try this: on *:text:!spin:#: {
flood spin 600 $nick
var %r $r(1,250)
$iif($r(1,2) == 1,doaddpoints,dorempoints) $nick %r
}
alias flood {
if (YOURNICK !isin $1-) {
if ($1 !isnum) {
if ($($+(%,flood.,#,.,$1),2)) { echo 4 # Flood control | halt }
set -z %flood. $+ # $+ . $+ $1 $2
}
else {
if ($($+(%,flood.,#),2)) { echo 4 # Flood control | halt }
set -z %flood. $+ # $1
}
}
}
Last edited by Nillen; 08/01/15 05:55 PM.
Nillens @ irc.twitch.tv Nillen @ irc.rizon.net
|
|
|
|
Joined: Apr 2014
Posts: 170
Vogon poet
|
Vogon poet
Joined: Apr 2014
Posts: 170 |
EDIT: Just saw your post Nillen. I'll try that now, and see how it goes. EDIT 2: So, with the old "doaddpoints" and "dorempoints" it returns the echo that $3 is not a number. Which is why I altered the alias. However, $2 is still going to be a problem I believe. Been attempting something with this, which is basically the "doaddpoints" alias.
alias spinpoints {
var %topic $+($nick,.,$2)
var %points $calc($readini(Points.ini,%topic,Points) + %r)
writeini -n Points.ini %topic Points %points
echo -a Added points for %topic
}
Now, a few things with this are: -Clearly the $2 doesn't belong there, but I'm not sure what to replace it with (usually it would be "add" or "remove" when adjusting peoples points. In this case, there is not since it's not in the "!spin" command. -Secondly, I'm not sure if it's reading the $nick correctly. When I run the script it returns the echo, but it returns it as "Added points for ." -Third, I'm not nearly experienced enough for this. And perhaps, that's the biggest flaw of all.
Last edited by Bramzee; 08/01/15 06:21 PM.
|
|
|
|
Joined: Apr 2014
Posts: 170
Vogon poet
|
Vogon poet
Joined: Apr 2014
Posts: 170 |
Alright so... I got this working. Semi. I'll paste the what I have and explain the issues after.
on *:text:!spin:#: {
flood thespin 1 $nick
var %r $r(1,250)
$iif($r(1,2) == 1,addspin) $nick %r
.timerSpinPts 1 1 msg # $nick has recieved %r points!
}
alias flood {
if (YOURNICK !isin $1-) {
if ($1 !isnum) {
if ($($+(%,flood.,#,.,$1),2)) { echo 4 # Flood control | halt }
set -z %flood. $+ # $+ . $+ $1 $2
}
else {
if ($($+(%,flood.,#),2)) { echo 4 # Flood control | halt }
set -z %flood. $+ # $1
}
}
}
alias addspin {
var %topic $+(#,.,$nick)
var %points $calc($readini(Points.ini,%topic,Points) + $2)
writeini -n Points.ini %topic Points %points
echo -a $nick $chr(91) $+ %points $+ $chr(93)
}
the problem with the "doaddpoints" thing was in the %topic set. It was setting the nick and the amount of points they earned rather than placing where the points that were previously stored were located. Fixed that (after I realized what was going on obviously... Overlooked it easily) Now, I don't have it so they can lose points, so that is the next thing to figure out on my list. But, I think I have an idea of where to start on that. The only other problems are; if more than one person does !spin at the same time the %r is all messed up and could potentially give the wrong points to each person. This is untested right now, but I'm 90% sure it's possible (correct if I'm wrong please) To fix this would I do something like "var %r. $+ $nick $r(1,250)" ?? And what else would I have to put in the "addspin" alias to be sure the points get to the correct person? Also, every now and then it echos with "USERNAME Unknown Command" and even though the game is played and points are shown in chat, it doesn't award the points. This is almost more common than it actually being successful. (roughly 3/5 times it shows "Unknown Command") Thanks 
|
|
|
|
Joined: Jan 2004
Posts: 1,361
Hoopy frood
|
Hoopy frood
Joined: Jan 2004
Posts: 1,361 |
Also, every now and then it echos with "USERNAME Unknown Command" $iif($r(1,2) == 1,addspin) $nick %r
|
|
|
|
Joined: Jan 2015
Posts: 3
Self-satisified door
|
OP
Self-satisified door
Joined: Jan 2015
Posts: 3 |
I've tried each code above, and although it spits out a random number for !spin, the points are not being added or removed. They're in my Points.ini file. Thank you all for being so helpful and for the quick replies! 
|
|
|
|
Joined: Apr 2014
Posts: 170
Vogon poet
|
Vogon poet
Joined: Apr 2014
Posts: 170 |
That one won't remove points. I have fixed it so it does remove as well, kind of? It's hard to explain really what's going on lol but I'll try. Basically, right now it will remove points and add points and I believe I've fixed the "Unknown Command" issue. Right now I want to have it so if it's going to remove points it'll say "Username LOST X Points!" and if they win it'll say "Username WON X Points!"
I've been searching for a way on youtube, google, the forums, hawkee... But I can't seem to find a way to have an "if" statement for the random options...It works, but it lies. It'll say they lost/won every time, but sometimes it'll be wrong. It will add and remove the points though. I'll post it once I get it all fixed up. Right now I have a few other things to do as well.EDIT: Here it is... on *:text:!spin:#: {
flood thespin 600 $nick
var %r $r(1,250)
$iif($r(1,2) == 1,addspin,remspin) $nick %r
}
alias flood {
if (YOURNICK !isin $1-) {
if ($1 !isnum) {
if ($($+(%,flood.,#,.,$1),2)) { echo 4 # Flood control | halt }
set -z %flood. $+ # $+ . $+ $1 $2
}
else {
if ($($+(%,flood.,#),2)) { echo 4 # Flood control | halt }
set -z %flood. $+ # $1
}
}
}
alias addspin {
var %topic $+(#,.,$nick)
var %points $calc($readini(Points.ini,%topic,Points) + $2)
writeini -n Points.ini %topic Points %points
.timerAdd 1 2 msg # $nick has won $2 points! $chr(91) $+ %points $+ $chr(93)
echo -a $nick $chr(91) $+ %points $+ $chr(93)
}
alias remspin {
var %topic $+(#,.,$nick)
var %points $calc($readini(Points.ini,%topic,Points) - $2)
writeini -n Points.ini %topic Points %points
.timerRem 1 2 msg # $nick has lost $2 points! $chr(91) $+ %points $+ $chr(93)
echo -a $nick - $2 points! Total -> $chr(91) $+ %points $+ $chr(93)
}
The problem with multiple entry's is still a question. But other than that, it's getting there. I think. lol. Also, this is still in "testing" so be aware that it is possible to go in the negative. Fixing that later, after I figure out the multiple entry thing. Really all you need to do is a pointcheck and if they have less than 1 stop them from being able to do the game.
Last edited by Bramzee; 09/01/15 12:59 AM.
|
|
|
|
Joined: Apr 2014
Posts: 170
Vogon poet
|
Vogon poet
Joined: Apr 2014
Posts: 170 |
I've got most problems solved except one.
-Only problem is that it won't message more than one user (more often than not, it's the last user to put in the !spin command)
I'l check back tomorrow for ideas and such but I think that this game is going to be enjoyable. I know I'm addicted. I had to force myself to throw on a long flood just so I could work on other stuff.
|
|
|
|
Joined: Jan 2004
Posts: 1,361
Hoopy frood
|
Hoopy frood
Joined: Jan 2004
Posts: 1,361 |
That's because you're overwriting the previous .timerAdd or .timerRem
|
|
|
|
Joined: Apr 2014
Posts: 170
Vogon poet
|
Vogon poet
Joined: Apr 2014
Posts: 170 |
So would I do .timerAdd/Rem. $+ $nick ?
idky I didn't notice that ha. Or why I'm asking. I'll give it a shot now. If that's not the fix a suggestion on how would be excellent.
Edit: So that didn't work. At all.
Last edited by Bramzee; 09/01/15 01:53 PM.
|
|
|
|
Joined: Jun 2014
Posts: 248
Fjord artisan
|
Fjord artisan
Joined: Jun 2014
Posts: 248 |
Why are the timers there anyway?
|
|
|
|
Joined: Apr 2014
Posts: 170
Vogon poet
|
Vogon poet
Joined: Apr 2014
Posts: 170 |
for some reason without them the total points show up without updating and adding what they won. I'll try again without but I'm pretty sure that's why I added them in.
|
|
|
|
Joined: Jun 2014
Posts: 248
Fjord artisan
|
Fjord artisan
Joined: Jun 2014
Posts: 248 |
You should fix problems rather than attempt to work around them.
|
|
|
|
|