Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Random Channels for Object Rezzing

Arianna Karas
Registered User
Join date: 18 Jun 2007
Posts: 5
10-07-2008 17:26
I'm currently working on a placemat which rezzes dishes on top of the placemat, as chosen through a blue dialog menu.

Well, I've gotten everything working and rezzing perfectly when only one placemat is rezzed within 10m. When I have two or more placemats on a table, the first placemat rezzed works normally. However, when choosing a dish from the second placemat's menu, the first placemat pops up it's own menu behind the second's, and then both placemats rez the same dish.

I've tried different ways of giving each individual placemat it's own channel through llFrand, but the same problems always occurs.

Can anyone give me any insight?
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-07-2008 17:34
Generate the random number in state_entry and assign it as the channel. This way each placemat will have a different channel.

If you are still having a problem then either post the whole script here or at least the part with state_entry and we will help.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
10-07-2008 17:44
From: Arianna Karas
When I have two or more placemats on a table, the first placemat rezzed works normally.
Really? That is, you can touch the "first" placemat and you get only the dialog for that one, not the second? But if you touch the second one, you get both dialogs? If so, what makes one of these the "first"? (First rezzed? First touched? ... not that I have a ready explanation, in any case.)
Arianna Karas
Registered User
Join date: 18 Jun 2007
Posts: 5
10-07-2008 18:40
From: Qie Niangao
Really? That is, you can touch the "first" placemat and you get only the dialog for that one, not the second? But if you touch the second one, you get both dialogs? If so, what makes one of these the "first"? (First rezzed? First touched? ... not that I have a ready explanation, in any case.)


By first I mean the first rezzed.

I tried adding an llFrand equation to state_entry, to no avail - here's the script if anyone can look it over.

*NOTE: With this change to the script, my avatar speaks the choices into the world as well, even though the channel isn't 0.

--------------------------------------------------------

list mainmenu = ["Breakfast","Lunch"];
list breakfastmenu = ["Main Menu", "Pastries", "SunnySideEggsandBacon", "Pancakes&Sausage", "Cereal", "Waffles&Strawberries"];
list lunchmenu = ["Main Menu", "Ham&Swiss", "RoastBeef&Cheddar", "Chili", "Cheeseburger", "TomatoSoup"];
key user;
integer channel;
integer n;
integer min = 500000;




default
{
state_entry()
{
integer randint = (integer)llFrand(n + 1);
integer channel = min + randint;
}

touch_start(integer total_number)
{
user = llDetectedKey(0);
llDialog(user,"What Would You Like to Eat?",mainmenu,channel);
llListen(channel,llKey2Name(user),user,"";);
}
listen(integer channel,string name, key id,string message)
{
if(id==user)
{

if(message=="Main Menu";)
{
llDialog(user,"Main Menu",mainmenu,channel);
return;
}
if(message=="Breakfast";)
{
llDialog(user,"Breakfast Menu",breakfastmenu,channel);
return;
}
if(message=="Lunch";)
{
llDialog(user,"Lunch Menu",lunchmenu,channel);
return;
}
if(message=="Pastries";)
{
llRezObject(message, llGetPos() + <0.0,0.0,0.065>, <0.0,0.0,0.0>, <0.0,0.0,0.0,0.0>, 0);
return;
}
if(message=="SunnySideEggsandBacon";)
{
llRezObject(message, llGetPos() + <0.0,0.0,0.038>, <0.0,0.0,0.0>, <0.0,0.0,0.0,0.0>, 0);
return;
}
if(message=="Pancakes&Sausage";)
{
llRezObject(message, llGetPos() + <0.0,0.0,0.038>, <0.0,0.0,0.0>, <0.0,0.0,0.0,0.0>, 0);
return;
}
if(message=="Cereal";)
{
llRezObject(message, llGetPos() + <0.0,0.0,0.056>, <0.0,0.0,0.0>, <0.0,0.0,0.0,0.0>, 0);
return;
}
if(message=="Waffles&Strawberries";)
{
llRezObject(message, llGetPos() + <0.0,0.0,0.030>, <0.0,0.0,0.0>, <0.0,0.0,0.0,0.0>, 0);
return;
}
if(message=="Ham&Swiss";)
{
llRezObject(message, llGetPos() + <0.0,0.0,0.043>, <0.0,0.0,0.0>, <0.0,0.0,0.0,0.0>, 0);
return;
}
if(message=="RoastBeef&Cheddar";)
{
llRezObject(message, llGetPos() + <0.0,0.0,0.018>, <0.0,0.0,0.0>, <0.0,0.0,0.0,0.0>, 0);
return;
}
if(message=="Chili";)
{
llRezObject(message, llGetPos() + <0.0,0.0,0.056>, <0.0,0.0,0.0>, <0.0,0.0,0.0,0.0>, 0);
return;
}
if(message=="Cheeseburger";)
{
llRezObject(message, llGetPos() + <0.0,0.0,0.040>, <0.0,0.0,0.0>, <0.0,0.0,0.0,0.0>, 0);
return;
}
if(message=="TomatoSoup";)
{
llRezObject(message, llGetPos() + <0.0,0.0,0.056>, <0.0,0.0,0.0>, <0.0,0.0,0.0,0.0>, 0);
return;
}

else
{
llRezObject(message, llGetPos() + <0.0,0.0,0.0>, <0.0,0.0,0.0>, <0.0,0.0,0.0,0.0>, 0);
return;
}
}
}
}
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-07-2008 18:52
Try it like this:
CODE

