Page 1 of 1
GUI Label Issue
Posted: Sun May 19, 2013 9:07 pm
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?
Re: GUI Label Issue
Posted: Sun May 19, 2013 9:14 pm
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)
Re: GUI Label Issue
Posted: Sun May 19, 2013 9:18 pm
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)