-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.gui_script
More file actions
26 lines (21 loc) · 970 Bytes
/
base.gui_script
File metadata and controls
26 lines (21 loc) · 970 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
local global = require "main.global" -- Import the module
function init(self)
self.camera_position = vmath.vector3(0, 0, 0)
self.global_pos = vmath.vector3()
msg.post(".", "release_input_focus")
self.range_node = gui.get_node("range") -- or "range_circle"
gui.set_scale(self.range_node, vmath.vector3(_G.base_range, _G.base_range, 0))
end
function on_message(self, message_id, message)
if message_id == hash("update_gui_position") then
-- 1. Get camera offset (assuming you send this too, or store it globally)
local camera_pos = _G.camera_pos -- Example: Update this when the camera moves
-- 2. Convert world position to screen space
local screen_pos = message.pos - camera_pos + vmath.vector3(750, 400, 0)
-- 3. Update the GUI node (e.g., a health bar)
gui.set_position(self.range_node, screen_pos)
end
if message_id == hash("update_base_range") then
gui.set_scale(self.range_node, vmath.vector3(_G.base_range, _G.base_range, 0))
end
end