Post message with hashed url not working?

I have a game object which has a property called url, like this:

go.property("url", hash("#script"))

I want to send a message to another object using that url property, and I do that like this:

msg.post(self.url, "trigger_activated")

When I do that I get an error saying:

ERROR:GAMEOBJECT: Instance '(null)' could not be found when dispatching message 'trigger_activated' sent from game:/pressure_plate#trigger_object

But when I do the same thing but instead of using the self.url, I type “#script” as a raw string, like so:

msg.post("#script", "trigger_activated")

It works. Does anyone know how this is? Or how to fix it?

I guess that to be able to use self.variable you need to declare a local variante like: local URL = '#scritp. If you prefer use Go.set_pro… Try to use Go.get(id) tô retrieve your value.
Maybe it is a possible solution.

After a quick read of the manual, I believe you need the following;

go.property("url", msg.url())
go.set("url", hash("#script"))
2 Likes

Yes, if it’s a URL you should use go.property("url", msg.url()) and set it like go.set("#", "url", msg.url(nil, nil, "script"))

3 Likes

Yes, urls are compound types containing three components: socket, path and fragment.

3 Likes

Hmm ok I think I have understood you, the problem is that I want to have dynamic URLs like properties, is that possible? And how would I retreive the URLs, would I just use self?

In the script itself you can use self.property_name to access any property declared with go.property() in the same script. If you need to access the property from another script you use go.get("#script_url", "property_name")