Do addresses hash the same from different scripts?


Let’s say I have a controller script A and worker script B on different Game Objects, and script A initializes a property on script B with a hash (because you can’t make a string property) of which of several CollectionFactorys to use to generate its objects. Does the CollectionFactory need to be specified with the address with respect to script A, where it originally gets hashed; or with respect to script B, where it gets used; or does it make a difference?



There seem to be some confusion going on here.

Hashes themselves are created from a string. It’s is only dependent on the string you pass into it, so if the string is the same, the hash is the same.

Addesses (urls), for game objects and components are unique. So script A and script B will have different urls.

When passing properties to a script via the collectionfactory.create() function you want to use the url of the script that has the



See, that’s what I would expect; and yet my addressing keeps failing to find the object, so I was grasping at any straws I could think of.



Okay, now that I had time to play with my suspicions, it turns out the problem is that collectionfactory.create only takes the string as a parameter, not the hash as I was thinking. So now I have to figure out how to properly address it without being able to pass a string.



That doesn’t sound right. Can you share some code and show where in your scene hierarchy the collection factory component is located?



I tested it by putting a hardcoded string right in the code, with and without hash() around it. It worked without the hash, didn’t work with the hash. Then I double-checked the manual, and the manual also shows it without the hash:



From my code:

This works:


This fails:


The error:

And as for my Outline, the script is highlighted:

(You can see where my ultimate goal is to have all the characters in the character_list.go; eliminating the middleman was part of my attempts to diagnose the problem)



An url is not a single hash. It’s a struct with multiple hashes.
Therefore, you cannot simply do hash("#component") and expect it to work.

What you could do, is pass a url msg.url(nil, nil, component_name).

I recommend reading the Addressing manual for more detailed info.



The API reference for collectionfactory.create() states that it should be a URL. You can provide a URL in two ways (string or url):

collectionfactory.create(msg.url(nil, nil, "roku_factory"))

The fact that we do accept a hash is a bit strange though…

In other places where the documentation mentions an id, for instance in go.set_position() you can provide the id in three ways (string, hash or url):

-- set the position of the game object with id "foo"
go.set_position(pos, "foo")
go.set_position(pos, hash("foo"))
go.set_position(pos, msg.url(nil, "foo", nil))


Thank you, I didn’t realize that there was actually an object called url that I could use; I thought the mentions were merely referring to one possible way of structuring the strings used for addressing. It might be worthwhile to add examples of using the object in some of the places it can be used, instead of just a tiny mention at the bottom of the Addressing page.



Maybe. Like you say, we use strings all around. It’s usually the only thing you need to use. It’s rare that you need to construct URLs using msg.url().