I’m basically trying to post from one script to this controller script in a collection in a different folder, I’ve tried consulting the documentation with no avail.
go.property("speed", 20)
local enemy_spawn_heights = {115, 370, 625}
function init(self)
--here is where the problem is
msg.post("main:/resources/environment/platforms/controller#script", "set_speed", { speed = self.speed })
end
function update(self, dt)
-- Maybe spawn a platform at random height
if math.random() < 0.2 then
local h = enemy_spawn_heights[math.random(#enemy_spawn_heights)]
factory.create("#enemy_factory", vmath.vector3(1700, h, 0), nil, {}, 1)
end
end
The filesystem folder structure is not used at all with runtime message passing address paths. You need to load the collection either directly or by a proxy and then you can send messages to it.
If you need the url for a particular script, put the following line somewhere in the script (probably in the ‘init’ function) then run the code and check the output in your console window.
No avail :(, what I did was create a GO in the main.collection and then added a collectionproxy to the original platforms.collection. Is that incorrect?
Also is there no way to directly post to the original platforms.collection?
The id a game object gets depends on its position in the build time collection hierarchy.
Collection proxies are used to dynamically load a new world (collection) into the runtime. It does not sound like that is what you intend to do, right? What you probably want is to just add the collection to main in the editor.
Ok, that makes a lot more sense, I read through that article already but I think maybe I need some sleep to absorb it in, I’ll report in tomorrow! Thanks everyone!