list mainmenu =["Breakfast", "Lunch"];
list breakfastmenu =
["Main Menu", "Pastries", "SunnySideEggsandBacon", "Pancakes&Sausage", "Cereal", "Waffles&Strawberries"];
list lunchmenu =["Main Menu", "Ham&Swiss", "RoastBeef&Cheddar", "Chili", "Cheeseburger", "TomatoSoup"];
key user;
integer channel;
integer listen_handle;


default {
state_entry() {
channel = (integer)llFrand(-1000000) - 1000000;
}

touch_start(integer total_number) {
user = llDetectedKey(0);
llDialog(user, "What Would You Like to Eat?", mainmenu, channel);
listen_handle = llListen(channel, "", user, "");
llSetTimerEvent(30.0);
}

listen(integer channel, string name, key id, string message) {
if (id == user) {

if (message == "Main Menu") {
llDialog(user, "Main Menu", mainmenu, channel);
return;
}
else if (message == "Breakfast") {
llDialog(user, "Breakfast Menu", breakfastmenu, channel);
return;
}
else if (message == "Lunch") {
llDialog(user, "Lunch Menu", lunchmenu, channel);
return;
}
else if (message == "Pastries") {
llRezObject(message, llGetPos() + <0.0, 0.0, 0.065 >, <0.0, 0.0, 0.0 >, <0.0, 0.0, 0.0, 0.0 >, 0);
return;
}
else if (message == "SunnySideEggsandBacon") {
llRezObject(message, llGetPos() + <0.0, 0.0, 0.038 >, <0.0, 0.0, 0.0 >, <0.0, 0.0, 0.0, 0.0 >, 0);
return;
}
else if (message == "Pancakes&Sausage") {
llRezObject(message, llGetPos() + <0.0, 0.0, 0.038 >, <0.0, 0.0, 0.0 >, <0.0, 0.0, 0.0, 0.0 >, 0);
return;
}
else if (message == "Cereal") {
llRezObject(message, llGetPos() + <0.0, 0.0, 0.056 >, <0.0, 0.0, 0.0 >, <0.0, 0.0, 0.0, 0.0 >, 0);
return;
}
else if (message == "Waffles&Strawberries") {
llRezObject(message, llGetPos() + <0.0, 0.0, 0.030 >, <0.0, 0.0, 0.0 >, <0.0, 0.0, 0.0, 0.0 >, 0);
return;
}
else if (message == "Ham&Swiss") {
llRezObject(message, llGetPos() + <0.0, 0.0, 0.043 >, <0.0, 0.0, 0.0 >, <0.0, 0.0, 0.0, 0.0 >, 0);
return;
}
else if (message == "RoastBeef&Cheddar") {
llRezObject(message, llGetPos() + <0.0, 0.0, 0.018 >, <0.0, 0.0, 0.0 >, <0.0, 0.0, 0.0, 0.0 >, 0);
return;
}
else if (message == "Chili") {
llRezObject(message, llGetPos() + <0.0, 0.0, 0.056 >, <0.0, 0.0, 0.0 >, <0.0, 0.0, 0.0, 0.0 >, 0);
return;
}
else if (message == "Cheeseburger") {
llRezObject(message, llGetPos() + <0.0, 0.0, 0.040 >, <0.0, 0.0, 0.0 >, <0.0, 0.0, 0.0, 0.0 >, 0);
return;
}
else if (message == "TomatoSoup") {
llRezObject(message, llGetPos() + <0.0, 0.0, 0.056 >, <0.0, 0.0, 0.0 >, <0.0, 0.0, 0.0, 0.0 >, 0);
return;
}

else {
llRezObject(message, llGetPos() + <0.0, 0.0, 0.0 >, <0.0, 0.0, 0.0 >, <0.0, 0.0, 0.0, 0.0 >, 0);
return;
}
}
}
timer() {
llListenRemove(listen_handle);
}
}
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
10-07-2008 19:08
Do what Jesse said.

