My code so far:
Code: Select all
local function set_hud_position(player)
local root_frame = get_hud(player)
if root_frame then
local x = player.display_resolution.width - root_frame.style.width
local y = root_frame.location.y
root_frame.location = {x, y}
player.print("gui location: x: " .. x)
end
end
local function create_hud(player)
-- Create frame in which to put the other GUI elements
local root_frame = player.gui.screen.add {type = "frame", direction = "vertical", name = "hud-root-frame"}
if global.hud_position_map[player.index] then
local new_location = global.hud_position_map[player.index]
root_frame.location = new_location
end
local title_flow = create_frame_title(root_frame, "Circuit HUD")
-- add a "toggle" button
global.toggle_button =
title_flow.add {
type = "sprite-button",
style = "frame_action_button",
sprite = (global.hud_collapsed_map[player.index] == true) and "utility/expand" or "utility/collapse",
name = "toggle-circuit-hud"
}
local scroll_pane =
root_frame.add {
type = "scroll-pane",
vertical_scroll_policy = "auto",
style = "hud_scrollpane_style"
}
local inner_frame =
scroll_pane.add {
type = "frame",
style = "inside_shallow_frame_with_padding",
direction = "vertical"
}
global["last_frame"][player.index] = root_frame
global["inner_frame"][player.index] = inner_frame
end
Am I trying to do the impossible here?
Thanks in advance!