Author Topic: Getting ID from ItemData name & array length?  (Read 1833 times)

How would get that integer ID thingy from an ItemData datablock name?

How to determine the length of an array?

I'm working on a simple weapon shop GUI system and I'm trying to populate a drop down list with predefined items.

nameToID(yourItemData) or yourItemData.getID()

Torque doesn't have actual arrays. If you're using one of Torque's pseudo-arrays, then you should keep a separate variable that records the length.

As a general note nameToID and ::getID are mostly unnecessary. Torque will automatically simplify datablock / object names to their respective ID numbers so they work interchangeably in most situations.

So something like someFunction("YourDatablockName", YourDatablockName); would simplify to the first argument being a string containing the name of the datablock object and the second would be the datablock object ID.
« Last Edit: January 18, 2015, 03:18:29 PM by $trinick »

When equipping players with items, though, it is necessary to get the ID. That's about the only case I can think of.

Using many brick functions, like ::setEmitter, ::setItem, ::setLight, ::setVehicle, etc, do require IDs, and I'm not sure why.

But yeah nameToID or ::getID are what you're looking for.

Using many brick functions, like ::setEmitter, ::setItem, ::setLight, ::setVehicle, etc, do require IDs, and I'm not sure why.

But yeah nameToID or ::getID are what you're looking for.
Are you an alt?

Using many brick functions, like ::setEmitter, ::setItem, ::setLight, ::setVehicle, etc, do require IDs, and I'm not sure why.

But yeah nameToID or ::getID are what you're looking for.
probably to be more efficient rather than doing user checking on functions that will mostly only be accessed by bricks


20k id. Probably not.
first post was an addon release.

probably.

So something like someFunction("YourDatablockName", YourDatablockName); would simplify to the first argument being a string containing the name of the datablock object and the second would be the datablock object ID.

That'd just call someFunction with "YourDatablockName" and YourDatablockName capitalized however it was the first time it was used. It doesn't matter though as an object name is a valid object ID ("foo".bar();) or even the start of an ID ("14264 foo".bar();).

That'd just call someFunction with "YourDatablockName" and YourDatablockName capitalized however it was the first time it was used. It doesn't matter though as an object name is a valid object ID ("foo".bar();) or even the start of an ID ("14264 foo".bar();).

Both "YourDatablockName" and YourDatablockName are technically both references due to Torque's weird stringtable stuff, but that's sort of beyond the point. There are plenty of things that work in Torque that shouldn't and thus shouldn't be taught as proper practice to people.