Author Topic: Building a custom command/text file for an overall stream goal counter  (Read 5984 times)

0 Members and 1 Guest are viewing this topic.

Santosvella

  • Youngling
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
  • Twitch Name: Santosvella
Hey guys,

Longtime DB user here.
As the title indicates, I'm trying to build a custom overall stream goal counter (such as the ones you often see for donations, subs, etc... except this one would combine all of these in one "score").

Basically, I'd be giving point values to:

Donations, 1€ = +1pt
Cheer, 100Bits = +1pt
Subs, 1 sub point = +5pt
And (maybe, not sure about that one) Follows, 1 new follow = +1pt

I'd need my custom text file/command to combine and add up all of these, giving me an overall score for the session.
I.e 20€ donated, 1000 Bits cheered, 3 Tier1 subs, 1 Tier2 sub, 7 followers = 20*1 + 10*1 + 3*5 + 1*10 + 7*1 = +62pts total

I'd need also need to be able to reset that file whenever I want, so it would only account for a period of my choosing (which should pretty much be every stream/day).

Once I have that custom output, I'll turn it into a an onscreen progression bar, but I know how to do that.
I also realize I could just build a command to manually increment a counter when each of the previous event occurs, but that sounds impractical while streaming and prone to error, so I'd rather find a way to automate it if such a thing is possible.

And hopefully it will, with your help.

ThatGirlSlays

  • Youngling
  • *
  • Posts: 42
  • Karma: +0/-0
    • View Profile
    • Instagram
  • Twitch Name: ThatGirlSlays
I will brainstorm how to do this. But for the progress bar, a portion, if not all of it, will have to be a web file. It could potentially be hosted on your local machine. However, you potentially could have a session that exceeds your goal. You would have to set some sort of goal whether it's 100 pts, 250 pt, 1000 pts, etc and then a percentage will be calculated which will drive how large/far the bar appears. It's possible that your points could exceed the goal in which case your bar would appear as full. You would have to think about whether or not, when you reset/clear the progress bar, should the new bar start at 0 or should it pre-fill with whatever value was in excess. So for example, you might have a goal of 50 and you might make it to 75 in one stream. If you set to reset/clear, should the next bar start at 0 or 25?

Santosvella

  • Youngling
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
  • Twitch Name: Santosvella
Hi there,

Thanks a lot for for your reply, to be honest I had lost hope of getting help from this forum.

To answer your question, the way I have my current system set up is I have both a customized donation goal and subgoal on Tipeeestream, as progression bars and added this to the CSS in OBS:

