This is the code I am running. When I start a new game, I get the clock label in the upper left corner but it never changes. None of the four test lines in the on_tick function do anything. Does anybody know what's wrong here?
Code: Select all
local function create_clock(playerindex)
local player = game.players[playerindex]
player.gui.left.add{type="label", name="clock", caption="clock"}
player.gui.left.clock.style.font_color = {r=1, g=1, b=1}
player.gui.left.clock.style.font = "default-bold"
end
script.on_event(defines.events.on_player_created, function(event)
create_clock(event.player_index)
end)
script.on_event(defines.events.on_tick, function(event)
for playerindex, player in ipairs(game.players) do
if (player.gui.left.clock == nil) then
create_clock(playerindex)
end
-- the next four lines test to make sure this function works
player.gui.left.clock.caption = "Hello"
game.players[playerindex].gui.left.clock.caption = "Hello"
game.players[playerindex].print("Hello")
player.print("Hello")
end
end)