Display of Time of Day

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

DexterNemrod
Inserter
Inserter
Posts: 31
Joined: Mon May 13, 2013 12:54 pm
Contact:

Display of Time of Day

Post by DexterNemrod »

Or to say it alternatively:
Display of, how many time of Sunlight ( or night ) remains, till the condition changes.
(could also be some kind of graphical display ... maybe a small display of a sun/moon that appears on some horizon on the left, then rises till the middle of the display and finally sinks and vanishes at the right of the display)

I don´t know how the others do it, but I usually prefer to stay/work in the well lit conditions of my base/s during the nighttime and only venture into the wilderness during the night.
Therefore, especially if I am planning long distance voyages into the wilderness, it would be extremly useful for me to know if there is enough daytime remaining (or if I rather should stay at home and do it at the beginning of the next day)

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Display of Time of Day

Post by ssilk »

Other ways to display it:
- Shadows of the buildings/trees changes
- The light has different colors. Day: White, Morning/Evening: Red, Night: Blue
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

User avatar
metzyn
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Tue Mar 19, 2013 10:49 pm
Contact:

Re: Display of Time of Day

Post by metzyn »

I made a quick mod that shows you the time of day. It doesn't look nice or anything as the GUI API seems a bit buggy, however it does work. I used that as a good indicator.
Factorio Modder
Solar Expansion

MF-
Smart Inserter
Smart Inserter
Posts: 1235
Joined: Sun Feb 24, 2013 12:07 am
Contact:

Re: Display of Time of Day

Post by MF- »

Perhaps one could build such device in-game by observing the power output of a solar panel?

User avatar
metzyn
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Tue Mar 19, 2013 10:49 pm
Contact:

Re: Display of Time of Day

Post by metzyn »

MF- wrote:Perhaps one could build such device in-game by observing the power output of a solar panel?
LOL... yup, just look at the power output of a solar panel to get a good indication.
Factorio Modder
Solar Expansion

DexterNemrod
Inserter
Inserter
Posts: 31
Joined: Mon May 13, 2013 12:54 pm
Contact:

Re: Display of Time of Day

Post by DexterNemrod »

Made ony myself now as well by using getdaytime() and doing an array lookup to convert it into a 24hour timescale, although it is rather rudimentary by now.
Still have to find out how the heck I can change the text color of labels from black to another (white, for example).
At the moment the label is rather difficult to read because of its black color :D

kovarex
Factorio Staff
Factorio Staff
Posts: 8195
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Display of Time of Day

Post by kovarex »

https://forums.factorio.com/wiki/inde ... Properties
https://forums.factorio.com/wiki/index.php/Lua/Font

so, you can write for example:

Code: Select all

mylabel.font={color={r=1, g=1, b=1}, bold=true}
To have bold white colored label.

DexterNemrod
Inserter
Inserter
Posts: 31
Joined: Mon May 13, 2013 12:54 pm
Contact:

Re: Display of Time of Day

Post by DexterNemrod »

Thanks a lot.

I already tried several approaches but was stumped, as even those approaches that didn´t give me errors didn´t change the color.
And even your approach didn´t change the color (initially).

It turned out that I made 2 errors ... the first one was (in my own approaches) to use round brackets instead of curly ones,
the second (which also affected my first trial with your approach) was, to assume that the changed mod would also affect games that had been saved (under an earlier version of the mod).
After starting a new game, I now have a nice white display of the time of day in the upper left corner :)

I think I will put it into the mod-library (after some tweaking with the numbers saved in the array ... I divided a 24 hours day into 10 equidistant chunks ... but for some reason the dark hours of the night seem to be rather short (only 0.25 of the total 1 time units) ... tweaking the array so that the distances between the hours in the night are bigger in my array will do the trick)

User avatar
metzyn
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Tue Mar 19, 2013 10:49 pm
Contact:

Re: Display of Time of Day

Post by metzyn »

This is the code I use to display a digital clock at the top-left of the screen. I put this in "control.lua" file for a new mod I'm working on.

Code: Select all

require "defines"

game.oninit(function()
	game.player.gui.left.add{
		type="label",
		name="label_time",
		caption="time"
	}
end)

game.onevent(defines.events, function(event)
	if event.name == defines.events.ontick then
	
		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) - (time * 24)))
		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)
Factorio Modder
Solar Expansion

Post Reply

Return to “Ideas and Suggestions”