Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Confused with events...

Klaire Larnia
Learner, be gentle....
Join date: 2 Jun 2008
Posts: 41
05-29-2009 12:19
Okay I am confused... :confused: :confused: :confused:

I have a script that reads data from two notecards and uses one to configure two lists which become menu dialog boxes. all variables are set with integer/string/list commands etc. And the dialogue handling code is missing off the end as it is not related to my problem as you will see.

---

At the moment the script is about 90% there, bar the fact that once the script goes all the way to the end, it exits and does not loop round to allow the prim it lives in to be clicked on again.

I think it is due to the touch_event not being in the main program state so it has no way to re-access that event.

Below main part of the script show how the two sections interlink... Now this works fine. No errors, problems or anything (bar not allow a user to click again).

CODE


default
{
state_entry()
{
llSay(0, "TSWTS Test");
CardName1 = llGetInventoryName(INVENTORY_NOTECARD, 0);
CardDataRead1 = llGetNotecardLine(CardName1, CardLine1);
CardName2 = llGetInventoryName(INVENTORY_NOTECARD, 1);
CardDataRead2 = llGetNotecardLine(CardName2, CardLine2);
}
dataserver (key Data_id, string CardData) {
if (Data_id == CardDataRead1) {
if (CardData !=EOF) {
AllowList = AllowList + CardData;
++CardLine1;
CardDataRead1 = llGetNotecardLine(CardName1, CardLine1);

}
}
else if (Data_id == CardDataRead2) {
if (CardData !=EOF) {
MenuList = MenuList + CardData;
++CardLine2;
CardDataRead2 = llGetNotecardLine(CardName2, CardLine2);

}
}

}

touch_start(integer total_number)
{
toucher = llDetectedKey(0);
state mainmenu;
}
}


state mainmenu
{
state_entry()
{
llSay(0, "Mainmenu");
MenuMain1 = MenuMain1+llList2String(MenuList, 0)+llList2String(MenuList, 1)+llList2String(MenuList, 2);
MenuMain2 = MenuMain2+llList2String(MenuList, 3)+llList2String(MenuList, 4)+llList2String(MenuList, 5);
llListen(Channel, "", NULL_KEY, ""); // listen for dialog answers (from multiple users)
llDialog(toucher, "What do you want to do?", MenuMain1, Channel); // present dialog on click
toucher = NULL_KEY;
}
/
CODE



Okay... I thought about how to alter this and came up with the code below. Now to me should work. BUT there is a problem which I do not understand.

Let me show you the code first:


CODE

default
{
state_entry()
{
llSay(0, "TSWTS Tes");
CardName1 = llGetInventoryName(INVENTORY_NOTECARD, 0);
CardDataRead1 = llGetNotecardLine(CardName1, CardLine1);
CardName2 = llGetInventoryName(INVENTORY_NOTECARD, 1);
CardDataRead2 = llGetNotecardLine(CardName2, CardLine2);
}
dataserver (key Data_id, string CardData) {
if (Data_id == CardDataRead1) {
if (CardData !=EOF) {
AllowList = AllowList + CardData;
++CardLine1;
CardDataRead1 = llGetNotecardLine(CardName1, CardLine1);

}
}
else if (Data_id == CardDataRead2) {
if (CardData !=EOF) {
MenuList = MenuList + CardData;
++CardLine2;
CardDataRead2 = llGetNotecardLine(CardName2, CardLine2);

}
}
state mainmenu;
}
}


state mainmenu
{
state_entry()
{
llSay(0, "Mainmenu");

if (menuset == FALSE)
{
llSay(0, "False");
MenuMain1 = MenuMain1+llList2String(MenuList, 0)+llList2String(MenuList, 1)+llList2String(MenuList, 2);
MenuMain2 = MenuMain2+llList2String(MenuList, 3)+llList2String(MenuList, 4)+llList2String(MenuList, 5);
menuset = TRUE;
}
}

touch_start(integer total_number)
{
toucher = llDetectedKey(0);
llListen(Channel, "", NULL_KEY, ""); // listen for dialog answers (from multiple users)
llDialog(toucher, "What do you want to do?", MenuMain1, Channel); // present dialog on click
}



When I run this version, the menu lists are NOT created. I know the routine to make them is accessed, as I put a test llSay command in there to prove it. but get a script error when run and you click on the prim saying: Object: llDialog: all buttons must have label strings

I am totaly confused. Why are the menus created in the first one but not in the second? The commands are identical, they are just accessed in a slightly different place within the script but I did not thing that would make any difference to be honest.

I hope that waffling makes some sense.. I cannot explain it correctly as my English lets me down being a second language to me.

Any help is appreicate.
_____________________
Klaire
xXx =^.^= xXx
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
05-29-2009 12:28
Create else conditionals to counter these two conditional tests:

if (CardData !=EOF) {

and call state main from there. In other words, if you ARE at EOF then you jump to state main.
_____________________
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
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
05-29-2009 13:40
From: Jesse Barnett
Create else conditionals to counter these two conditional tests:

if (CardData !=EOF) {

and call state main from there. In other words, if you ARE at EOF then you jump to state main.
Right! as it is after one note card line is read you enter the mainmenu state and no more lines are read
_____________________
From Studio Dora
Klaire Larnia
Learner, be gentle....
Join date: 2 Jun 2008
Posts: 41
05-29-2009 14:31
Typical a long complicated question gets a short simple answer :) I will go and try that in a moment.

----

Update: I have it working now thank you. I was on the right track with my alteration which is pleasing. Still a couple of bugs in it but I will resolve those.

Thank you both again.
_____________________
Klaire
xXx =^.^= xXx
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
05-29-2009 14:54
You are calling both data queries in state entry. Now it may work like that, I am not in world to test it. But I usually call the first and then have it call the next when it is finished.

CODE

list allowList;
list menuList;
string nName;
integer nLine = 0;
key allowQuery;
key menuQuery;

default {
state_entry() {
llSay(0, "TSWTS Tes");
allowList = [];
nName = llGetInventoryName(INVENTORY_NOTECARD, 0);
allowQuery = llGetNotecardLine(nName, nLine);

}
dataserver(key queryid, string data) {
if (queryid == allowQuery) {
if (data != EOF) {
allowList += data;
++nLine;
allowQuery = llGetNotecardLine(nName, nLine);
}
else{
nName = llGetInventoryName(INVENTORY_NOTECARD, 1);
nLine = 0;
menuQuery = llGetNotecardLine(nName, nLine);
}
}
else if (queryid == menuQuery) {
if (data != EOF) {
menuList += data;
++nLine;
menuQuery = llGetNotecardLine(nName, nLine);

}
else{
state mainmenu;
}
}
}
}

state mainmenu {
touch_start(integer total_number) {
llOwnerSay("allowList = " + llList2CSV(allowList));
llOwnerSay("menuList = " + llList2CSV(menuList));
}
}
_____________________
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