Difference between revisions of "User talk:Ugleh Ulrik"

From Second Life Wiki
Jump to navigation Jump to search
(Added notes and previously forgotten signature.)
(→‎Template:Hl3: new section)
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
= Suggestions =
== Stristr ==


== Vector2List ==
I don't know what came over me but I totally rewrote Stristr. It makes a good example but it shouldn't be used as a user function. The programmer already knows at compile time if the string is going to be empty and if they want the before or after value. In most cases you won't be working with null strings and you will want the one string or the other but never will it change during execution. This means if you created a specialized function for each case, each function would be about 3 lines of code. It's better IMHO to inline three lines of code and cement understanding then to create a function to do it for you.


<lsl>// Created by Strife Onizuka
I also added comments. I removed the example and func_footnote because it was the wrong way to do existence checking. -- '''[[User:Strife_Onizuka|Strife]]''' <sup><small>([[User talk:Strife_Onizuka|talk]]|[[Special:Contributions/Strife_Onizuka|contribs]])</small></sup> 06:17, 31 May 2010 (UTC)


// Posted on this page by Fred Gandt
I knew someone was going to write it better, because I knew there was a different way then to use lists, seeing as a paragraph would probably waist memory, and was hoping for you or someone to edit it, the reason i made Stristr is because i used the same php function recently, and decided to import it into SL.


list Vector2List(vector v){
I just rechecked, and I was looking for a llSubStringIndex, i swear i searched for it and couldn't find it, i must of searched the wrong thing -.-
    return [v.x, v.y, v.z];
,thanks
}</lsl>
<b>--</b>[[File:Uglehsig.png|53px|link=User:Ugleh_Ulrik]]([[User_talk:Ugleh_Ulrik|talk]]) 06:43, 31 May 2010 (UTC)


== FirstName & LastName ==
:Yeah the search can be a pain. -- '''[[User:Strife_Onizuka|Strife]]''' <sup><small>([[User talk:Strife_Onizuka|talk]]|[[Special:Contributions/Strife_Onizuka|contribs]])</small></sup> 17:41, 31 May 2010 (UTC)


<lsl>// Created by Fred Gandt
== Template:Hl3 ==


key name_q; // Used to referrence dataserver requests.
Good call. -- '''[[User:Strife_Onizuka|Strife]]''' <sup><small>([[User talk:Strife_Onizuka|talk]]|[[Special:Contributions/Strife_Onizuka|contribs]])</small></sup> 19:26, 6 March 2014 (PST)
 
string FirstName(string name) // Deliver the name.
{
    return llDeleteSubString(name, llSubStringIndex(name, " "), -1);
}  // Return name with all removed from the separating space to the end.
 
string LastName(string name) // Deliver the name.
{
    return llGetSubString(name, (llSubStringIndex(name, " ") + 1), -1);
}  // Return name from the separating space to the end.
 
string FirstOrLastName(string name, integer FoL) // TRUE for first name, FALSE for last name.
{
    if(FoL) // If FoL == TRUE...
    return llDeleteSubString(name, llSubStringIndex(name, " "), -1); // Return first name.
    return llGetSubString(name, (llSubStringIndex(name, " ") + 1), -1); // If FoL != TRUE return last name.
}
 
default
{
    state_entry()
    {
        key owner = llGetOwner(); // We need a key...wherever it may come from.
        name_q = llRequestAgentData(owner, DATA_NAME); // Request the name that belongs to that key.
    }
    dataserver(key q, string data) // Triggered by a return of data requested.
    {
        if(q == name_q) // Check which request is being answered.
        {
            llOwnerSay("First name - " + FirstName(data)); // Say the data.
           
            llOwnerSay("Last name - " + LastName(data)); // Say the data.
           
            llOwnerSay("First name - " + FirstOrLastName(data, TRUE)); // Say the data.
           
            llOwnerSay("Last name - " + FirstOrLastName(data, FALSE)); // Say the data.
        }
    }
}</lsl>
 
== TrimString ==
 
<lsl>// Created by Fred Gandt
 
string TrimStringToLength(string text, integer length) // Deliver text and desired length of output.
{
    if(length >= llStringLength(text)) // If text is shorter than or the same length as desired...
    return text; // Send text back.
    return (llGetSubString(text, 0, (length - 4)) + "..."); // Else, get string from text and add continuum dots.
}
 
default
{
    state_entry()
    {
        llOwnerSay(TrimStringToLength("I like toitles!! - http://www.youtube.com/watch?v=CMNry4PE93Y", 19));
    }
}</lsl>-- '''[[User:Fred_Gandt|Fred Gandt]]''' <sup><small>([[User talk:Fred_Gandt|talk]]|[[Special:Contributions/Fred_Gandt|contribs]])</small></sup> 03:32, 24 April 2010 (UTC)

Revision as of 20:26, 6 March 2014

Stristr

I don't know what came over me but I totally rewrote Stristr. It makes a good example but it shouldn't be used as a user function. The programmer already knows at compile time if the string is going to be empty and if they want the before or after value. In most cases you won't be working with null strings and you will want the one string or the other but never will it change during execution. This means if you created a specialized function for each case, each function would be about 3 lines of code. It's better IMHO to inline three lines of code and cement understanding then to create a function to do it for you.

I also added comments. I removed the example and func_footnote because it was the wrong way to do existence checking. -- Strife (talk|contribs) 06:17, 31 May 2010 (UTC)

I knew someone was going to write it better, because I knew there was a different way then to use lists, seeing as a paragraph would probably waist memory, and was hoping for you or someone to edit it, the reason i made Stristr is because i used the same php function recently, and decided to import it into SL.

I just rechecked, and I was looking for a llSubStringIndex, i swear i searched for it and couldn't find it, i must of searched the wrong thing -.- ,thanks --Uglehsig.png(talk) 06:43, 31 May 2010 (UTC)

Yeah the search can be a pain. -- Strife (talk|contribs) 17:41, 31 May 2010 (UTC)

Template:Hl3

Good call. -- Strife (talk|contribs) 19:26, 6 March 2014 (PST)