Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Instructor
Original Poster
#1 Old 5th Feb 2017 at 9:08 PM Last edited by whoward69 : 5th Feb 2017 at 9:33 PM.
Default Attributes on an object in inventory appear to be read-only
I have an object that I'm using to store data about the owning sim - specifically the number of days worked. So every time the Sim gets paid, the days value in an attribute is incremented.
There is also a Show Values action to display the data.

If the object is on the bedside table (ie NOT in the owning Sims inventory), I get the expected behaviour
* Show Values - days = 2 (say)
* Sim goes to work and comes home, gets paid. BHAV on the object gets called, reads some attributes, does some calculations, spits out the answer in a notification (this is all correct). As part of the BHAV, days is incremented
* Show Values - days = 3 (which is correct)

Now, if the object is in the Sim's inventory, I get a "read-only" behaviour
* Show Values - days = 3 (say)
* Sim goes to work and comes home, gets paid. BHAV on the object gets called, reads some attributes, does some calculations, spits out the answer in a notification (this is all correct). As part of the BHAV, days is incremented
* Show Values - days = 3 (which is incorrect, it should be 4)

Same "read-only" behaviour can be seen when the Sim quits their job (which resets days to 0) - if the object is not in the inventory, I get the correct value of 0. If the object is in the Sim's inventory it doesn't change, ie I get the old value.

Anybody happen to of come across something similar and know the solution?

TIA

W

Edit: Mmmmmm

There is another possibility ....

Get copy of object from inventory, show values from the copy, discard copy
Get copy of object from inventory, perform paid actions on copy, discard copy
Get copy of object from inventory, show values, discard copy

Which is probably what's happening ...

Now, how to deal with that sequence of events ...

Just call me William, definitely not Who-Ward
Advertisement
Instructor
Original Poster
#2 Old 6th Feb 2017 at 8:56 AM
And the nominations for the category "Worst named parameter" go to ...

"Don't Delete" for meaning "Make A Copy"

When you place an item into the inventory, you don't. You put a copy into the inventory. The "Don't Delete" parameter determines if the original object is destroyed or not.

When you get an item from the inventory, you don't. You get a copy, and the "Don't Delete" parameter determines if the original in the inventory is destroyed.

So to work on an item in the inventory, you need to
a) Find it
b) Get it a copy of it, deleting the original from the inventory
c) Work on the copy
d) Put a copy of the copy back into the inventory, deleting the copy


Just call me William, definitely not Who-Ward
Scholar
#3 Old 6th Feb 2017 at 2:01 PM
Yes, that's almost correct. I have never seen anything attempt to make a change to an item in the inventory, it is actually just a token of the item while it is in the inventory so you must create the item from the inventory token to make changes.
a) find it's index (you'd have to do that any way)
b) Create the item, delete the token from the inventory
c) Work on the item
d) Re-create the inventory token of the updated item and delete the item.
I assume you are referring to the global op-codes 'Inventory - Visible - Get Item' (0x0000044B) and 'Inventory - Visible - Add Item' (0x0000044A). The param names are a part of SimPE (GLOBALS.package in this case) not from the game so you can change them if you like. Those two global op-codes are easy to work with once you are used to them.
Back to top