llGetInventoryKey
|
|
Lyndzay Meili
Registered User
Join date: 2 Sep 2007
Posts: 28
|
12-19-2007 03:46
Hi there,
I've made a "gun" using using Ready Jack's pistol script I found on the wiki, which works great for me. The problem is when I give it to my alt I get a message that "Bullet not found" and Sound not found" though when they open up all the items are in the object.
I 've narrowed it down to the fact that the bullet and sound files are just set at copy /no mod/no transfer/ because when I set them all to yes (copy/Mod/Trans) it doesn't give me the alert. Which is fine for the alt but if I want to give it to friends, well not so much.
So I guess my question is "Is the only way to verify Inventory with llGetInventoryKey is to have those items full permissions to keep it from returning a null key and saying item not found while clearly it's in the inventory, or is there another way to verify the inventory that works with copy only items?
Thx
_____________________
"Be who you are and say what you feel, because those who matter don't mind, and those that mind, don't matter." —Dr. Seuss
|
|
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
|
12-19-2007 04:22
you can reference by key or name.
name is case sensitive.
llGetInventoryName()
|
|
Lyndzay Meili
Registered User
Join date: 2 Sep 2007
Posts: 28
|
12-20-2007 03:18
Thanks Squirrel that helps knowing that it can be done using llGetInventoryName() but now my problem is changing this part of the script to use it: <snip> verifyInventory() { if (llGetInventoryKey(gBulletName) != NULL_KEY) { gEnableBullet = TRUE; } else { gEnableBullet = FALSE; say("bullet not found: " + gBulletName); } if (llGetInventoryKey(gShotSound) != NULL_KEY) { gEnableSound = TRUE; } else { gEnableSound = FALSE; say("sound not found: " + gShotSound); } } <snip> I kinda of understand what this section is doing but not enough to change it and still have it do what it's suppose to do  Any help/ insight greatly appreciated- Thx
_____________________
"Be who you are and say what you feel, because those who matter don't mind, and those that mind, don't matter." —Dr. Seuss
|
|
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
|
12-20-2007 04:50
that code basically checks if certain inventory items exist.
gBulletName and gShotSound are variables that should be defined somewhere in the script and assigned a value.
those variables specify the name of the objects that need to be in the objects inventory.
Names are case sensitive.
|
|
Lyndzay Meili
Registered User
Join date: 2 Sep 2007
Posts: 28
|
12-20-2007 04:55
ahh, that's what I thought, but wasn't sure. and yes at the beginning of the script I have defined gBulletName and gShotSound Now if I replace the llGetInventoryKey with llGetInventory Name do I need the !=NULL_KEY part of the statement? or is that only there because if the items are not Copy/Mod/Trans, llGet InventoryKey will return a Null_Key (not sure if I said that right but I hope you understand it  ) That's the part that just isn't clicking for me -Thx
_____________________
"Be who you are and say what you feel, because those who matter don't mind, and those that mind, don't matter." —Dr. Seuss
|
|
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
|
12-20-2007 07:15
You do not need to replace anything.
Make sure that the name of the bullet item and the name of the sound match the ones referenced in the script and ensure that the bullet object has copy permission.
That should get it working.
|
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
12-20-2007 08:34
first use llGetInventoryType to check if the asset exists, this function will not give an audible error if the inventory item isn't found, also you can make sure it's the right type at this time. Then you can use llGetInventoryPermMask to check the permissions.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
|
Wyatt Burton
Registered User
Join date: 11 Jan 2007
Posts: 49
|
12-20-2007 09:37
From: Lyndzay Meili Hi there,
I've made a "gun" using using Ready Jack's pistol script I found on the wiki, which works great for me. The problem is when I give it to my alt I get a message that "Bullet not found" and Sound not found" though when they open up all the items are in the object.
I 've narrowed it down to the fact that the bullet and sound files are just set at copy /no mod/no transfer/ because when I set them all to yes (copy/Mod/Trans) it doesn't give me the alert. Which is fine for the alt but if I want to give it to friends, well not so much.
So I guess my question is "Is the only way to verify Inventory with llGetInventoryKey is to have those items full permissions to keep it from returning a null key and saying item not found while clearly it's in the inventory, or is there another way to verify the inventory that works with copy only items?
Thx Sorry to barge in with a different question about this. I saw the script and need something like this. Did you have to make your own sound and bullets or are the supplied in the example or can I find them in SL? Thanks
|
|
Lyndzay Meili
Registered User
Join date: 2 Sep 2007
Posts: 28
|
12-20-2007 20:29
Thanks Strife and Squirrel, I was able to get it working using the llGetInventoryName ( it took a while to figure out that I needed to include the integer number (INVENTORY_OBJECT,6) but hey that how you learn. ) As I learn more about scripting I'm sure I'll refine it more  Wyatt, there is no bullet or sound per se with it just put the bullet script in a prim and the the prim inside the "gun". At first I used the sound from the popgun, but it was not really what I was looking for so I recorded my own sound. Thanks again for everyone's help
_____________________
"Be who you are and say what you feel, because those who matter don't mind, and those that mind, don't matter." —Dr. Seuss
|
|
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
|
12-21-2007 09:56
Note that the bullet will need to be copiable for the gun to fire more than once.
Of course, the sound shouldn't need to be copiable, so Strife's suggestion is best for testing to see if it's there. You see, getting the key to a sound or texture is essentially the same as being able to copy it, so that function won't return the key unless it's copiable.
(A script can play a sound that's not in the object's inventory, using its key. A sctript can set a prim's texture to one that's not in the object's inventory, using its key.)
So, you could skip the sound inventory test altogether, and bake the sound right into the script (use right-click in your inventory to get the sound's UUID and paste it into the script).
However, if I'd written the script, I'd have simply used the first object as the bullet, and the first sound as the sound, to make it unnecessary to change the script when I change the sound or bullet name. (Or to change the sound or bullet name to match the script.)
|
|
Lyndzay Meili
Registered User
Join date: 2 Sep 2007
Posts: 28
|
12-21-2007 16:15
Thanks Lear, I found the inventory test odd too but that was how the script was originally written and when I started this little experiment it was easier to leave it, now i think I could completely pull it out.  My biggest hang up was that to get the llGetIventoryKey to work the bullet and the sound had to be full permissions, which I put a lot of work into the bullet and did not want that full permissions if I gave it away. I got the script to work pretty much as written using llGetInventoryName so I'm happy with the results. Thx everbody
_____________________
"Be who you are and say what you feel, because those who matter don't mind, and those that mind, don't matter." —Dr. Seuss
|