How can I get the id of a game object? (SOLVED)

#1

Hello guys!
(I may use wrong English because I am Japanese, sorry)

I want to get game object id!
image

I can get it on Debugging.
image

But I cannot get it on executable file.
I tried to get it with “log.txt”, but it was empty.
image
So, I got “id” in this way

f = io.open(id..".txt", "w")
f:close()

I seems that the “go.get_id()” returned only number.
I want to get id in collection.

How can I do this?
(And “log.txt” bug?)
Please give me some solutions!

0 Likes

#2

The write logs feature is disabled in release builds, that is why it is an empty file.

Moreover, go.get_id() returns a hash, which, if I am correct, is internally an number(correct me if I am wrong). That’s why you got numbers as id.
If you want to save hashes to log file and debug them, make sure they are debug apps, from the menu which comes when you want to bundle them.

No worries. This ain’t an English class :wink:

2 Likes

#3

I can get unhashed string and it works completely when I used “Debug Bundle”!
Thank you for your support!
(Can’t I get unhashed string in release bundle?)

0 Likes

#4

Reverse hash is not available in release bundles.

In debug we store the strings for hashes (when available) for debugging purposes, but this takes up memory that we don’t want to waste in release builds.

2 Likes

#5

I see. I can understand it :slight_smile:
Thanks!

1 Like

#6

hey there! Don’t want to make a new post since I have the same problem.

Have 20 similar objects (with minor differences) added manually and called d1 … d20. All with colliders and scripts. They actually look like factories but they are not. =)

How can I get a number (an id or path) of an object? I.e. I need that number “d15” or “d7” to address objects inside.

Thank you!

PS Actually the obvious reaction is to get those numbers through messages, but it doesn’t look good enough.

0 Likes

#7

You can create new urls like so:

local url = msg.url(nil, "/d15", nil)

You can read more here:

2 Likes