Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

String manipulation help plz

Nyef Nyak
Junior Member
Join date: 23 Jul 2004
Posts: 17
08-14-2004 15:05
I've never done string manipulation and I need a little help please, how could i find out if the string has an "a" in front of it?

what I want is:

var1 llGetTexture(ALL_SIDES)
if var1/'s first char is an a/
var1 == /var1 without the a/

if var1/'s first char is not an a/
var1 == /var1 with an a as first char/

This is all i'm lacking from completing my script, Many thanks!
Eggy Lippmann
Wiktator
Join date: 1 May 2003
Posts: 7,939
08-14-2004 15:41
Use the wiki, luke:
Strings and related functions

In particular:

llGetSubString

Of course, that piece of code you posted is FAR away from being valid LSL.
First of all, llGetTexture returns the texture's key, not its name. Using ALL_SIDES with llGetTexture is nonsense. It works, but it's silly :)
See llGetTexture for more details.

And "==" can only be used for comparisons which return a boolean value, not assignments. You need a plain "=" for that.
Nyef Nyak
Junior Member
Join date: 23 Jul 2004
Posts: 17
08-14-2004 15:57
CODE

touch_start(integer total_number)
{

if (llGetOwner() == llDetectedKey(total_number - 1))
{
vartexture = llGetTexture(ALL_SIDES);
if (llGetSubString(vartexture, 0, 0) == "a")
{
vartexture = llDeleteSubString(vartexture,0,0);
llSetTexture(vartexture,ALL_SIDES);
}
else
{
vartexture = llInsertString(vartexture, 0, "a");
llSetTexture(vartexture,ALL_SIDES);
}
}
}



ok then, i got it to work, thanks eggy, my prob was using the ==, i guess i've just never noticed it before I've usually always just used = and then changed it on error because I didnt know the criteria in which you needed it
Anyways the textures are in the inventory, but I do have a question if theres a better way to do this texturing thing, they are generated randomly from a list on the main object which sends the link message in which the link message str is set as the texture. I couldnt think of any other way to do this, but there has to be a better one, comments anyone?
Eggy Lippmann
Wiktator
Join date: 1 May 2003
Posts: 7,939
08-14-2004 16:03
You could start by explaining what on earth you are trying to do :)
I don't see anything wrong with your code, aside from the fact that llGetTexture(ALL_SIDES) is a little silly :)
Nyef Nyak
Junior Member
Join date: 23 Jul 2004
Posts: 17
08-14-2004 16:09
ok then,
first off if you dont understand the concept completely, ill let you see it in game and itll come clear
im making a bingo card, the main board randomizes the numbers and send a messagelinked to with a 1, 2, 3, 4, etc. to let the prims on the car know if its talking to them. (im doing that because I really cant figure out how to find out which prim is what number yet, will do later)
I'm using allsides because I tried sides 1-6 which i think should be all a rectangle has, and none of them came up right, so I said screw it set all other sides to color black so the texture doesnt show up.
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
09-09-2004 12:32
Judging from the date on that post, I have to guess you have completed this project by now. If not, then use the search tool (scroll up on the search tool at the bottom of the page).. There is a script floating around that will put the numbers on the sides of the prim. Although there are 6 obvious sides to a cube, I believe I heard that there is also an "inside" side. The other thing is that the side numbers start with Zero. Check the Wiki for details Wiki
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts