GUI Label Issue

Place to get help with not working mods / modding interface.
User avatar
metzyn
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Tue Mar 19, 2013 10:49 pm
Contact:

GUI Label Issue

Post by metzyn »

GUI labels are cut off and only extend to the proper length after you save the game and then load it... but if you start a new game again, the label's horizontal size gets trimmed again. Is there anyway around this or a bug?
Factorio Modder
Solar Expansion
kovarex
Factorio Staff
Factorio Staff
Posts: 8298
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: GUI Label Issue

Post by kovarex »

This is a bug (thank you for the report), Do you have some simple piece of code that shows it?
(My labels are working correctly, but I'm probably using it differently)
User avatar
metzyn
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Tue Mar 19, 2013 10:49 pm
Contact:

Re: GUI Label Issue

Post by metzyn »

kovarex wrote:This is a bug (thank you for the report), Do you have some simple piece of code that shows it?
(My labels are working correctly, but I'm probably using it differently)
This is code to display a digital clock for a new mod I'm working on... contained within my "control.lua":

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 “Modding help”