Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Trim button names for landmarks

Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
06-03-2009 11:18
I need some help in dealing with name length for dialogue buttons, where the buttons are dynamically taken from landmarks in an objects inventory. I know that I need to have them shortened in order not to get the "24 or fewer characters" error.

//
CODE


touch_start(integer total_number)
{
listenerhandle();

integer i = 0;
MENU1 = [];
MENU2 = [];

if (landmarks <= 12)
{
for (; i < landmarks; ++i)
MENU1 += llGetInventoryName(INVENTORY_LANDMARK, i);
}
else
{
for (; i < 11; ++i)
MENU1 += llGetInventoryName(INVENTORY_LANDMARK, i);
if(landmarks > 21)
landmarks = 21;
for (; i < landmarks; ++i)
MENU2 += llGetInventoryName(INVENTORY_LANDMARK, i);

//[End Code]
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
06-03-2009 11:33
CODE

string LMName = llGetInventoryName(INVENTORY_LANDMARK,i);
MENU1 += llDeleteSubString(LMName,23,llStringLength(LMName));
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
06-03-2009 11:34
MENU1 += llGetSubString(llGetInventoryName(INVENTORY_LANDMARK, i), 0, 23);
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
06-03-2009 11:40
LOL. Argent's glass is half full. Mine is half empty. His is better. :)
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
06-03-2009 12:02
Superb, and don't feel bad Roliq, it always helps to see multiple approaches and thinking, I always learn from you guys:), and thanks Argent! I appreciate both your help:)

BTW, worked like a charm!
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-03-2009 17:30
well while you're limiting them you might as well cut them down to ~12 characters, since you won't see more than that anyways, and save your self half the bytes in memory.

and I'd like to slap the nit that decided a variable width font for a fixed viewing space was the way to go...
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
06-03-2009 18:16
MM true, Void, now i just have to figure out how to make llMapDestination work from menu buttons, when it's in an object that's not an attachment, seems like lsl loves to create catch 22's.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-03-2009 19:04
well you can store all the info (cut name, and target), or poll against the index being checked by a second script.

script 1
touch triggers polling loop on description

script 2
touch triggers dialog
gets landmark based on dialog index
saves LM target to description.

script 1
catches updated description, applies it to map destination
clears description

make sure script two has proper timeouts so that it can feed script one stop values so it's not constantly polling.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
06-03-2009 19:08
hmm well i see it conceptually, but past my level of scripting, but thanks:)
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-03-2009 20:19
I coded an example on the forums already... and people expanded on it...
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
06-03-2009 20:33
Really excellent information thanks:), who knows I may get it working as I hope eventually, with that link.
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
06-08-2009 10:58
Well I'm still struggling with this one, the following code works as far as bringing up a menu, and saying the name of the selected landmark. The problem is it does not utilize the selected landmark for "llMapDestination(sim,loc,loc);" (it brings up the location for the 1st landmark in the object's inventory instead) and the variable "sim" does not return a value.

I later want to change this script by splitting it into two, so that it passes the value to a second script with a touch event, which triggers the "llMapDestination(sim,loc,loc);" from another prim, but first need to get the basic script working properly.

/
CODE

list MENU1 = [];
list MENU2 = [];
string sim;
vector loc;

list buttons;
integer i;
integer MyChannel;
integer listener;
key toucher;
string menuText;
key LMid;

integer randBetween(integer min, integer max)
{
return (integer)(llFrand((float)(max - min)) + min);
}

Dialog(key id, list menu)
{
llSetTimerEvent(30.0);//refresh timer so listen not removed when using
llDialog(id, "\nFloo Network \n\nChoose a destination", menu, MyChannel);
//Edit just above here to add comments/info to main menu.
}

init()
{
LMid = llRequestInventoryData(llGetInventoryName(INVENTORY_LANDMARK, i));
}


