Replies: 0 (Who?), Viewed: 248 times.
#1 27th Mar 2021 at 8:30 PM Last edited by BartekStu : 28th Apr 2021 at 3:30 AM.
Thanks: 211 in 2 Posts
Changing a token's attribute using Manage InventoryI'm have a bit of confusion concerning the terms that are used when discussing primitive 0x0033, Manage Inventory.
Say I have an object with an arbitrary attribute, "Worth". Sims can be directed to pick up this object and add it to their inventory. However, if the object finds a copy of itself in the Sim's inventory first, I would want it to increase that copy's "Worth" by whatever the object not in their inventory's "Worth" is, instead.
The usual Set to Next variants of Manage Inventory are used to find an eligible token, which loads it into a temp token, and then checks its GUID. It all works as desired, apart from that last bit of attribute-changing functionality.
I have been trying to use the "Get Nth Property From Token In Temp" variant for this as it seems to be the correct one? It keeps throwing an error, and I lack the understanding to troubleshoot.
Per the following thread, and the documentation attached in it: https://modthesims.info/showthread.php?t=208887
"Takes the value provided by index and copies the property at that index from the temp token into the property variable. Returns false if the property index is invalid."
1. Can a "property" be any operand, within reason? Is attempting to use "My Attribute" incorrect? I've only found one Maxis BHAV that uses it.
2. displays two fields, "property" and "Value". Is value meant to be the index, or a variable the token's property is to be written to? If not, what are the functions of the two? If found, where is the token's property written to, otherwise?
3. Would it be better to just create an object version of the token in the ether, modify its attribute with 0x0002, then return that object to the inventory? Can one even directly modify the attributes of tokens, or temporary tokens?
If anyone has any notes or advice they would be willing to share, it would be very much appreciated!
EDIT: Just updating this so anyone who finds this thread and has a similar conundrum can glean some information - thanks very much to the modder who PM'd me with some pointers!
1. Token "properties" are completely unrelated to object attributes and in turn, similar data, I would imagine.
2. This was me misunderstanding the purpose of the index, as long as the difference between Counted and not Manage Inventory functions. 'Index' functions similarly to the Stack Object variable when using Set to Next, for instance.
3. This is the correct approach. The takeaway is, if you want to modify an object in a Sim's inventory, you must extract that object (the token) and hence modify the actual, extracted object as outlined above. Globals 0x044B and 0x44A can be used to make this process easier. Feeling silly that it took me this long to glean that tokens were just, uh, tokens.