Yep, I understand what you mean. That will be slightly difficult as, apart from the update rate, Rainmeter can't measure time less than 1 second. But then, if you're ok with basing the code on the inaccurate update rate, all will be good and doable. I have some things to take care of now for a couple of hours, so I'll take a look at the required code afterwards, if death.crafter doesn't come with a feasible solution in the meantime.EnhancedJax wrote: ↑August 8th, 2021, 11:29 am Yeah. that's it.
For example, if we have a data set like this:
Sec1: 5 clicks (0 to 1)s
Sec2: 7 clicks (1 to 2)s
If the time extracting the CPS is at 1.5s, it would be the num of clicks from 0.5s to 1.5s, lets expand the data set
Column: Each 100ms, row: each sec
Sec1: 0 1 0 0 1 1 1 1 1 0
Sec2: 1 1 1 0 0 1 1 0 0 0
the CPS then would be [ 1 1 1 1 0 1 1 1 0 0 ] -> 7
If we set the "instant range" as 1, we would always get an integer, for a smoother result we could use 2 as the "instant range"... so I guess what is left is the execution?
It is currently April 26th, 2024, 10:10 pm
Instantaneous CPS algorithm
-
- Rainmeter Sage
- Posts: 7175
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Instantaneous CPS algorithm
-
- Posts: 19
- Joined: October 17th, 2020, 11:57 am
Re: Instantaneous CPS algorithm
Thanks, and take your time!
Deviant art profile: https://www.deviantart.com/jaxoriginals
-
- Rainmeter Sage
- Posts: 1399
- Joined: April 24th, 2021, 8:13 pm
Re: Instantaneous CPS algorithm
SKIN:
Code: Select all
[Rainmeter]
Update=50
[Variables]
Time=0
Clicks=0
CPS=0
[Time]
Measure=Calc
Formula=Time+0.05
DynamicVariables=1
[Lua]
Measure=Script
ScriptFile=Tester.lua
[Image]
Meter=Image
SolidColor=FEFEFE
H=69
W=50
DynamicVariables=1
LeftMouseUpAction=[!SetVariable Clicks "(#Clicks#+1)"][!CommandMeasure Lua "t[[&Time]]=[#Clicks]"]
[String]
Meter=String
X=10
Y=25
Text=#CPS#
DynamicVariables=1
Code: Select all
t={}
function Update()
e=SKIN:GetMeasure('Time'):GetValue()
s=e-1
local m={}
for k,v in pairs(t) do
if k>=s and k<=e then
table.insert(m, v)
end
end
SKIN:Bang('!SetVariable', 'CPS', table.maxn(m))
end
P.S.> Max clicks you can count is 62, at an update 16. Good luck!
2nd Edit:
If Rainmeter can keep up that is.
from the Realm of Death
-
- Posts: 19
- Joined: October 17th, 2020, 11:57 am
Re: Instantaneous CPS algorithm
death.crafter wrote: ↑August 8th, 2021, 12:38 pm SKIN:LUA:Code: Select all
[Rainmeter] Update=50 [Variables] Time=0 Clicks=0 CPS=0 [Time] Measure=Calc Formula=Time+0.05 DynamicVariables=1 [Lua] Measure=Script ScriptFile=Tester.lua [Image] Meter=Image SolidColor=FEFEFE H=69 W=50 DynamicVariables=1 LeftMouseUpAction=[!SetVariable Clicks "(#Clicks#+1)"][!CommandMeasure Lua "t[[&Time]]=[#Clicks]"] [String] Meter=String X=10 Y=25 Text=#CPS# DynamicVariables=1
P.S.> Max clicks you can count is 62, at an update 16. Good luck!Code: Select all
t={} function Update() e=SKIN:GetMeasure('Time'):GetValue() s=e-1 local m={} for k,v in pairs(t) do if k>=s and k<=e then table.insert(m, v) end end SKIN:Bang('!SetVariable', 'CPS', table.maxn(m)) end
This is exactly what I needed! Thankyou so much!
Deviant art profile: https://www.deviantart.com/jaxoriginals
-
- Rainmeter Sage
- Posts: 1399
- Joined: April 24th, 2021, 8:13 pm
Re: Instantaneous CPS algorithm
By the way nice work with the ArcTech clocks.
from the Realm of Death
-
- Rainmeter Sage
- Posts: 1399
- Joined: April 24th, 2021, 8:13 pm
Re: Instantaneous CPS algorithm
In case it causes memory leaks due to more usage(in case):
Code: Select all
t={}
function Update()
e=SKIN:GetMeasure('Time'):GetValue()
s=e-1
local m={}
for k,v in pairs(t) do
if k<s then
table.remove(t, k)
end
if k>=s and k<=e then
table.insert(m, v)
end
end
SKIN:Bang('!SetVariable', 'CPS', table.maxn(m))
end
from the Realm of Death
-
- Posts: 1
- Joined: May 18th, 2022, 7:30 am
Re: Instantaneous CPS algorithm
man I made account just to thank you. I had been struggling for a couple of days while making my CPS test that could calculate instant clicks per second. deleted everything and implemented your code and it worked in single time! kudos to you.death.crafter wrote: ↑August 8th, 2021, 12:38 pm SKIN:LUA:Code: Select all
[Rainmeter] Update=50 [Variables] Time=0 Clicks=0 CPS=0 [Time] Measure=Calc Formula=Time+0.05 DynamicVariables=1 [Lua] Measure=Script ScriptFile=Tester.lua [Image] Meter=Image SolidColor=FEFEFE H=69 W=50 DynamicVariables=1 LeftMouseUpAction=[!SetVariable Clicks "(#Clicks#+1)"][!CommandMeasure Lua "t[[&Time]]=[#Clicks]"] [String] Meter=String X=10 Y=25 Text=#CPS# DynamicVariables=1
1st Edit:Code: Select all
t={} function Update() e=SKIN:GetMeasure('Time'):GetValue() s=e-1 local m={} for k,v in pairs(t) do if k>=s and k<=e then table.insert(m, v) end end SKIN:Bang('!SetVariable', 'CPS', table.maxn(m)) end
P.S.> Max clicks you can count is 62, at an update 16. Good luck!
2nd Edit:
If Rainmeter can keep up that is.
Last edited by Active Colors on May 19th, 2022, 8:57 am, edited 1 time in total.
Reason: Removed external link
Reason: Removed external link