Wednesday 30 March 2011

LLDialog NPC HUD controller work-in-progress

K so the code doesn't work yet because it's splitting the list up based on UUID and you can't have more than 24 characters for a button (so that indicates it's actually working for the most part). What we should be doing is keeping two separate lists which are associated to each other by index, one for botName and one for botUUIDs. That way we can choose the bot by name but we will know the index and that will give us the corresponding UUID. Anyways, work on it another time since it's time for bed....

list lstBotList;
list main_menu = ["Blue", "Red"];
list blue_menu = ["Blue Stuff 1", "Blue Stuff 2", "Back"];
list red_menu = ["Red Stuff 1", "Red Stuff 2", "Back"];
integer submenu = FALSE;
integer listen_channel = 1;


default
{
state_entry()
{
llSetText("Touch to split parse the string", <1,0,0>, 1.0);

}

touch_end(integer num)
{


list a = osGetAvatarList();


integer i;
integer intCount= 1;
integer s = llGetListLength(a);
do
{

if (intCount == 4)
{

intCount = 1;
}
if (intCount == 1)
{
string strListItem = llList2String(a,i);
llSay(0,strListItem);
lstBotList = [strListItem] + lstBotList;
}
intCount++;
}
while(s>++i);
llSay(0, "Touched.");
llDialog(llDetectedKey(0),"Try a selection...", lstBotList, listen_channel);
state stReadToGenerateLLDialog;
}

}

state stReadyToGenerateLLDialog
{
state_entry()
{
llListen(listen_channel,"",llGetOwner(),"");
//llSay(0, "Hello, Avatar!");
llSetText("Sample menu using LLDialog", <1,0,0>, 1.0);
}


listen(integer channel, string name, key id, string message)
{
if (submenu == FALSE)
{
// Use a main menu verification

if (message == "Blue")
{
llSay(0,"Thanks for picking " + message);
llDialog(id,message + " Dialog", blue_menu, listen_channel);
}

if (message == "Red")
{
llSay(0,"Thanks for picking " + message);
llDialog(id,message + " Dialog", red_menu, listen_channel);
}

submenu = TRUE;
llSetTimerEvent(20.0);
}
else
{
// Use a sub menu verification

llSetTimerEvent(20.0);
if (message == "Back")
{
llDialog(id,message + " Dialog", main_menu, listen_channel);
submenu = FALSE;
}
else
{
llSay(0,"You picked " + message);
//might want to verify which sub-menu was being used to redisplay here, etc
submenu = FALSE;
}
}
}

timer()
{
llSetTimerEvent(0.0);
llSay(0,"You waited too long to pick, resetting menu.");
submenu = FALSE;
}
}

No comments:

Post a Comment