mIRC Home    About    Download    Register    News    Help

Topic Options
#259916 - 10/02/17 04:41 PM .ini file: Counting how often a value occurs
VijoPlays Offline
Ameglian cow

Registered: 06/01/17
Posts: 20
Loc: Germany
Hello there!
I'm currently working on a song rater (where any person can do a !rate and the bot will write the number down for each song/person).

The only problem that I yet face is, that I want to see the values, so I can pull the average. I already have the line part down, so all that is left to do is count how many 1's, 2's (etc.) are in the file/song.

The file looks like that:

[Song]
$nick = value
$othernick = othervalue
[song]
$nick = otherothervalue

(I guess you can imagine the rest.)

Could you tell me how I can retrieve the amount of 1's/2's (etc.) or maybe even how I can retrieve all the values at once?


Thanks in advance!
_________________________
Streaming games on Twitch, while guiding and helping other players!
www.twitch.tv/vijoplays

Top
#259919 - 10/02/17 05:23 PM Re: .ini file: Counting how often a value occurs [Re: VijoPlays]
splinny Offline
Fjord artisan

Registered: 14/05/15
Posts: 246
[song1]
0=nick1 nick2 nick3 nick4 nick5 nick6 (all rated users)
1=nick1 nick2 nick3
2=
3=
..
10=nick4 nick5 nick6

You can use $istok to check for nick in 0-row (if user already rated) and $numtok to count total nicks in row.


Edited by splinny (10/02/17 05:24 PM)
_________________________
Dont give a fish - teach to fish!
whisper-bot

Top
#259921 - 11/02/17 12:04 AM Re: .ini file: Counting how often a value occurs [Re: splinny]
VijoPlays Offline
Ameglian cow

Registered: 06/01/17
Posts: 20
Loc: Germany
As I do not have this layout, I would like to know how I could script MiRC for this.

Right now I have all songs listed and below that one the different nicks and with them the ratings they gave.

Small example:

[Finish me - Trance]
vijoplays=4
whitestar=7

[Dota - Basshunter]
vijoplays=7

I would prefer the 'search for number' way, but I'm fine for any other one!
_________________________
Streaming games on Twitch, while guiding and helping other players!
www.twitch.tv/vijoplays

Top
#259924 - 11/02/17 05:04 PM Re: .ini file: Counting how often a value occurs [Re: VijoPlays]
splinny Offline
Fjord artisan

Registered: 14/05/15
Posts: 246
If you need only average rating for song:
Code:
[Finish me - Trance]
nicks=vijoplays whitestar
rates=4 7
[Dota - Basshunter]
nicks=vijoplays
rates=7

So you will need to check if new $nick is already in "nicks" and if not - add $nick to "nicks" line and his rate to "rates". To get average use loop from 1 up to $numtok(your.ini,songname,rates).
_________________________
Dont give a fish - teach to fish!
whisper-bot

Top
#259927 - 11/02/17 08:21 PM Re: .ini file: Counting how often a value occurs [Re: splinny]
VijoPlays Offline
Ameglian cow

Registered: 06/01/17
Posts: 20
Loc: Germany
And how am I supposed to bring mIrc to write like that?

Quote:
[Finish me - Trance]
nicks=vijoplays whitestar
rates=4 7
[Dota - Basshunter]
nicks=vijoplays
rates=7


When writing to .ini files they will always delete values and the switches from the normal /write command do not work here, so what command do I have to use there?
Already tried using seperate .txt files for each song, but I doubt it's possible to make the bot write each of the songs as .txt files.

I appreciate all the help, but I'd like to know how I can make this work, as the bot overwrites all the values this way.
_________________________
Streaming games on Twitch, while guiding and helping other players!
www.twitch.tv/vijoplays

Top
#259929 - 11/02/17 08:25 PM Re: .ini file: Counting how often a value occurs [Re: VijoPlays]
splinny Offline
Fjord artisan

Registered: 14/05/15
Posts: 246
save old data to %var, write again %var + new data
_________________________
Dont give a fish - teach to fish!
whisper-bot

Top
#259933 - 12/02/17 03:17 PM [Solved] ini file: Counting how often value occurs [Re: splinny]
VijoPlays Offline
Ameglian cow

Registered: 06/01/17
Posts: 20
Loc: Germany
And thank you very much! <3

Now I've got everything running, except for a few minor functions, which are not too important.

Also: Doh! I already had something similar, but I didn't think about saving the data this way... Guess I'm just a bit exhausted now.^^
_________________________
Streaming games on Twitch, while guiding and helping other players!
www.twitch.tv/vijoplays

Top