default
{
state_entry()
{
llVolumeDetect(TRUE); // Starts llVolumeDetect
MyChannel = -randBetween(1, 100000); //so neighbouring devices don't interfere with each other
llListen(MyChannel, "", NULL_KEY, "");
}

on_rez(integer start_param)
{
llResetScript();
}

collision_start(integer total_number)
{
toucher = llDetectedKey(0);
listener = llListen(MyChannel, "", toucher, "");
integer numberOfLandmarks = llGetInventoryNumber(INVENTORY_LANDMARK);
i = 0;
MENU1 = [];
MENU2 = [];

if (numberOfLandmarks <= 12)
{
for (; i < numberOfLandmarks; ++i)
MENU1 += llGetSubString(llGetInventoryName(INVENTORY_LANDMARK, i), 0, 12);
}
else
{
for (; i < 11; ++i)
MENU1 += llGetSubString(llGetInventoryName(INVENTORY_LANDMARK, i), 0, 12);
if(numberOfLandmarks > 21)
numberOfLandmarks = 21;
for (; i < numberOfLandmarks; ++i)
MENU2 += llGetSubString(llGetInventoryName(INVENTORY_LANDMARK, i), 0, 12);
MENU1 += ">>";
MENU2 += "<";
}
Dialog(llDetectedKey(0), MENU1);
llSetTimerEvent(30);
}

touch_start(integer total_number)
{
llMapDestination(sim,loc,loc);
}

listen(integer channel, string name, key id, string message)
{
if (channel == MyChannel)
{
if (message == ">>")
{
Dialog(id, MENU2);
}
else if (message == "<")
{
Dialog(id, MENU1);
}
else
{
init();
llSay(0,message);
llSay(0,sim);
llSay( 0, llGetObjectDesc() );
}
}
}

changed(integer change)
{
if (CHANGED_INVENTORY)
{ llResetScript();}
else if (change & CHANGED_OWNER)
{
llResetScript();
}
}

dataserver(key requestID, string data)
{
if ( requestID == LMid )
{
LMid = NULL_KEY;
sim = llGetRegionName();
loc = (vector)data;
llSetObjectDesc( data );
}
}
}
/
CODE
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
06-08-2009 11:54
Hmmm... for starters, you have two loops that don't have a defined starting value for the counter .....

for (; i < 11; ++i) and for (; i < numberOfLandmarks; ++i) .

That could make a difference.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
06-08-2009 12:51
From: Rolig Loon
Hmmm... for starters, you have two loops that don't have a defined starting value for the counter .....

for (; i < 11; ++i) and for (; i < numberOfLandmarks; ++i) .

That could make a difference.

As long as i has been declared and defined, which it has, then a for loop will work like this also.

At work right now but I'll take a look at the code when I get home this afternoon.
_____________________
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
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
06-08-2009 16:27
It is not utilizing the chosen LM data because you are not doing anything with it except saying it. In your listen event for the menu there is nothing saying what to do with your pick. Plus you are defining "sim" as the simulator that the av is currently in.

Plus, if (CHANGED_INVENTORY) is wrong and should be corrected to if(change & CHANGED_INVENTORY), you have set a timer but have no timer event to deal with it.

Keep on trying and asking questions. You have done an awesome job with the menus and data server calls in your script so far.
_____________________
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
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-08-2009 17:54
CODE

//-- user defined function (it's only called from one spot, might as well insert it there.)
init()
{
LMid = llRequestInventoryData(llGetInventoryName(INVENTORY_LANDMARK, i));
}


//-- in your main state
listen(integer channel, string name, key id, string message)
{
//-- contained statement
init();
//-- move these for lines to the dataserver call where they are saved
llSay(0,message);
llSay(0,sim);
llSay( 0, llGetObjectDesc() );
}

dataserver(key requestID, string data)
{
if ( requestID == LMid )
{
LMid = NULL_KEY;
sim = llGetRegionName();
loc = (vector)data;
llSetObjectDesc( data );
}
}
}

the reason you aren't returning a sim is because you are trying to get the data that will be saved to it in the dataserver event, before that event can fire (because you haven't exited the listen event where you set that data)...

to get your logic down, move the says to the dataserver event where they are actually saved... this will parse well for your ultimate switch to 2 scripts.

also a fun little trick... if you read all of the landmarks into the a single list, and they are in order, you can test the response aginst the list you used to make the buttons with, and pull the exact same index in your get inventory data call
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
06-08-2009 18:03
Well, Jesse, I tried for several days, but the reason I have it saying the information was just to see if it was retrieving it properly which it does not, thanks for help on the changed event, I'll do that.

