-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.script
More file actions
43 lines (32 loc) · 1.25 KB
/
main.script
File metadata and controls
43 lines (32 loc) · 1.25 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
local config = require("scripts.config")
local background = msg.url("main", "/background", "background")
local paricles = msg.url("main", "/particles", "stars")
local background_time = vmath.vector4()
local target_pos = vmath.vector3()
local planet_ids = {}
local function load_collection(id)
if config.planets[config.current_planet].collection then
go.delete_all(config.planets[config.current_planet].collection)
end
config.current_planet = id
local name = "/collections#planet_" .. id
config.planets[id].collection = collectionfactory.create(name, target_pos, nil, nil, vmath.vector3(2.5, 2.5, 1))
config.target_script = config.planets[config.current_planet].collection[hash("/scripts")]
end
function init(self)
msg.post(".", "acquire_input_focus")
msg.post("@render:", "set_size", {width = 640, height = 360})
particlefx.play(paricles)
--profiler.enable_ui(true)
config.main_url = msg.url()
target_pos = go.get_position("target")
end
function on_message(self, message_id, message, sender)
if message_id == config.msg.load_planet then
load_collection(message.id)
end
end
function update(self, dt)
background_time.x = background_time.x + dt
go.set(background, "time", background_time)
end