33 posts
Location
127.0.0.1
Posted 21 January 2013 - 04:47 AM
Hey,
I think it would be useful to have a function or peripheral to get the current frame rate of the game, so we can switch large, lag producing machines (scrap-production for mass fabricator, giant turtle swarm, water mill power plant etc) off if the game lags too much.
Syntax could be like
.getFrameRate() -- would return the frame rate as a number
sry if its bad english, its not my native language.
264 posts
Location
United Kingdom
Posted 21 January 2013 - 04:54 AM
cant you just press "F3" and see the current FPS?
2447 posts
Posted 21 January 2013 - 04:57 AM
Definitely not. Makes no sense from the context of the game world.
33 posts
Location
127.0.0.1
Posted 21 January 2013 - 05:01 AM
cant you just press "F3" and see the current FPS?
I can, but a computer can't, so i would have switch it off manually, and traveling a long distance or even between dimensions (i have a solar power plant in a bright mystcraft dimension) with lag is a pain.
edit: maybe you didn't understand waht i meant, so here's an example script:
-- startup file on a computer far from your base
rs.setOutput("back", true) -- switches machine (e.g. timer) on
while true do
if os.getFrameRate() < 30 then
rs.setOutput("back", false) -- switches machine off again
end
sleep(60)
end
264 posts
Location
United Kingdom
Posted 21 January 2013 - 05:26 AM
ah I didnt realise you wanted to due it auto (I feel stupid now lol)
1619 posts
Posted 21 January 2013 - 05:30 AM
cant you just press "F3" and see the current FPS?
I can, but a computer can't, so i would have switch it off manually, and traveling a long distance or even between dimensions (i have a solar power plant in a bright mystcraft dimension) with lag is a pain.
edit: maybe you didn't understand waht i meant, so here's an example script:
-- startup file on a computer far from your base
rs.setOutput("back", true) -- switches machine (e.g. timer) on
while true do
if os.getFrameRate() < 30 then
rs.setOutput("back", false) -- switches machine off again
end
sleep(60)
end
Again,
Definitely not. Makes no sense from the context of the game world.
514 posts
Location
Over there
Posted 21 January 2013 - 05:40 AM
The frame rate is client-side, the code is executed server-side, this wouldn't work very well on servers.
797 posts
Posted 21 January 2013 - 08:01 AM
you can do it kind of btw using os.clock
2447 posts
Posted 21 January 2013 - 08:05 AM
Nah, not really - clock is only advanced on ticks too, and sleep works on ticks.
7508 posts
Location
Australia
Posted 21 January 2013 - 08:14 AM
Nah, not really - clock is only advanced on ticks too, and sleep works on ticks.
Is a timer ticks? If not you could get a TPS working with clock and a timer.
797 posts
Posted 21 January 2013 - 08:18 AM
you can measure how long it takes for the computer to go through your code with os.clock and sleep according to that surely?
2447 posts
Posted 21 January 2013 - 08:55 AM
Everything is based on ticks.
392 posts
Location
Christchurch, New Zealand
Posted 21 January 2013 - 10:08 AM
I had my suspicion that everything was based on ticks, which does shatter an idea I had.
Cloudy, how about the alarms, I take it they are 100% ticks also, since they use MC time which is incremented by a 20th of a second, each tick.
Well at least the game is fully synchronized, slow or fast, everything always gets the same amount of ticks.
I think the only luck beyond this would be http with a real world clock. Checking the time difference, if there is a slew of more than 40/50% you could shut down things.
2447 posts
Posted 21 January 2013 - 01:06 PM
Yes, alarms are based off ticks. Everything is based off ticks.
[media]
http://www.youtube.com/watch?v=shs7VQhVvxA[/media]
2005 posts
Posted 21 January 2013 - 01:07 PM
Or, you can just take care to program things so that they yield until they are actually needed to do something, or even shut themselves off if they aren't in use.
1054 posts
Posted 21 January 2013 - 01:20 PM
And eventually you could use the HTTP api (if available) to compare ticks with elapsed time through a time server. This would only work properly over larger intervals I suppose.
7508 posts
Location
Australia
Posted 21 January 2013 - 01:45 PM
Yes, alarms are based off ticks. Everything is based off ticks.
- video snip -
LOL!!! Nice…
2005 posts
Posted 21 January 2013 - 09:52 PM
Lister, as usual exercising less than the minimum safe hygienic discretion. "Hmm…everyone's dead, so I'll taste some of this white powder lying about."
144 posts
Location
Wellington, New Zealand
Posted 22 January 2013 - 07:56 PM
Orwell's idea would work the best. It wouldn't be possible to compare two in-game times, since they're both advancing at the same rate (Eg. The computer could think 1 second has elapsed when it actually has been 2). I'm not great at explaining.
Off-topic-ish: How does the server calculate the TPS? Does it reference other machine times?
997 posts
Location
Wellington, New Zealand
Posted 22 January 2013 - 10:14 PM
Orwell's idea would work the best. It wouldn't be possible to compare two in-game times, since they're both advancing at the same rate (Eg. The computer could think 1 second has elapsed when it actually has been 2). I'm not great at explaining.
Off-topic-ish: How does the server calculate the TPS? Does it reference other machine times?
Java code can easily access real and in-game time to compare them.