Thanks Void, I'll chew on all that :)
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-08-2009 18:44
From: Celty Westwick
Well, Jesse, I tried for several days, but the reason I have it saying the information was just to see if it was retrieving it properly which it does not, thanks for help on the changed event, I'll do that.

Thanks Void, I'll chew on all that :)

basically it amounts to the fact that functions can intterupt/be-inside-of an event, but events can't be inside of other events, they must wait for the current event to finish before the next one will be processed. (in this case dataserver can't fire before ALL the code in the listen has run)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
06-08-2009 19:14
I tried incorporating the suggestions but the only change in result is that the llSay's do nothing. I did notice one other thing. I removed the landmark that the map was opening to from the object's inventory, but it continues to bring it up, no matter what desitnations are selected on the menu. Now I am well and truly baffled. Here's what I have now.

Hopefully the timer, changed event, and init() were corrected :)

CODE

list MENU1 = [];
list MENU2 = [];
string sim;
vector loc;

list buttons;
integer i;
integer MyChannel;
integer listener;
key toucher;
string menuText;
key LMid;

integer randBetween(integer min, integer max)
{
return (integer)(llFrand((float)(max - min)) + min);
}

Dialog(key id, list menu)
{
llSetTimerEvent(30.0);
llDialog(id, "\nFloo Network \n\nChoose a destination", menu, MyChannel);
}

default
{
state_entry()
{
llVolumeDetect(TRUE);
MyChannel = -randBetween(1, 100000);
llListen(MyChannel, "", NULL_KEY, "");
}

on_rez(integer start_param)
{
llResetScript();
}

collision_start(integer total_number)
{
toucher = llDetectedKey(0);
listener = llListen(MyChannel, "", toucher, "");
integer numberOfLandmarks = llGetInventoryNumber(INVENTORY_LANDMARK);
i = 0;
MENU1 = [];
MENU2 = [];

if (numberOfLandmarks <= 12)
{
for (; i < numberOfLandmarks; ++i)
MENU1 += llGetSubString(llGetInventoryName(INVENTORY_LANDMARK, i), 0, 12);
}
else
{
for (; i < 11; ++i)
MENU1 += llGetSubString(llGetInventoryName(INVENTORY_LANDMARK, i), 0, 12);
if(numberOfLandmarks > 21)
numberOfLandmarks = 21;
for (; i < numberOfLandmarks; ++i)
MENU2 += llGetSubString(llGetInventoryName(INVENTORY_LANDMARK, i), 0, 12);
MENU1 += ">>";
MENU2 += "<";
}
Dialog(llDetectedKey(0), MENU1);
llSetTimerEvent(30);
}

touch_start(integer total_number)
{
llMapDestination(sim,loc,loc);
}

listen(integer channel, string name, key id, string message)
{
if (channel == MyChannel)
{
if (message == ">>")
{
Dialog(id, MENU2);
}
else if (message == "<")
{
Dialog(id, MENU1);
}
else
{
LMid = llRequestInventoryData(llGetInventoryName(INVENTORY_LANDMARK, i));
}
}
}

changed(integer change)
{
if(change & CHANGED_INVENTORY)
{
llResetScript();
}
else if (change & CHANGED_OWNER)
{
llResetScript();
}
}

timer()
{
llSetTimerEvent(0.0);
llListenRemove(listener);
}

dataserver(key requestID, string data)
{
if ( requestID == LMid )
{
LMid = NULL_KEY;
sim = llGetRegionName();
loc = (vector)data;
llSetObjectDesc( data );
llSay(0,sim);
llSay( 0, llGetObjectDesc() );
}
}
}
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
06-08-2009 19:19
Actually I was just playing with it and I do not see how you are going to be able to get what you want. All the data server call on a landmark returns is the global vector and not the simulator name. And you have to have the simulator name to do an llMapPosition call. Now you could cludge it together so that you parse the sim name and vector from the LM name but of course some LM's do not have that info in them.
_____________________
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
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
06-08-2009 19:40
Break it down into steps. Here is a base script that calls up the data for a single LM and llMapDestination works correctly. Just drop it in a prim along with an LM:

CODE

key LMid;
string sim;
vector vec;

