• Bitte schaltet eure Ad Blocker aus. SLinfo kann nur betrieben werden, wenn es durch Werbung Einnahmen erzielt. Vielen Dank!!
  • Wir freuen uns, wenn du dich in unserem Forum anmeldest. Bitte beachte, dass die Freigabe per Hand durchgeführt wird (Schutz vor Spammer). Damit kann die Freigabe bis zu 24 Stunden dauern.
  • Wir verwenden Cookies, um Inhalte und Anzeigen zu personalisieren, Funktionen für soziale Medien anbieten zu können und die Zugriffe auf unsere Website zu analysieren. Sie geben Einwilligung zu unseren Cookies, wenn Sie unsere Webseite weiterhin nutzen.

Color Change Hud Problem

Cedric Barbosa

Aktiver Nutzer
Hi zusammen,
ich hab ein Problem mit folgenden Scripten:
Listener:

PHP:
default
{
    state_entry()
    {
        llListen(-1,"",NULL_KEY,"");
    }
    listen(integer channel, string name, key id, string message)
    {
        llSetColor((vector)message,ALL_SIDES);
    }
}


Hud:

PHP:
integer build_prim = TRUE;
integer allow_anyone = FALSE;
integer continuous_link_update = TRUE;
integer show_floating_text = TRUE;

// These will be overriden if you set "build_prim" to TRUE.
integer color_chooser_face = 0;
integer color_preview_face = 2;
integer color_brightness_face = 4;

integer link_message_scope = LINK_SET;
string link_message_text = "color_chooser";
integer updates_per_second = 20;


key toucher = NULL_KEY;
integer original_touch_face = -1;
vector original_color = <1.0, 1.0, 1.0>;
float original_brightness = 1.0;

vector color = <1.0, 1.0, 1.0>;
float brightness = 1.0;
vector last_uv_touch_position = <-1.0, -1.0, 0.0>;

updateFloatingText()
{
    vector final_color = color * brightness;
    integer red = llCeil(final_color.x * 255.0);
    integer green = llCeil(final_color.y * 255.0);
    integer blue = llCeil(final_color.z * 255.0);
    //llSetText("SL Color: " + (string)final_color + "\nStandard Color: <" + (string)red + ", " + (string)green + ", " + (string)blue + ">", <1.0, 1.0, 1.0>, 1.0);
    llSetText("",<0,0,0>,1);
    llSay(1518, (string)final_color);
}

