Jump to content

Is there an easy way to Assign String Subset to Key?


Syle Devin
 Share

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

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

Recommended Posts

Right now I am going about this in a very odd way. I am getting the substring of a numbered score, using an if statement to check which number the substring, then assigning that substring to a variable that is the same as variable assigned to the UUID.

This seems so round about, using a bunch of if statements. Is there an easier way to assign substrings to a uuid? I tried setting my variable names to numbers but that didn't work, kept getting syntax error.

 

Maybe I am going about this wrong. I'm simply trying to get score and apply coresponding number textures to faces. I have figured out applying the texture to the faces at appropriate times. Now I am just stuck on getting the inputs to know which textures to use. 

Any advice or suggestions are highly appreciated!

 

Link to comment
Share on other sites

Hmm, for the moment that is a bit much to take in. I'll look into it later but since most of my code is already written, just the score display left,  I'll likely stick to pure LSL. Although I am curious, how much slower would you say? But thank you for the suggestion, I'll check it out.

I've also run into another problem. I couldn't get string subset to work with my score. I figure that is because score is an integer not a string. Unless should it still work in some way? I'm so confused, I did not think a score display would be this challenging. I'm sure there is something I haven't thought of yet. 

 I'm trying to get teh numbers of a score to equal the UUID counterpart so I can input that into a prim params. I am lost at setting the score to equal the UUID counterpart. I did figure out a way to seperate each number of the score by putting the score into a list, each number being a seperate item. Although I couldn't figure out how to change a list item once it was added. I did not see anything in the wiki for editing a specific list item. That idea stopped short.

Link to comment
Share on other sites

I would say that JSON is so slow you should never even think about using it in real time tasks
For updating a scoreboard it would work fine although you might notice a difference

llListReplaceList() is used to replace one or more list elements at a time

Used with llList2List(), llList2Integer()llList2Rot() etc. it may be used to modify one or more elements at a time

:smileysurprised::):smileyvery-happy:

Link to comment
Share on other sites

**** I've also run into another problem. I couldn't get string subset to work with my score. I figure that is because score is an integer not a string. Unless should it still work in some way? I'm so confused, I did not think a score display would be this challenging. I'm sure there is something I haven't thought of yet.  ****

 

not sure if this helps, but.....

 

integer score = 120;

string scoreString = (string)score;

 

 

Link to comment
Share on other sites

I'm also not sure what you are trying to achieve? From what I understand, I think you have a set of textures with numbers, and want to display those corresponding to the numbers in the score.

This is how I do this. With a single texture, a list with texture offsets, and a mesh with X number of faces/materials as the display. The example script is for a mesh with 5 materials. Indexed from 0 - 4, from left to right.

key gkTexture = "874fac0e-991e-648e-64ce-d0dba03e9c22"; // Texture with numbers from 0 - 9, from left to right.
list glOffsets = [-0.45,-0.35,-0.25,-0.15,-0.05,0.05,0.15,0.25,0.35,0.45]; // texture face offsets. Indexed from 0 - 9, matching the numbers texture.


SetScore(integer _link, integer _sides, string _input) {
    
    integer iInt = (integer)llGetSubString(_input, 0, _sides-1);  // Match string length with number of sides.
    integer iDigits = llStringLength(llGetSubString(_input, 0, _sides-1)); // Get number of digits.
    llSetLinkPrimitiveParamsFast(_link, [PRIM_COLOR, ALL_SIDES, <1.0,1.0,1.0>, 0.0]); // Reset the display.
    
    while(iDigits)
    {// Display each digit on a separate face of the mesh.
        llSetLinkPrimitiveParamsFast(_link, [PRIM_TEXTURE, _sides-1, gkTexture, <0.1,1.0,0.0>, <llList2Float(glOffsets, iInt % 10),0.0,0.0>, 0.0, PRIM_COLOR, _sides-1, <1.0,1.0,1.0>, 1.0]);
        iInt /= 10;
        --_sides;
        --iDigits;
    }
}



default
{
    state_entry()
    {
        llListen(0, "", llGetOwner(), "");
    }

    listen(integer channel, string name, key id, string msg)
    {
        // SetScore(integer linknumber, integer number_of_sides, string score)
        SetScore(0, 5, msg);
    }
}

 The texture looks like this:
aR_Numbers_01.png

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3485 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...