Hi,
I want to recursively update all of the things within a collection so that their “team” setting is accurate.
For example
coreseg.go
go.property("team", 0)
function init(self)
print("team is", self.team)
msg.post(".", hash("update_team"), { team = self.team })
end
segment.go
function on_message(self, message_id, message, sender)
if message_id == hash("update_team") then
local tint = vmath.vector4(0, self.team/2, self.team/5, 1) -- just placeholder
go.set("#sprite", "tint", tint)
end
end
main.script
function init(self)
msg.post(".", "acquire_input_focus")
msg.post("@render:", "use_fixed_fit_projection", { near = -1, far = 1 })
local rot = vmath.quat_rotation_z(0)
local props1 = {}
props1[hash("/core")] = { team = 1 }
local props2 = {}
props2[hash("/core")] = { team = 2 }
collectionfactory.create("#hestiafactory", vmath.vector3(200,200,0), rot, props1)
collectionfactory.create("#hestiafactory", vmath.vector3(300,300,0), rot, props2)
end
The hierarchy of the object being created by #hestiafactory
looks like this:
But I’m only getting the message on the “core” node – I also want to see it on “segment11”, and “segment12”, “segment13” … etc however many segments I add automatically.
I sort of assumed that this was the core use-case of the message passing system.