Jump to content

Best way to InstantMessage several text strings of info.?


Raena Parx
 Share

You are about to reply to a thread that has been inactive for 411 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

On 5/7/2023 at 11:12 PM, Raena Parx said:

Thank you for the suggestion.  The receiving avatar would be on the same region because it's activated on-touch.  The strings are already formatted with "\n'"'s, but vary a lot in size.

I'm a bit lost on how the "For" operators works in .lsl. 

For example, i found this on the lsl wiki:

/block statement
integer a = 0;
integer b = 10;
for(; a < b; ++a)
{
    llOwnerSay((string)a);
    llOwnerSay((string)b);
}

why does it start with a semicolon? does that mean there's no initializer? - i'm just guessing.

and the ++a....is that a counter?  meaning "a" will increment plus one each loop?

trying to figure out how I would write a loop that reads all the data, one string at at time (so using lists for the string names, i'm guessing), and arrays?...(that's where I really get confused), then join the strings together into strings no longer than 1024 characters.  Not sure I'm that program-savvy.  But if I understand the concept, I might be able to pull it off.

Thank you for your help :)

 

 

 

Sorry, i don't frequent the forums very often but your assessment of a for loop is correct. you have an initializer, a test, and an action within a for loop.
I typically like to initialize with a variable. for(i=0; i > 100; i++){} for example will loop until the variable i is greater than 100, carry out any tasks within the loop, and then increment i by one and test again to see if i is greater than 100.

As for reading the data one object at a time, assuming you store them in an array or even using object data storage, you can just get the number of objects in the array and iterate over them, initialize a variable for your data to send at the function level to store it. then send before it reaches 1024 characters in length by checking its length before adding data to it. (alternatively by checking its length + the length of the data to add and seeing if that'll put it above 1024 before sending.)

as for the part about "it's activated on-touch" don't rely on this as a method of checking if someone is in the same region, for a lot of cases in sl it will be true, but if your script runs in a region that has neighboring regions, people in those adjacent regions can still touch the object. which would cause a regionsayto to fail. which is why you'd want a check to determine if they're in the same region before trying to regionsayto. that part is as simple as checking llGetAgentSize within the touched event to determine if they are or aren't.

default {
	touch_start(integer touch) {
    	if(llGetAgentSize(llDetectedKey(0)) != ZERO_VECTOR) {
        	llRegionSayTo(llDetectedKey(0), 0, "Welcome to the region!");
        }
        else {
        	llInstantMessage(llDetectedKey(0), "You're so far away!");
        }
    }
}

 

Edited by alexx Ohmai
Link to comment
Share on other sites

16 hours ago, alexx Ohmai said:

 

default {
	touch_start(integer touch) {
    	if(llGetAgentSize(llDetectedKey(0)) != ZERO_VECTOR) {
        	llRegionSayTo(llDetectedKey(0), 0, "Welcome to the region!");
        }
        else {
        	llInstantMessage(llDetectedKey(0), "You're so far away!");
        }
    }
}

 

Thank you so much for the explanation, and the code. I "kind of" understand it, but it is a little over my head yet.  I did find a solution already. But I really like the code you gave me to check if the toucher is in the Region. Thank you so much!

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 411 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...