Hi, I’m new to Defold and I’m getting errors whenever I attempt to send messages to a receiver.
I wrote this code to send the position of an object to a script located inside a game object named opholder located in a collection named holder.
function update(self, dt)
local opholder = msg.url("opholder#script")
msg.post(opholder, "position", {position = go.get_position()})
end
however, whenever I run the code, I get the following error message.
ERROR:GAMEOBJECT: Instance '/opholder' could not be found when dispatching message 'position' sent from default:/instance2#script
I tried different variations, but I keep getting the same type of error everytime.
function update(self, dt)
local opholder = msg.url("holder/opholder#script")
msg.post(opholder, "position", {position = go.get_position()})
end
ERROR:GAMEOBJECT: Instance '/holder/opholder' could not be found when dispatching message 'position' sent from default:/instance4#script
function update(self, dt)
local opholder = msg.url("holder:/opholder#script")
msg.post(opholder, "position", {position = go.get_position()})
end
ERROR:SCRIPT: card/operation.script:45: The socket 'holder' could not be found.
stack traceback:
[C]: in function 'url'
card/operation.script:45: in function <card/operation.script:44>
Can someone help me understand why these errors are occurring and how I can fix this issue? I looked at the defold API and it stated, “The format of the string must be “[socket:][path][#fragment]”, which is similar to a http URL. When addressing instances, socket is the name of the collection. path is the id of the instance, which can either be relative the instance of the calling script or global. fragment would be the id of the desired component.”, but I don’t know what I’m doing wrong.
Thanks