[MOD 0.4.x] Factorio Clock

Topics and discussion about specific mods
DexterNemrod
Inserter
Inserter
Posts: 31
Joined: Mon May 13, 2013 12:54 pm
Contact:

[MOD 0.4.x] Factorio Clock

Post by DexterNemrod »

A tiny mod that displays the hour of day in 24h format in the upper left corner.
Very useful if you want to estimate how much time of night (or day) there is still left.
It begins to darken around 17/19 o`clock and the sun rises again around 4/5 o clock in the morning.
(the game only has 25% of its time as dark hours ... much less than you´ll find in a normal european night ... therefore I skipped a few night hours, to present a clock/cycle that somehow resembles the one we have on earth ... so don´t be astonished if hours pass by very fast during the night :D )

That´s what it looks like (in upper left corner):
Factorio_Clock_2.jpg
Factorio_Clock_2.jpg (500.55 KiB) Viewed 15170 times
Factorio_Clock_2b.jpg
Factorio_Clock_2b.jpg (8.68 KiB) Viewed 15170 times
Attachments
TimeOfDay.rar
Unrar the folder and put into mods-folder. You´ll have to start a new game for the mod to take effect
(734 Bytes) Downloaded 744 times
User avatar
metzyn
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Tue Mar 19, 2013 10:49 pm
Contact:

Re: [Mod 1.0]Factorio Clock

Post by metzyn »

Sweet! I made a clock myself quite similar in the format HH:MM, but the time didn't speed up during the night to resemble Earth-based timing. I do like that you made it resemble our time as it might be easier to use it for tracking day/night cycles.
Factorio Modder
Solar Expansion
kovarex
Factorio Staff
Factorio Staff
Posts: 8207
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [Mod 0.4.x]Factorio Clock

Post by kovarex »

The night is shorter to make it less annoying, I think it would be better to not speed it up and just live with the fact that night is 8 hours.
DexterNemrod
Inserter
Inserter
Posts: 31
Joined: Mon May 13, 2013 12:54 pm
Contact:

Re: [Mod 0.4.x]Factorio Clock

Post by DexterNemrod »

Well, I am definitely not against the fact that the period of darkness is so short and will support to keep it this way.

But from a human psychology standpoint I for my part definitely find it better to have the night start/end at clock times that I intuitively connect with the start/end of night (instead of the unusual clock times for the start/end of darkness that we get when we divide a 24 hour clock into equidistant chunks). Especially as the skipping of hours only takes place in the (more unimportant) hours of night, while the important day hours (with the exception of noon which takes 2 chunks) are divided into 1 hour chunks

But changing my mod into other hour values (maybe even to AM/PM format) is rather easy ... people just have to change the array content into hour values of their liking and, of course, are free to do so if they wish :)
User avatar
metzyn
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Tue Mar 19, 2013 10:49 pm
Contact:

Re: [Mod 0.4.x]Factorio Clock

Post by metzyn »

I'm just going to leave this here...

Code: Select all

require "defines"

game.oninit(function()

	-- create label
	game.player.gui.left.add {
		type="label",
		name="label_time",
		caption="______"
	}
end)

game.onevent(defines.events, function(event)
	if event.name == defines.events.ontick then
	
		-- format label
		game.player.gui.left.label_time.font = {
			color = {r=1, g=1, b=1},
			bold = true
		}
		
		-- format time
		local time = game.getdaytime()
		time = time + 0.5
		if time > 1 then
			time = time - 1
		end
		
		-- format hour
		local hour = math.floor(time * 24)
		local meridiem = "AM"
		if hour > 12 then
			hour = hour - 12
			meridiem = "PM"
		end
		
		-- format minute
		local minute = math.floor(60 * ((time * 24) - math.floor(time * 24)))
		if minute < 10 then
			minute = "0" .. minute
		end
		
		-- display time
		game.player.gui.left.label_time.caption =
			hour .. ":" .. minute .. " " .. meridiem
			
	end
end)
What does it do? Displays the time in HH:MM format with AM/PM.
Factorio Modder
Solar Expansion
ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: [Mod 0.4.x]Factorio Clock

Post by ficolas »

what about checking if the player haves a clock item in the inv?
User avatar
metzyn
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Tue Mar 19, 2013 10:49 pm
Contact:

Re: [Mod 0.4.x]Factorio Clock

Post by metzyn »

ficolas wrote:what about checking if the player haves a clock item in the inv?
That's a great idea!
Factorio Modder
Solar Expansion
zlosynus
Global Moderator
Global Moderator
Posts: 114
Joined: Sat Feb 09, 2013 2:17 am
Contact:

Re: [Mod 0.4.x]Factorio Clock

Post by zlosynus »

Cool mod, it is really useful. But it might be nice to add also minutes, so one could have more accurate information how the day progresses.
kovarex
Factorio Staff
Factorio Staff
Posts: 8207
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [Mod 0.4.x]Factorio Clock

Post by kovarex »

Hi, I took a look at your mod.
It is better to register the event only on the type you need, this saves the performance, and also makes the code more simple.

This code registeres the event to all events defined in the devines.events table

Code: Select all

game.onevent(defines.events, function(event)
If you write it like this, it will only be called for the ontick event, so you can also get rid of the if checking that the event is of type ontick

Code: Select all

game.onevent(defines.events.ontick, function(event)
In 0.5, the font will not work anymore, as the gui appearence is controlled by the style attribute, so the command will have to be written like this:

Code: Select all

  game.player.gui.left.dn_clock.style.font = "default-bold"
DexterNemrod
Inserter
Inserter
Posts: 31
Joined: Mon May 13, 2013 12:54 pm
Contact:

Re: [MOD 0.4.x] Factorio Clock

Post by DexterNemrod »

Oops, had I looked into my htread a little bit earlier I wouldn´t have had to ask about the font-problem.

Well, new version of the Clock-Mod for version 5.2 of Factorio.
Now, with minutes (as zlosynus wanted) and using the format that kovario suggested (with ontick-specific event requery).

I dropped my former method of putting more hours into the nighttime (i.e. letting minutes/hours pass faster during the night)
therefore we now have the start of dusk around 19:00 and the end of dawn around 4:00 with the darkest time being between 22:30 and 1:00
Attachments
TimeOfDay.rar
Unpack into your mod-folder ... only use if you have Factorio version >= 5.2
(747 Bytes) Downloaded 474 times
orion420
Inserter
Inserter
Posts: 24
Joined: Fri Jun 06, 2014 12:12 am
Contact:

Re: [MOD 0.4.x] Factorio Clock

Post by orion420 »

Hey cool mod kinda should be Vanilla. Totally BUMPing this
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3716
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: [MOD 0.4.x] Factorio Clock

Post by DaveMcW »

Here is a version compatible with Factorio 0.10.8.
Attachments
TimeOfDay_0.10.8.zip
(837 Bytes) Downloaded 299 times
Last edited by DaveMcW on Sat Aug 23, 2014 6:39 pm, edited 1 time in total.
Turtle
Fast Inserter
Fast Inserter
Posts: 240
Joined: Sat May 31, 2014 9:45 pm
Contact:

Re: [MOD 0.4.x] Factorio Clock

Post by Turtle »

DaveMcW wrote:Here is a version compatible with Factorio 0.10.8.
This mod still works fine in 0.10.8. It'll probably break in 0.11.0 when version numbers are required though.
NicoH
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sun Aug 17, 2014 1:09 am
Contact:

Re: [MOD 0.4.x] Factorio Clock

Post by NicoH »

Turtle wrote:
DaveMcW wrote:Here is a version compatible with Factorio 0.10.8.
This mod still works fine in 0.10.8. It'll probably break in 0.11.0 when version numbers are required though.
Versionnumbers are already required in 0.10.8. I can't install a mod without having the version number in the foldername.
Turtle
Fast Inserter
Fast Inserter
Posts: 240
Joined: Sat May 31, 2014 9:45 pm
Contact:

Re: [MOD 0.4.x] Factorio Clock

Post by Turtle »

NicoH wrote:
Turtle wrote:
DaveMcW wrote:Here is a version compatible with Factorio 0.10.8.
This mod still works fine in 0.10.8. It'll probably break in 0.11.0 when version numbers are required though.
Versionnumbers are already required in 0.10.8. I can't install a mod without having the version number in the foldername.
From https://forums.factorio.com/forum/vie ... =14&t=5364:
"The filename format without version number is deprecated since 0.10.7 and will eventually (in 0.11.0, probably) be completely disabled."

Mods without version numbers work for me.
OBAMA MCLAMA
Filter Inserter
Filter Inserter
Posts: 337
Joined: Fri May 30, 2014 4:23 am
Contact:

Re: [MOD 0.4.x] Factorio Clock

Post by OBAMA MCLAMA »

Currently in 0.10.8 it just requires all the modnames to be lowercase, in 0.11.0 it will be required to include the version with the name.
When i stream twitch i always answer questions and try to help, come visit me.
Post Reply

Return to “Mods”