The error in your first script is that n is 0. llFrand is really just returning a float value from 0 to 1, you then convert it to a integer. So over 99% of the time it will be 0.
So the channel that you are getting is 500001. Another fix would be to change the integer n; line to integer n=10000;
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-07-2008 19:28
I forgot to mention that you did a nice job for a new lsl scripter and that it is a pretty creative idea.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Arianna Karas
Registered User
Join date: 18 Jun 2007
Posts: 5
10-07-2008 19:41
Thank you Jesse! I have a bit of practice in Java programming from high school, but it's been ages.

Ok, I've tried both ways, and it's still giving me that same problem. Which ever placemat I touch second spawns both mat's menu's.

Could it be something in the rest of the coding?
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
10-07-2008 20:05
you are removing the listen with a timer. so why not generate a new channel on touch rather than only once in the state entry? i do that for anything i use menus for. and while we're on the random channel topic, what do you do with the items that are rezzed as far as removing them to rez a new one? i like to generate a random channel and pass it to the object thru the param integer, then when it comes time to rezz a new item, it would first tell it to die on that channel and then change the channel before rezzing the new item with a new channel.
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Arianna Karas
Registered User
Join date: 18 Jun 2007
Posts: 5
10-07-2008 20:22
Right now, I have a temp-rezzing script inside the dishes that kills them after a minute, or whatever the time is on that server.

How would I pass the channel on to the rezzed object? Could I get an example if possible? Now that I think about it, having the objects destruct before a new one rezzes might be a better option. Would that work with a "Clear All" button on my menu as well?
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
10-07-2008 20:58
alrighty, i cleaned up the current script some, and added the prim channel i mentioned before. and the script to drop into the items will listen for the word die, but also change it's position on rez. also i added llGetRot() to the rez command, you had it at zero rotation before which wouldn't really look right if the placemat is rotated. as for the clear all, it will only work for each placemat and the item on top of it

From: someone

list mainmenu =["Breakfast", "Lunch", "Clear"];
list breakfastmenu =
["Main Menu", "Pastries", "SunnySideEggsandBacon", "Pancakes&Sausage", "Cereal", "Waffles&Strawberries"];
list lunchmenu =["Main Menu", "Ham&Swiss", "RoastBeef&Cheddar", "Chili", "Cheeseburger", "TomatoSoup"];
key user;
integer channel;
integer listen_handle;
integer primchan;


default {

touch_start(integer total_number) {
user = llDetectedKey(0);
channel = (integer)llFrand(-1000000) - 1000000;
llDialog(user, "What Would You Like to Eat?", mainmenu, channel);
listen_handle = llListen(channel, "", user, "";);
llSetTimerEvent(30.0);
}

listen(integer channel, string name, key id, string message) {
if (id == user) {
if (message == "Main Menu";) {
llDialog(user, "Main Menu", mainmenu, channel);
return;
}
else if (message == "Breakfast";) {
llDialog(user, "Breakfast Menu", breakfastmenu, channel);
return;
}
else if (message == "Lunch";) {
llDialog(user, "Lunch Menu", lunchmenu, channel);
return;
}
else if (message == "Clear";) {
llWhisper(primchan,"die";);
return;
}
else {
llWhisper(primchan,"die";);//tell the current item to die
primchan = (integer)llFrand(-1000000) - 10000;//create a new channel for the new item to listen on
llRezObject(message, llGetPos() ,<0.0, 0.0, 0.0 >,llGetRot(),primchan);//rez the object at the placemat's position and send the prim chan thru the rez param
return;
}
}
}
timer() {
llListenRemove(listen_handle);
}
}


and then drop this one into each item and change the offset

From: someone

vector offset = <0.0, 0.0, 0.056 >;//just change the offset to for each item
default
{
on_rez(integer chan)
{
llSetPos(llGetPos() + offset);
llListen(chan, "","","";);
}

listen(integer channel, string name, key id, string str)
{
if(str == "die";){
llDie();
}
}
}
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Arianna Karas
Registered User
Join date: 18 Jun 2007
Posts: 5
10-07-2008 22:04
Thank You! The placemats work like a charm!