Nexeus Fatale
DJ Nexeus
Join date: 28 Aug 2004
Posts: 128
|
07-26-2005 13:16
I'm creating a script for a vendor that I have that will play a sound when touched. But everytime I load an object, with the sound, this script gives me an "Sound cannot be found" error. Can someone tell me what I'm doing wrong by talkinga look at this script? default { state_entry() { llWhisper(0, "Sound Vendor Ready!"); }
touch_start(integer total_number) { integer InvNum = llGetInventoryNumber(INVENTORY_SOUND); string SoundName; if (InvNum == 0) { llWhisper(0, "No sound loaded. Please place a sound in the object"); } else { SoundName = llGetInventoryName(INVENTORY_SOUND, InvNum); llSay(0, "Playing " + SoundName); llPlaySound(SoundName, 1); }
} }
_____________________
Website: www.nexeusfatale.com [nf_d]: nfd.nexeusfatale.com
|
Nexeus Fatale
DJ Nexeus
Join date: 28 Aug 2004
Posts: 128
|
07-26-2005 13:39
Okay, I found the work around, although I don't like it, it works. Being that I'm using this for a vendor, and only putting one sound in it at a time, and sounds start at 0 rather than 1, I have to change the way I call for the sound. default { state_entry() { llWhisper(0, "Sound Vendor Ready!"); }
touch_start(integer total_number) { integer InvNum = llGetInventoryNumber(INVENTORY_SOUND); string SoundName; if (InvNum == 0) { llWhisper(0, "No sound loaded. Please place a sound in the object"); } else { SoundName = llGetInventoryName(INVENTORY_SOUND, 0); llSay(0, "Playing " + SoundName); llTriggerSound(SoundName, 1); }
} }
The difference here, between the other script is right here SoundName = llGetInventoryName(INVENTORY_SOUND, 0);
Seting llGetInventoryName(INVENTORY_SOUND,InvNum); has it look for the second sound in the object, not the first, and being that there's always just 1 sound... it doesn't find it, and poof, goes haywire.
_____________________
Website: www.nexeusfatale.com [nf_d]: nfd.nexeusfatale.com
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
07-26-2005 13:46
From: Nexeus Fatale Okay, I found the work around, although I don't like it, it works. Being that I'm using this for a vendor, and only putting one sound in it at a time, and sounds start at 0 rather than 1, I have to change the way I call for the sound. SoundName = llGetInventoryName(INVENTORY_SOUND, InvNum - 1); there is one sound, you start counting with 0, so the first sound is 1 minus 1... or the 10th sound is 10 - 1. At least, I think that's the problem here. o.O
|