.gauge-fill {
    background-color:transparent;
    background:url(https://i.imgur.com/e5fiCRa.png) right no-repeat;

I made the gauge fill image twice the size of the gauge itself, and with 2 different-colored sections, so what happens is the 1st half of the image gradually fills the bar as we get near the goal, and if we go over the goal the gauge starts being filled with the 2nd half of the image, indicating that we're basically filling a 2nd gauge over the 1st one. And if I wished I could repeat this process with a 3rd, 4th, etc... full "bar".
I'd like to keep something similar with this project, i.e visually indicate that we went over the goal for a single session, but definitely restart at 0 when I clear/reset the file for the next session.

This system visually works well, the problem is that I'm forced to have a separate progression bar for donations, subs and follows, while cheers for some reason simply can't be used as a goal variable on Tipeee (despite obviously being correctly recorded by the site).

What I want to do is COMBINE donation/subs/follows/cheers into a single custom daily gauge/goal using a "score" system that I previously outlined, for a more elegant, streamlined and less screen-cluttering solution.

So to be clear, while I realize turning the output current "score" + goal into a visual gauge/progression bar will require some html/CSS/JS work later down the line, my main issue right now is with the previous step, i.e finding how to combine donations/follows/subs of various tiers/cheers, assign a point value to each, output a result and have all of that be over a single, over a session length that'd be easy to customize and reset at will. 

Santosvella

  • Youngling
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
  • Twitch Name: Santosvella
As for the gauge itself, I'm thinking of using a 3 quarters circle shape, similar to variant 2 on this page:
http://bernii.github.io/gauge.js/

But without text, and using a custom image as gauge fill to make it more visually appealing.

ThatGirlSlays

  • Youngling
  • *
  • Posts: 42
  • Karma: +0/-0
    • View Profile
    • Instagram
  • Twitch Name: ThatGirlSlays
Re: Building a custom command/text file for an overall stream goal counter
« Reply #4 on: August 07, 2018, 02:21:43 AM »
Well you can simply add up the points as each event happens to one master file that you would then wipe clear whenever you wanted.

Create a new folder in your "custom logs" folder and name it "Goal". Then inside, create the following text files:
  • TotalScore.txt - leave empty, this will add up the total score.
  • FollowerScore.txt - Save the content of this to how many points you want to add whenever someone follows. So in your case that would be 1.
  • SubScore.txt - Save the content of this to how many points you want to add whenever someone subs. So in your case that would be 5.
  • DonationScore.txt - Save the content of this to how many points you want to add whenever someone donates. So in your case that would be 1 PER Euro.
  • BitScore.txt - Save the content of this to how many points you want to add whenever someone cheers. So in your case that would be 1 PER 100 bits.
  • BitThreshold.txt - Save the content of this to how many bits are required before a new point is added. So  in your case that would be 100.
  • BitProgress.txt - leave empty, this will contain a count of the bits you have received.

**Storing this information in text files as opposed to entering the values directly in the command will allow for easier updates if you ever want to adjust the values.

So for your follower notification, you could have the message "!newfollower @user@", then you create a command called "!newfollower" which the message of that would be "@target@ Just followed the channel @savefile@[Goal/TotalScore.txt,@calc@[+|0@readfile@[Goal/TotalScore.txt]|0@readfile@[Goal/FollowerScore.txt]]]". Set the access of this command to Streamer/Bot.

The same would be the case for both subs and donations because it's an easy 1 event (sub or donation) adds X points. For donation you will have to use @calc@ to multiply the DonationScore.txt to the amount of Euros the person has donated. Bits will be more complicated because you will only add points when a certain threshold is reached. We are not going to use the Cheer Notifications settings variables @current@ and @target@ for this because I haven't found an automatic way to clear these values (you must manually go in and press the "reset" button) so instead, we are going to save the bits you have received to a text file (BitProgress.txt) which will allow you to easily clear the value with the rest of the text files.

For your Cheer Notification settings, enter the message "!newcheer @user@ @amt@" <== PLEASE KEEP IN MIND I DON'T HAVE ACCESS TO MY DEEPBOT AT THE MOMENT SO I CAN'T RECALL IF THE AMOUNT VARIABLE IS WRITTEN AS @amt@ OR @amount@

Then create a new command called "!newcheer" and enter the message: "@target@[1] just cheered @target@[2] Bit@if@[>||@target@[2]||1||s||]. @savefile@[Goal/BitProgress.txt,@calc@[+|0@readfile@[Goal/BitProgress.txt]|@target@[2]]]". Set the access of this command to Streamer/Bot.

Chain this command to another command "!newcheer2". Create a new command called "!newcheer2" and enter the message: "@if@[@customapi@[http://api.thatgirlslays.com?divisible=@readfile@[Goal/BitProgress.txt]~@readfile@[Goal/BitThreshold.txt]]||true||@savefile@[Goal/TotalScore.txt,@calc@[+|0@readfile@[Goal/TotalScore.txt]|0@readfile@[Goal/BitScore.txt]]]||]".

What ^ those commands are doing is say someone had already cheered 30 bits and then someone new cheers 60 bits, !newcheer is going to update the BitsProgress.txt file and save the value as 90. !newcheer2 is going to check whether or not 90 is divisible by 100 with no remainder. And if so, it will award a point to the TotalScore.txt

Also, I'm too lazy to do this right now but you need further logic for if someone donates 200 or more bits. It should calculate 2 points for 200 bits, 3 points for 300 bits etc. That's much more involved logic and I'm too tired to write out.

Anyways, that will get you started in calculating a total score. Then of course you will need HTML, CSS, and possibly JS to display and animate a bar. I would recommend creating an additional file called "Goal/Maximum.txt" and save this whatever your goal of points to reach is for example, 100. This will help you when it comes time to display your progress bar. You would simply divide the TotalScore.txt by the Maximum.txt and then multiply by 100 and that will be the percent you need to see the progress width or location at (as a percentage out of 100).

Lastly, to reset progress whenever you want simply create a command called !cleargoal and set the access as Streamer/Bot only. The message of this will be "@savefile@[Goal/TotalScore.txt,0] @savefile@[Goal/BitProgress.txt,0]".


PLEASE VERIFY ALL CODE BEFORE USING IN PRODUCTION AS I AM WRITING IT AT THE TOP OF MY HEAD WITHOUT ACCESS TO MY DEEPBOT FOR TESTING.

Santosvella

  • Youngling
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
  • Twitch Name: Santosvella
Re: Building a custom command/text file for an overall stream goal counter
« Reply #5 on: August 22, 2018, 07:06:15 AM »
Well you can simply add up the points as each event happens to one master file that you would then wipe clear whenever you wanted.

(...)

PLEASE VERIFY ALL CODE BEFORE USING IN PRODUCTION AS I AM WRITING IT AT THE TOP OF MY HEAD WITHOUT ACCESS TO MY DEEPBOT FOR TESTING.

I was travelling abroad for the last few weeks and didn't think of checking back on this thread but thank you so, so much for taking the time to write this up.
It looks like this is pretty much everything I wanted (with the small exceptions of allocating extra points for tier 2 and tier 3 subs, but I'll either try and find a workaround for that, or just live with it).
You're amazing.