default {
state_entry() {
LMid = llRequestInventoryData(llGetInventoryName(INVENTORY_LANDMARK, 0));
}
touch_start(integer n) {
llMapDestination(sim, vec, <0, 0, 0 >);
}
dataserver(key requestID, string data) {
sim = llGetRegionName();
vec = (vector) data;
}
}


Your menus are working fine so create another test script without that clutter and get it working for the db call and then lm like I did here and then add back in the menus.
_____________________
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
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
06-08-2009 20:01
Here you go> I have not optimized it yet but it works fine like this:

CODE

list MENU1 =[];
list MENU2 =[];
integer menuId;
integer lmIdx;
string sim;
vector loc;
integer i;
integer MyChannel;
integer listener;
key LMid;
key toucher;

integer randBetween(integer min, integer max)
{
return (integer) (llFrand((float) (max - min)) + min);
}

Dialog(key id, list menu)
{
llSetTimerEvent(30.0);
llDialog(id, "\nFloo Network \n\nChoose a destination", menu, MyChannel);
}

init()
{
LMid = llRequestInventoryData(llGetInventoryName(INVENTORY_LANDMARK, lmIdx));
}

default {
state_entry() {
llVolumeDetect(TRUE);
MyChannel = -randBetween(1, 100000);
llListen(MyChannel, "", NULL_KEY, "");
}

on_rez(integer start_param) {
llResetScript();
}

collision_start(integer total_number) {
toucher = llDetectedKey(0);
listener = llListen(MyChannel, "", toucher, "");
integer numberOfLandmarks = llGetInventoryNumber(INVENTORY_LANDMARK);
i = 0;
MENU1 =[];
MENU2 =[];

if (numberOfLandmarks <= 12) {
for (; i < numberOfLandmarks; ++i)
MENU1 += llGetSubString(llGetInventoryName(INVENTORY_LANDMARK, i), 0, 12);
}
else {
for (; i < 11; ++i)
MENU1 += llGetSubString(llGetInventoryName(INVENTORY_LANDMARK, i), 0, 12);
if (numberOfLandmarks > 21)
numberOfLandmarks = 21;
for (; i < numberOfLandmarks; ++i)
MENU2 += llGetSubString(llGetInventoryName(INVENTORY_LANDMARK, i), 0, 12);
MENU1 += ">>";
MENU2 += "<";
}
Dialog(llDetectedKey(0), MENU1);
menuId = 1;
llSetTimerEvent(30);
}

touch_start(integer total_number) {
llMapDestination(sim, loc, loc);
}

listen(integer channel, string name, key id, string message) {
if (channel == MyChannel) {
if (message == ">>") {
Dialog(id, MENU2);
menuId = 2;
}
else if (message == "<") {
Dialog(id, MENU1);
menuId = 1;
}
else {
if (menuId == 1) {
lmIdx = llListFindList(MENU1, (list) message);
}
else {
lmIdx = llListFindList(MENU2, (list) message) + 11;
}
init();
}
}
}

changed(integer change) {
if (change & CHANGED_INVENTORY) {
llResetScript();
}
else if (change & CHANGED_OWNER) {
llResetScript();
}
}

dataserver(key requestID, string data) {
if (requestID == LMid) {
LMid = NULL_KEY;
sim = llGetRegionName();
loc = (vector) data;
llSetObjectDesc(data);
}
}
}
_____________________
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
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
06-08-2009 20:04
Yes Jesse, I got similar non-menu code to do a single mapdestination correctly. It's something withe menued version i can't get right, I am wondering if perhaps my menu code which shortens the name by using a substring is causing the issue. No guess not i removed the substring and used a short landmark, did not help.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
06-08-2009 20:06
The variable i isn't defined in your listen event, so I don't see how your call to llRequestInventoryData is going to know which LM to look for. In fact, I don't see anything in the listen event that asks what message is being sent from the Dialog box. When you push a button other than "<" or ">>" it looks like the message will be ignored.

BTW, you can simplify your changed event with

if(change & CHANGED_INVENTORY | change & CHANGED_OWNER) llResetScript();

ETA: Ooops! This was in response to your post #19. I see things have changed since then. :)
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
06-08-2009 20:08
My last post works just fine across both menus. The key was to know which menu was being used and assign a landmark index from that to know which one to call for the db call.
_____________________
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
1 2