• All submissions to this site are governed by Second Life Project Contribution Agreement. By submitting patches and other information using this site, you acknowledge that you have read, understood, and agreed to those terms.
Issue Details (XML | Word | Printable)

Key: SVC-302
Type: New Feature New Feature
Status: Open Open
Priority: Normal Normal
Assignee: Unassigned
Reporter: Haravikk Mistral
Votes: 3
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
2. Second Life Service - SVC

llGetInventoryUpdateTime()

Created: 10/Jun/07 12:27 PM   Updated: 29/Oct/09 07:55 PM
Return to search
Component/s: Scripts
Affects Version/s: 1.15.0, 1.16.0, 1.17.0, 1.18.0, 1.21.0 Server, 1.22.1 Server, 1.22.2 Server, 1.22.3 Server, 1.22.4 Server, 1.23.4 Server, 1.24 Server, 1.25 Server, 1.26 Server, 1.27 Server, 1.30 Server
Fix Version/s: None

Issue Links:
Duplicate
 
Relates

Sub-Tasks  All   Open   
 Sub-Task Progress: 

 Description  « Hide
integer llGetInventoryUpdateTime(string inventory);

PARAMS:
inventory = the name or key for an inventory item within the object where this script resides

RETURNS: a unix time-stamp indicating when this inventory item was added to the object in which this script resides, or was last updated (ie due to renaming/saving etc)

Reasoning for this is simple; currently to look for updated items in an object we have to maintain our own lists of names, keys and so-on. But this is not very memory efficient, and makes it impossible to cope with objects with any number of inventory items. As such this function would allow us to simply skim through inventory and look for items which return a timestamp greater than that corresponding to the last time that we looked. This quite neatly then allows us to deal only with these updated items, ignoring unchanged items completely.



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Haravikk Mistral added a comment - 29/Aug/07 01:21 AM
No love for this addition? It would be so simple to use if it were implemented, though admittedly it requires a little addition to object inventory. Namely, each entry in an object's inventory would be time-stamped to indicate when it was last updated, or was added to the object (this is basically the same thing since keys change when items are saved).

With it to perform some action on an object with 200 notecards you can do the following:

// START_SCRIPT
integer lastUpdateTime = 0;

default {
state_entry() { state loading; }
changed(integer x) { if (x & CHANGED_INVENTORY) state loading; }
}

state loading {
state_entry() {
integer x = llGetInventoryNumber(INVENTORY_NOTECARD);
integer i; string s;
for (i = 0; i < x; ++i) {
s = llGetInventoryName(INVENTORY_NOTECARD, i);
if (llGetInventoryUpdateTime(s) >= lastUpdateTime) { // >= because we can't rely on the precision of seconds llOwnerSay(s+" has been added or updated"); }
}
lastUpdateTime = llGetUnixTimestamp();
state default;
}
}
// END_SCRIPT

In an object with 200 notecards, while it still has to go through all of them (O time), it only has to process those that actually updated, and can do so without maintaining an internal list, which for 200+ items would easily eat up the memory of an object. Even for low numbers of items the amount of wasted memory and processing time because we don't have this function is pretty ridiculous.

Basically the changes amount to:

  • Change inventory list structure to include a unix timestamp
  • When inventory is added to the list (either newly or through an update), update the timestamp to the current result that llGetUnixTimestamp() would give
  • Add an LSL function to expose the timestamp assigned to an inventory item

There seems no con to this besides the relatively small amount of work required to implement it, as object inventory is not updated frequently enough to present any real increase in overhead due to update timestamps etc.


Haravikk Mistral added a comment - 07/Sep/07 07:58 AM
Added SVC-622 which adds an even more interesting function on-top of the changes required to implement llGetInventoryUpdateTime().

anthony reisman added a comment - 28/Sep/07 02:29 PM
I would think that this could also be accomplished if the change event allowed returning more information as I put in a feature request at http://jira.secondlife.com/browse/SVC-675. I hope either one could get implemented.

Haravikk Mistral added a comment - 07/Nov/07 03:06 AM
As mentioned in your proposal (though good), there are issues surrounding the changed() event, namely that only so many events can be queued; too many and events are lost.

To get around this would either require changes to be blocked until such a time as changed() events have completed (the code in them is finished). Alternatively the changed() event has to try and return the maximum possible information (so if 50 items are added, it returns a list of 50 inventory keys), however this has problems in that it could crash a script that does not have enough memory to cope with the list of items.

The easiest way to avoid memory issues, and potential misses from event issues is to traverse the entire inventory list, but without a way to filter (such as by time as I'm proposing) which inventory items we're interested in, this can't be done without significant amounts of work =(


Peri Lorefield added a comment - 29/Oct/09 05:03 PM
Clearly I think this is a great idea - since I mistakenly raised the exact same issue