default
{
    state_entry()
    {
        if (show_floating_text) updateFloatingText();
        else llSetText("", ZERO_VECTOR, 0.0);
        
        if (build_prim)
        {
            color_chooser_face = 0;
            color_preview_face = 2;
            color_brightness_face = 4;
            
            llSetPrimitiveParams([
                PRIM_TYPE,
                    PRIM_TYPE_BOX,
                        PRIM_HOLE_DEFAULT,
                        <0.0, 1.0, 0.0>,
                        0.0,
                        ZERO_VECTOR,
                        <0.75, 1.0, 0.0>,
                        <-0.07, 0.0, 0.0>,
                PRIM_SIZE,
                    <2.7, 0.5, 0.01>
            ]);
            llSetPrimitiveParams([
                PRIM_TEXGEN, ALL_SIDES,
                    PRIM_TEXGEN_DEFAULT,
                PRIM_COLOR, ALL_SIDES,
                    ZERO_VECTOR, 1.0,
                PRIM_FULLBRIGHT, ALL_SIDES,
                    TRUE
            ]);
            llSetPrimitiveParams([
                PRIM_TEXTURE, color_brightness_face,
                    "10e28202-e90b-4e28-e607-3d883f584b45",
                    <1.0, 1.0, 0.0>,
                    ZERO_VECTOR,
                    PI_BY_TWO,
                PRIM_TEXTURE, color_chooser_face,
                    "f52060e5-a4cc-3555-27c7-e7b6c2bf50ed",
                    <1.0, 1.0, 0.0>,
                    ZERO_VECTOR,
                    0.0,
                PRIM_TEXTURE, color_preview_face,
                    "ee5569d3-f819-18f0-4787-7f23e792f013",
                    <1.0, 1.0, 0.0>,
                    ZERO_VECTOR,
                    -PI_BY_TWO,
                PRIM_COLOR, color_brightness_face,
                    color, 1.0,
                PRIM_COLOR, color_chooser_face,
                    <1.0, 1.0, 1.0> * brightness, 1.0,
                PRIM_COLOR, color_preview_face,
                    color * brightness, 1.0
            ]);
        }
    }
    
    touch_start(integer n)
    {
        key detected_toucher = llDetectedKey(0);
        if ((toucher == NULL_KEY || llGetTime() > 0.25) && (detected_toucher == llGetOwner() || allow_anyone))
        {
            integer touch_face = llDetectedTouchFace(0);
            if (touch_face == color_chooser_face || touch_face == color_brightness_face)
            {
                toucher = detected_toucher;
                original_touch_face = touch_face;
                original_color = color;
                original_brightness = brightness;
            }
        }
    }
    
    touch(integer n)
    {
        if (toucher == llDetectedKey(0) && llGetTime() >= (1.0 / (float)updates_per_second))
        {
            vector uv_touch_position = llDetectedTouchUV(0);
            if (uv_touch_position == last_uv_touch_position)
            {
                return;
            }
            
            last_uv_touch_position = uv_touch_position;
            vector last_color = color;
            float last_brightness = brightness;
            
            integer touch_face = llDetectedTouchFace(0);
            if (touch_face != original_touch_face)
            {
                color = original_color;
                brightness = original_brightness;
            }
            else
            {
                uv_touch_position.y = (uv_touch_position.y - 0.03) / 0.94;
                if (uv_touch_position.y < 0.0) uv_touch_position.y = 0.0;
                else if (uv_touch_position.y > 1.0) uv_touch_position.y = 1.0;
                
                if (touch_face == color_chooser_face)
                {
                    color = ZERO_VECTOR;
                    
                    uv_touch_position.x = (uv_touch_position.x - 0.006) / 0.988;
                    if (uv_touch_position.x < 0.0) uv_touch_position.x = 0.0;
                    else if (uv_touch_position.x > 1.0) uv_touch_position.x = 1.0;
                    
                    if (uv_touch_position.x <= 0.33333)
                    {
                        if (uv_touch_position.x < 0.16667) color.x = 1.0;
                        else color.x = 1.0 - ((uv_touch_position.x - 0.16667) / 0.16666);
                    }
                    else if (uv_touch_position.x >= 0.66667)
                    {
                        if (uv_touch_position.x <= 0.83333) color.x = (uv_touch_position.x - 0.66667) / 0.16666;
                        else color.x = 1.0;
                    }
                    
                    if (uv_touch_position.x < 0.66667)
                    {
                        if (uv_touch_position.x <= 0.16666) color.y = uv_touch_position.x / 0.16666;
                        else if (uv_touch_position.x < 0.5) color.y = 1.0;
                        else color.y = 1.0 - ((uv_touch_position.x - 0.5) / 0.16666);
                    }
                    
                    if (uv_touch_position.x > 0.33333)
                    {
                        if (uv_touch_position.x <= 0.5) color.z = (uv_touch_position.x - 0.33334) / 0.16666;
                        else if (uv_touch_position.x < 0.83333) color.z = 1.0;
                        else color.z = 1.0 - ((uv_touch_position.x - 0.83333) / 0.16667);
                    }
                    
                    color = (color * (1.0 - uv_touch_position.y)) + (<1.0, 1.0, 1.0> * uv_touch_position.y);
                }
                else if (touch_face == color_brightness_face)
                {
                    brightness = uv_touch_position.y;
                }
                else
                {
                    return;
                }
            }
            
            if (((brightness != last_brightness) || (color != last_color))) {
                if ((brightness != last_brightness)) llSetColor((<1.0,1.0,1.0> * brightness),0);
                if ((color != last_color)) llSetColor(color,4);
                llSay(-1,((string)(color * brightness)));
            }
            llResetTime();
        }
    }


    touch_end(integer n) {
        integer i;
        for (i = 0; (i < n); i += 1) {
            if ((llDetectedKey(i) == toucher)) {
                toucher = NULL_KEY;
                return;
            }
        }
    }
}

Im grunde macht das Ding genau was es soll, nur scheint es da ein Problem mit der Reichweite zu geben denn ab ner gewissen Entfernung ändert sich nichts mehr!
Kann man das irgendwie erweitern? 30 - 50 Meter sollten reichen! Hab aber im Script jetzt nichts gefunden was irgendwie auf ne Distanz hinweist! Naja ... und wirklich Ahnung hab ich davon auch nicht, von daher kanns sein das nur ich das nicht sehe lol
 
Hallo Cedric

Ohne den Skript getestet zu haben. Der HUD übermittelt den Wert mittels llSay, dieser Befehl hat Reichweite von 20m. Wenn Du statdessen llShout nimmst, wird es 100m reichen, und llRegionSay macht sogar simweit. Aber dann bitte nicht den Channel -1 nehmen. Die Nummer ist sehr klein, da kann es evtl. weitere ungesicherte Skripte in der Sim geben, die auf dem Channel hören und dann machst Du eine Störung. Irgendeine 4-6 stellige Zahl müsste das Überschneiden reduzieren.
 

Users who are viewing this thread

Zurück
Oben Unten