Rezzing objects from it's inventory on command.
|
|
Exile Loudon
Aspiring Scripter
Join date: 10 Dec 2005
Posts: 122
|
03-30-2006 08:12
I'm trying to make a "rezzer" that would rez anything that is in it's inventory on command; including objects that the user adds without changing the script. For example, if I say "/2 rez cube", it will rez a cube. If I add in an object called "sphere" into the objects inventory, I will immediately be able to say "/2 rez sphere" and I'll be able to rez it. But, doing this, I have run into a problem. To get a name of something in my inventory, I need to use the llGetInventoryName(INVENTORY_OBJECT, objectnum) function. How would I go about getting the number of an object inside the inventory? Or, if anyone would be kind enough to give me another suggestion for going about and doing this a different way? Here's the script I'm trying to use, please implement your suggestions into it.  string object; integer objectnum; vector pos; default { state_entry() { string object = llGetInventoryName(INVENTORY_OBJECT,objectnum); llListen(2,"",llGetOwner(),"rez" + (string)object); } listen(integer channel, string name,key id, string message) { vector pos = llGetPos(); if (message = "rez" + object) llRezObject(message,pos,ZERO_VECTOR, ZERO_ROTATION, 0); } }
|
|
Persephone Milk
Very Persenickety!
Join date: 7 Oct 2004
Posts: 870
|
03-30-2006 08:21
I would suggest that you don't filter your listener for a specific object name. Just use an open listen on your channel, parse the command string to obtain your object name, and rez it. I wrote a similar script not that long ago. Message me in-world if you want some help.
_____________________
~ Persephone Milk ~
Please visit my stores on Persenickety Isle Musical Alchemy - Pianos, harps and other musical intruments. Persenickety! - Ladies Eyewear, Jewelry and Clothing Fashions
|
|
Exile Loudon
Aspiring Scripter
Join date: 10 Dec 2005
Posts: 122
|
03-30-2006 08:31
I left you an IM, thanks.
|
|
Persephone Milk
Very Persenickety!
Join date: 7 Oct 2004
Posts: 870
|
03-30-2006 09:01
Excellent  Unfortunately, I am at work right now. I will contact you later tonight. If you are not online I will send you a sample script that does what you want to do.
_____________________
~ Persephone Milk ~
Please visit my stores on Persenickety Isle Musical Alchemy - Pianos, harps and other musical intruments. Persenickety! - Ladies Eyewear, Jewelry and Clothing Fashions
|
|
Exile Loudon
Aspiring Scripter
Join date: 10 Dec 2005
Posts: 122
|
03-30-2006 10:12
Thanks alot 
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
03-30-2006 10:20
From: someone How would I go about getting the number of an object inside the inventory? In general, llGetInventoryNumber() will tell you how many of a certain type are in inventory. You'll then have to search through them to see if you find a match. I believe that list is sorted alphabetically, so a given object won't always have the same number as new items are added or removed. But in this case, you already know the name you're searching for, so all you need to check is if something by that name exists in inventory or not. The easiest way to do that is to use llGetInventoryType. So, like Persephone said - the listener has to be able to listen for anything. You need to extract the requested object name out of the received text, then see if you have anything by that name in your inventory. Also, remember... == is used for comparison, = is used for assignment. So if you type [message=something], you're assigning the value of 'something' to 'message', not comparing it, which is what you want to do. default { state_entry() { llListen(2, "", llGetOwner(), ""); }
listen(integer channel, string name, key id, string message) { // See if the first 3 letters in message are 'rez' if (llGetSubString(message, 0, 2) == "rez") { // It's a rez command... extract the requested object name. This // will be everything in the message starting from the 5th // character (i.e. index 4) out to the end, since there will be a // space between the word 'rez' and the object name string object = llGetSubString(message, 4, -1);
// Now see if we have something with this name in inventory integer type = llGetInventoryType(object); if (type == -1) { llOwnerSay("Sorry, no " + object + " found in inventory."); } else { vector pos = llGetPos(); llRezObject(object, pos, ZERO_VECTOR, ZERO_ROTATION, 0); } } } }
That should mostly work, I think 
|
|
MadamG Zagato
means business
Join date: 17 Sep 2005
Posts: 1,402
|
03-30-2006 10:33
The N30 Modeling Studio does what you are trying to do. If you visit "Never 30" on the 2nd floor, and go to the studio and say '/7 chair1' or '/7 fire' you will see a working example of this. If you need help IM me in world and I will be happy to assist you with whatever you are trying to do. Smiles 
|
|
Exile Loudon
Aspiring Scripter
Join date: 10 Dec 2005
Posts: 122
|
03-30-2006 15:30
Thank you everyone for your help, and Ziggy, it works great 
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
03-30-2006 15:39
Glad to hear that. Now that I think about it, you could make it a little safer - since you're checking the inventory type, you can make sure the name points to an object, so you don't end up trying to rez a texture or a notecard or something else that won't work with llRezObject. So you could replace: if (type == -1) { llOwnerSay("Sorry, no " + object + " found in inventory."); }
with: if (type != INVENTORY_OBJECT) { llOwnerSay("Sorry, no object called " + object + " found in inventory."); }
This way, it'll fail if the name matches something other than an object (as well as, if the name doesn't match anything at all).
|
|
Exile Loudon
Aspiring Scripter
Join date: 10 Dec 2005
Posts: 122
|
03-31-2006 04:00
You sure do know alot about scripts 
|