Don't click here unless you want to be banned.
LSL Wiki :
ZenMondo
HomePage
::
PageIndex
::
RecentChanges
::
RecentlyCommented
::
UserSettings
:: You are crawling22.us.archive.org
ZenMondo Wormser styles himself a code poet. %%(lsl) //////////////////////// // Function GetNewInventoryName by ZenMondo Wormser // // This function returns a list of the names of // inventory items added to an object's inventory // since the last time the function was called. // // This function works by keeping a list of inventory items // and comparing against that list as inventory changes. // // NOTE: If items are deleted between calls and nothing is added // this function will return an empty list. //////////////////////// list gOld_Inventory; //This stores the Inventory since the last function call. //It is global so it persists between function calls. //It may also be handy to have a list of your object's inventory. list GetNewInventoryName() { list found_new = []; //This list will contain the names of New Inventory items. integer inventory_type = INVENTORY_ALL; //Change to look at inventory type you want. integer inventory_num = llGetInventoryNumber(inventory_type); list new_inventory = []; //This list will contain the current inventory. integer counter = 0; while(counter < inventory_num) { new_inventory = (new_inventory=[]) + new_inventory + llGetInventoryName(inventory_type, counter); counter ++; } integer list_length = llGetListLength(new_inventory); counter = 0; list scratch; while(counter < list_length) { scratch = llList2List(new_inventory, counter, counter); if(llListFindList(gOld_Inventory, scratch) == -1) //New Inventory Object { found_new += llList2String(scratch,0); //Add the name of the new inventory item to the found_new list } counter ++; } gOld_Inventory = new_inventory; //Store the Inventory List to be compared the next time the function is called. return found_new; //Return a list of the new inventory items. } default { state_entry() { GetNewInventoryName(); //Populate the list on reset. } touch_start(integer num_detected) { /////////// // Example Use in touch_start() // Because Multiple Items could have been // added between calls we work through // the list that is retunred. /////////// list new_inv = GetNewInventoryName(); llSay(0, "New Inventory Items:"); integer list_len = llGetListLength(new_inv); integer counter; for(counter = 0; counter < list_len; counter++) { llSay(0, llList2String(new_inv, counter)); } } changed(integer mask) { ////////////////// // Example Used in changed() // This is much simpler, as changed() // will be triggered each time something // is added to the object's inventory // resulting in only one result in the // returned list from GetNewInventoryName() //////////////////// if(mask & CHANGED_INVENTORY) { list new_inv = GetNewInventoryName(); llSay(0, "New Inventory Item:" + llList2String(new_inv, 0)); } } } %% A simple script to light up a prim in a linkset when touched, and unlight the last one touced using [[llSetLinkPrimitiveParams]] %%(lsl) default { touch_start(integer total_number) { llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, TRUE]); llSetLinkPrimitiveParams(LINK_ALL_OTHERS, [PRIM_FULLBRIGHT, ALL_SIDES, FALSE]); } } %%
Valid XHTML 1.0 Transitional
::
Valid CSS
:: Powered by
WakkaWiki 0.1.2