Object ID

For questions about using Classic.

Post » Thu Feb 03, 2011 6:32 am

Is there something that determines what the Object ID is? Using a level editor that places an object based on it's ID works great, however, the number changes as I add objects, but only certain ones. This causes issues in terms of loading objects, as the incorrect objects will not load. Is there a way I can pick the OID? If not, any chance of seeing this as a feature in the near future?
B
2
S
1
G
1
Posts: 38
Reputation: 676

Post » Thu Feb 03, 2011 7:09 am

All object types and all behaviors get their own OID in order from 0 on.
The order of the object bar kind of shows what the order the OIDs will be a runtime, but no there is no way to set what the OID of an object type will be.

It's best to avoid using the oid to identify object types in a save file because oids are only guaranteed to be the same for that object type for the duration that the game is run.

What you can do when you save is ignore what the oid of the object is and use you own numbers:
ex
Sprite -> 1
Sprite2 ->4
Sprite3 -> 703 ...

and when you load change from those values to what the OID of the object is:
if loadedValue == 1
then oidToUse = Sprite.OID
if loadedValue == 4
then oidToUse = Sprite2.OID
if loadedValue == 703
then oidToUse = Sprite3.OID
...and so on.
B
79
S
24
G
52
Posts: 4,724
Reputation: 39,711

Post » Thu Feb 03, 2011 8:47 am

So essentially build a database that reads the OID reguardless of what it is, not a bad idea. Sure beats the hell out of having a separate set of events that do the same thing.
B
2
S
1
G
1
Posts: 38
Reputation: 676


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest