Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

trying to modify a vendor to play sounds

Wolf Galbraith
Fuzzy Bunny Slipper
Join date: 27 Apr 2006
Posts: 7
06-03-2006 22:37
If I have a 4 prim vendor, and my item list and cost on a notecard how can I make the script in the "play" prim play the sound from the notecard I am using to store the items and cost?

Pardon but I'm half asleep right now, and not logged into SL. If anyone can help I'll post the scripts I am trying to modify to get it to work.

Thanks,
Wolf
Angela Salome
Registered User
Join date: 6 Oct 2005
Posts: 224
06-04-2006 00:00
From: Wolf Galbraith
If I have a 4 prim vendor, and my item list and cost on a notecard how can I make the script in the "play" prim play the sound from the notecard I am using to store the items and cost?


Modify the notecard so that the name of the sound is there for each. Then in your notecard reading function, read the name of the sound. Then llPlaySound the sound when the play primitive is touched.
Wolf Galbraith
Fuzzy Bunny Slipper
Join date: 27 Apr 2006
Posts: 7
06-04-2006 08:36
I think the problem I am running into is that the info being read from the notecard isn’t the expected type needed in the prim I have set up. It’s been a few years since I have programmed so I’m at the point where I remember how to do some things but have forgotten a lot.

I’m sort of living that “knows just enough to be dangerous” cycle right now. J

I’m having the modified scripts attached to this message… I know I’m gonna smack myself in the skull when someone helps me out andshows me what is wrong.


Main prim Script:
integer sell_type = INVENTORY_OBJECT;
vector text_color = <1,1,1>;
float text_alpha = 1;
list items;
list descriptions;
list prices;
integer notecardline;
integer current_item;


Next_Item()
{
current_item++;
if(current_item >= llGetListLength(items))
{
current_item = 0;
}
llSetText(llList2String(descriptions,current_item) + "\n$L" + llList2String(prices,current_item),text_color,text_alpha);
llSetTexture(llList2String(items,current_item) + "PIC",ALL_SIDES);
}

Prev_Item()
{
current_item--;
if(current_item < 0)
{
current_item = llGetListLength(items) - 1;
}
llSetText(llList2String(descriptions,current_item) + "\n$L" + llList2String(prices,current_item),text_color,text_alpha);
llSetTexture(llList2String(items,current_item) + "PIC",ALL_SIDES);
}

default
{
state_entry()
{
llSetTexture("d2665d83-d5f5-d0a8-7fb7-89656f2d3f7a",ALL_SIDES);
llSetText("Offline Mode, Nows the time to add/remove items, then click to start.",text_color,text_alpha);
}
touch(integer number)
{
if(llDetectedKey(0) == llGetOwner())
{
state check_items;
}
}
}

state check_items
{
state_entry()
{
llSetText("Checking inventory",text_color,text_alpha);
if(llGetInventoryNumber(sell_type) == 0)
{
llOwnerSay("Nothing found in inventory. Reseting.";);
llResetScript();
}
if(llGetInventoryKey("_LIST";) == NULL_KEY)
{
llOwnerSay("Could not find the _LIST notecard. Remeber the name of the notecard is important and CaSe sensitive.";);
llResetScript();
}
else
{
llGetNumberOfNotecardLines("_LIST";);
}
}
dataserver(key queryid, string data)
{
state setup_items;
}
on_rez(integer start_param)
{
llResetScript();
}
}
state setup_items
{
state_entry()
{
llSetText("Please Wait, Loading Items List.",text_color,text_alpha);
current_item = 0;
notecardline = 0;
llGetNotecardLine("_LIST",notecardline);
}
dataserver(key query_id, string data)
{
if (data != EOF)
{
integer item_mode = (notecardline - 0) % 2;
if(item_mode == 0)
{
if(llGetInventoryKey(data) == NULL_KEY)
{
llOwnerSay("Item: " + data + " couldn't be found in inventory. Reseting";);
llResetScript();
}
else
{
if(llGetInventoryKey(data + "PIC";) == NULL_KEY)
{
llOwnerSay("Couldn't find the picture for " + data + " named " + data + "PIC. Reseting.";);
llResetScript();
}
descriptions += [data];
items += [data];
}
}
else if(item_mode == 1)
{
prices += [data];
}
notecardline++;
llGetNotecardLine("_LIST",notecardline);
}
else
{
state run_store;
}
}
on_rez(integer start_param)
{
llResetScript();
}
}

state run_store
{
state_entry()
{
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
current_item = 0;
llSetText(llList2String(descriptions,0) + "\n$L" + llList2String(prices,0),text_color,text_alpha);
llSetTexture(llList2String(items,0) + "PIC",ALL_SIDES);
}
on_rez(integer start_param)
{
llResetScript();
}
changed(integer type)
{
if(type & CHANGED_INVENTORY)
{
llResetScript();
}
}
run_time_permissions(integer type)
{
if(type & PERMISSION_DEBIT)
{
}
else
{
llOwnerSay("Permissions must be granted for refund setup incomplete. Reseting";);
llResetScript();
}
}
money(key giver, integer amount)
{
integer cost = (integer)llList2String(prices,current_item);
if (amount == cost)
{
llInstantMessage(giver,"Thank you for your purchase!";);
llGiveInventory(giver,llList2String(items,current_item));
}
if (amount > cost)
{
integer change =0;
llInstantMessage(giver,"Here is your change. Thank you for your purchase!";);
llGiveInventory(giver,llList2String(items,current_item));
change = amount - cost;
llGiveMoney(giver,change);
}
if (amount < cost)
{
llInstantMessage(giver, "Sorry, That's not enough to buy this item. It costs L$" + llList2String(prices,current_item));
llGiveMoney(giver, amount);
}
}
link_message(integer sender, integer number, string message, key id)
{
if(message == "NEXT";)
{
Next_Item();
}
else if (message == "PREV";)
{
Prev_Item();
}
}
}

"Play Prim" Script

default
{
touch_start(integer total_number)
{
llPlaySound("current_item", 2);
}


Once again thanks for any help.
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
06-04-2006 09:10
Main:
CODE
integer sell_type = INVENTORY_OBJECT;
vector text_color = <1,1,1>;
float text_alpha = 1;
list items;
list descriptions;
list prices;
integer notecardline;
integer current_item;


Next_Item()
{
current_item++;
if(current_item >= llGetListLength(items))
{
current_item = 0;
}
llSetText(llList2String(descriptions,current_item) + "\n$L" + llList2String(prices,current_item),text_color,text _alpha);
llSetTexture(llList2String(items,current_item) + "PIC",ALL_SIDES);
}

Prev_Item()
{
current_item--;
if(current_item < 0)
{
current_item = llGetListLength(items) - 1;
}
llSetText(llList2String(descriptions,current_item) + "\n$L" + llList2String(prices,current_item),text_color,text _alpha);
llSetTexture(llList2String(items,current_item) + "PIC",ALL_SIDES);
}

default
{
state_entry()
{
llSetTexture("d2665d83-d5f5-d0a8-7fb7-89656f2d3f7a",ALL_SIDES);
llSetText("Offline Mode, Nows the time to add/remove items, then click to start.",text_color,text_alpha);
}

touch(integer number)
{
if(llDetectedKey(0) == llGetOwner())
{
state check_items;
}
}
}

state check_items
{
state_entry()
{
llSetText("Checking inventory",text_color,text_alpha);
if(llGetInventoryNumber(sell_type) == 0)
{
llOwnerSay("Nothing found in inventory. Reseting.");
llResetScript();
}
if(llGetInventoryKey("_LIST") == NULL_KEY)
{
llOwnerSay("Could not find the _LIST notecard. Remeber the name of the notecard is important and CaSe sensitive.");
llResetScript();
}
else
{
llGetNumberOfNotecardLines("_LIST");
}
}
dataserver(key queryid, string data)
{
state setup_items;
}
on_rez(integer start_param)
{
llResetScript();
}
}
state setup_items
{
state_entry()
{
llSetText("Please Wait, Loading Items List.",text_color,text_alpha);
current_item = 0;
notecardline = 0;
llGetNotecardLine("_LIST",notecardline);
}

dataserver(key query_id, string data)
{
if (data != EOF)
{
integer item_mode = (notecardline - 0) % 2;
if(item_mode == 0)
{
if(llGetInventoryKey(data) == NULL_KEY)
{
llOwnerSay("Item: " + data + " couldn't be found in inventory. Reseting");
llResetScript();
}
else
{
if(llGetInventoryKey(data + "PIC") == NULL_KEY)
{
llOwnerSay("Couldn't find the picture for " + data + " named " + data + "PIC. Reseting.");
llResetScript();
}
descriptions += [data];
items += [data];
}
}
else if(item_mode == 1)
{
prices += [data];
}
notecardline++;
llGetNotecardLine("_LIST",notecardline);
}
else
{
state run_store;
}
}
on_rez(integer start_param)
{
llResetScript();
}
}

state run_store
{
state_entry()
{
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT );
current_item = 0;
llSetText(llList2String(descriptions,0) + "\n$L" + llList2String(prices,0),text_color,text_alpha);
llSetTexture(llList2String(items,0) + "PIC",ALL_SIDES);
}

on_rez(integer start_param)
{
llResetScript();
}

changed(integer type)
{
if(type & CHANGED_INVENTORY)
{
llResetScript();
}
}

run_time_permissions(integer type)
{
if(type & PERMISSION_DEBIT)
{
llOwnerSay("I gots de perms!");
}
else
{
llOwnerSay("Permissions must be granted for refund setup incomplete. Reseting");
llResetScript();
}
}
money(key giver, integer amount)
{
integer cost = (integer)llList2String(prices,current_item);
if (amount == cost)
{
llInstantMessage(giver,"Thank you for your purchase!");
llGiveInventory(giver,llList2String(items,current_ item));
}
if (amount > cost)
{
integer change =0;
llInstantMessage(giver,"Here is your change. Thank you for your purchase!");
llGiveInventory(giver,llList2String(items,current_ item));
change = amount - cost;
llGiveMoney(giver,change);
}
if (amount < cost)
{
llInstantMessage(giver, "Sorry, That's not enough to buy this item. It costs L$" + llList2String(prices,current_item));
llGiveMoney(giver, amount);
}
}
link_message(integer sender, integer number, string message, key id)
{
if(message == "NEXT")
{
Next_Item();
}
else if (message == "PREV")
{
Prev_Item();
}
else if ( message == "PLAY" )
{
llPlaySound(llList2String(items,current_item), 1.0);
}
}
}
Child (button):
CODE
state default
{
touch_start(integer n)
{
llMessageLinked(LINK_SET, 0, "PLAY", NULL_KEY);
}
}
_____________________