Hi,
Been stuck with this for a while, and I’m fully aware that’s it’s just my addressing however I’ve completely stumped myself.
My goal: I want to send a message to the script of a game object being created by a factory. The aim of this is to set bounds on my map for different objects using a hidden layer on a my level tilemap.
This script (level.script) finds the position of specific trigger tiles (46 and 47) and creates instances of enemy objects at the coordinates. What I want to do is for another set of unique tiles, have a message sent to stop instances moving any further.
function init(self)
sx, sy, w, h = tilemap.get_bounds("#tilemap")
print(sx, sy, w, h)
for y = sy, h+sy-1 do
for x = sx, w+sx-1 do
local t = tilemap.get_tile("#tilemap", "enemy", x, y)
if t == 47 then
local id = factory.create("#mushroom_factory", module.tile_vector(vmath.vector3(x, y, 0)))
elseif t == 46 then
factory.create("#skeleton_factory", module.tile_vector(vmath.vector3(x, y, 0)))
end
local p = tilemap.get_tile("#tilemap", "patrol", x, y)
if p == 5 then
msg.post(msg.url(nil, id, "mushroom_factory"), "patrol_limit", { limit = module.tile_vector(vmath.vector3(x, y, 0)) } )
end
end
end
end
My issue is with the line:
msg.post(msg.url(nil, id, "mushroom_factory"), "patrol_limit", { limit = module.tile_vector(vmath.vector3(x, y, 0)) } )
As this only seems to let me send a message to components within my /level object.
My collection structure is as follows:
The script I am wanting to send my message to is mushroom.script in the prototype object mushroom:
I apologise for what’s probably just me misreading something
Thanks