Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
Gender Poseball
#1
Gender Poseball
Ein Poseball das 3 Geschlechter kennt:
male_animationsname
female_animationsname
unknown_animationsname
der Anfang ist die Geschlechterkennung/Zuweisung.
Es werden einfach eure Animationen in das Prim kopiert und das Geschlecht vorgesetzt.
Es ist eigentlich ganz einfach zu handhaben.
Die Animation umbenennen zum Beispiel von „sit1 female“ in „female_sit1“
genauso bei den male_ und unknown_ Animationen vorgehen
und diese in den Poseball kopieren (Bitte keine Leerzeichen).
Anschließend die Animationsposition einstellen „vector target = <0.0, 0.0, 1.0>;“ Breite, Tiefe und Höhe.
Ich habe mal 3 Beispiele und ein paar Animationen zum Testen in meinem Grid zum Mitnehmen hingestellt.
http://openmanniland.de:8002/ Welcome

Ein Anwendungsbeispiel wäre eine Couch mit 6 male Animationen, 6 female Animationen, 1 unknown Animation.
Beim Setzen wird dann geschaut, welches Geschlecht der/die/das sich setzende hat
und eine entsprechende Zufallsanimation wird abgespielt.

gender_poseball.lsl
PHP-Code:
vector target = <0.00.01.0>; // Ändere diese Werte, um die Position deines Avatars anzupassen.
// rotation localrot = ZERO_ROTATION; // Rotationsposition des Avatars abschalten.
rotation localrot llEuler2Rot(<900, -90>*DEG_TO_RAD); // Rotationsposition des Avatars setzen.
list male_animations// Liste für männliche Animationen
list female_animations// Liste für weibliche Animationen
list unknown_animations// Liste für das dritte Geschlecht Animationen
integer used// Als Flagge verwendet, um zu bestimmen, was das Skript tun soll.
key user// Hier wird der Schlüssel des Benutzers gespeichert, der den Poseball benutzt
string chosen_anim// Hier wird die ausgewählte Animation gespeichert

default
{
    
state_entry()
    {
        
llSitTarget(targetlocalrot);
        
        
// Animationen im Inventar sammeln
        
integer num_anims llGetInventoryNumber(INVENTORY_ANIMATION);
        
integer i;
        for (
0num_anims; ++i) {
            
string anim_name llGetInventoryName(INVENTORY_ANIMATIONi);
            if (
llSubStringIndex(anim_name"male_") == 0) {
                
male_animations += anim_name;
            } else if (
llSubStringIndex(anim_name"female_") == 0) {
                
female_animations += anim_name;
            } else if (
llSubStringIndex(anim_name"unknown_") == 0) {
                
unknown_animations += anim_name;
            }
        }
        
        if (
male_animations == [] && female_animations == [] && unknown_animations == []) {
            
state error// Gehe und warte, bis sich das Inventar geändert hat.
        
} else { // Ansonsten...
            
llOwnerSay("Gefundene Animationen: Männlich: " + (string)llGetListLength(male_animations) + ", Weiblich: " + (string)llGetListLength(female_animations) + ", Unbekannt: " + (string)llGetListLength(unknown_animations)); // Bestätige, dass sich Animationen im Inventar befinden
        
}
    }
 
    
changed(integer change)
    {
        if (
change CHANGED_LINK// Wird ausgelöst, wenn jemand auf den Poseball sitzt. Wenn du dich hinsetzt, wirst du tatsächlich mit dem Ball verlinkt.
        
{
            if(!
used)
            {
                
used TRUE;
                
user llAvatarOnSitTarget();
                if(
user == NULL_KEYused FALSE// Stelle sicher, dass wirklich jemand auf dem Poseball sitzt
                
llSetAlpha(0.0,ALL_SIDES); // Verstecke den Poseball, wenn darauf gesessen wird
                
osAvatarStopAnimation(user"sit"); // Stoppe die Standard-Sitzanimation (WICHTIG!)
                
                // Geschlecht des Benutzers abrufen
                
string gender osGetGender(user);
                
                
// Zufällige Animation auswählen und abspielen
                
if (gender == "male") {
                    
chosen_anim llList2String(male_animationsllFloor(llFrand(llGetListLength(male_animations))));
                } else if (
gender == "female") {
                    
chosen_anim llList2String(female_animationsllFloor(llFrand(llGetListLength(female_animations))));
                } else {
                    
chosen_anim llList2String(unknown_animationsllFloor(llFrand(llGetListLength(unknown_animations))));
                }
                
osAvatarPlayAnimation(userchosen_anim);  // Und starte die gewählte Animation.
                
state running// Wechseln in den Zustand "running", um das Abspielen der Animation zu verfolgen
            
} else {
                
used FALSE;
                
llSetAlpha(1.0,ALL_SIDES); // Mache den Poseball wieder sichtbar, wenn der Benutzer aufsteht
                
osAvatarStopAnimation(userchosen_anim); // Stoppe die Animation, wenn der Benutzer aufsteht.
                
user NULL_KEY// Wahrscheinlich überflüssig, aber wir möchten sicherstellen, dass der Wert für ''user'' leer ist.
            
}
        }
 
        if(
change CHANGED_INVENTORY)
        {
            
llResetScript(); // Setze das Skript zurück, wenn sich das Inventar geändert hat.
        
}
    }
}

state running
{
    
state_entry()
    {
        
// Hier kannst du weitere Aktionen durchführen, wenn das Animation abgespielt wird
    
}

    
on_rez(integer start_param)
    {
        
llResetScript();
    }

    
changed(integer change)
    {
        if(
change CHANGED_LINK)
        {
            
used FALSE;
            
llSetAlpha(1.0,ALL_SIDES); // Mache den Poseball wieder sichtbar, wenn der Benutzer aufsteht
            
osAvatarStopAnimation(userchosen_anim); // Stoppe die Animation, wenn der Benutzer aufsteht.
            
user NULL_KEY// Wahrscheinlich überflüssig, aber wir möchten sicherstellen, dass der Wert für ''user'' leer ist.
            
llSleep(0.1);
            
state default;
        }
    }
}

state error
{
    
state_entry()
    {
        
llOwnerSay("Dieser Poseball enthält keine Animationen. Bitte füge eine hinzu.");
    }
 
    
changed(integer change)
    {
        if(
change CHANGED_INVENTORY)
        {
            
llOwnerSay("Änderung erkannt. Initialisiere.");
            
llResetScript();
        }
    }


Ich habe die fehlende Rotation hinzugefügt.
Ein Metaversum sind viele kleine Räume, die nahtlos aneinander passen,
sowie direkt sichtbar und begehbar sind, als wäre es aus einem Guss.



[-] The following 2 users say Thank You to Manfred Aabye for this post:
  • Jupiter Rowland, Pius Noel
Zitieren
#2
Während das Sessel/Stuhl Skript (siehe oben) super läuft, habe ich mit Sofa/Couch/Bank Probleme.
Hier sollen dann 3 Personen mit einem Skript dazu gebracht werden, sich in einer Reihe hinzusetzen.
Das Setzen ab der 2.Person sieht aber willkürlich aus und die Rotation stimmt auch nicht.

Mein Sofa/Couch/Bank Test Skript:
PHP-Code:
vector target1 = <-1.0, -0.5, -1.0>; // Position for first avatar
vector target2 = <0.0, -0.5, -1.0>; // Position for second avatar
vector target3 = <1.0, -0.5, -1.0>; // Position for third avatar

rotation localrot ZERO_ROTATION// Rotationsposition des Avatars abschalten.
rotation localrot1 llEuler2Rot(<900, -90>*DEG_TO_RAD); // Rotation position of first avatar
rotation localrot2 llEuler2Rot(<900, -90>*DEG_TO_RAD); // Rotation position of second avatar
rotation localrot3 llEuler2Rot(<900, -90>*DEG_TO_RAD); // Rotation position of third avatar

list male_animations// List for male animations
list female_animations// List for female animations
list unknown_animations// List for animations of other genders

integer used// Flag used to determine script behavior
key user// Key of the user sitting on the poseball
string chosen_anim// Chosen animation

default
{
    
state_entry()
    {
        
llSitTarget(target1localrot1); // Set sit target for first avatar
        
llSitTarget(target2localrot2); // Set sit target for second avatar
        
llSitTarget(target3localrot3); // Set sit target for third avatar

        // Collect animations in inventory
        
integer num_anims llGetInventoryNumber(INVENTORY_ANIMATION);
        
integer i;
        for (
0num_anims; ++i) {
            
string anim_name llGetInventoryName(INVENTORY_ANIMATIONi);
            if (
llSubStringIndex(anim_name"male_") == 0) {
                
male_animations += anim_name;
            } else if (
llSubStringIndex(anim_name"female_") == 0) {
                
female_animations += anim_name;
            } else if (
llSubStringIndex(anim_name"unknown_") == 0) {
                
unknown_animations += anim_name;
            }
        }

        if (
male_animations == [] && female_animations == [] && unknown_animations == []) {
            
state error// Go to and wait until inventory changes
        
} else {
            
llOwnerSay("Found animations: Male: " + (string)llGetListLength(male_animations) + ", Female: " + (string)llGetListLength(female_animations) + ", Unknown: " + (string)llGetListLength(unknown_animations)); // Confirm animations in inventory
        
}
    }

    
// Event triggered when someone sits on the poseball
    
changed(integer change)
    {
        if (
change CHANGED_LINK)
        {
            if(!
used)
            {
                
used TRUE;
                
user llAvatarOnSitTarget();
                if(
user == NULL_KEYused FALSE// Ensure someone is sitting on the poseball
                
llSetAlpha(0.0,ALL_SIDES); // Hide the poseball when someone sits on it
                
osAvatarStopAnimation(user"sit"); // Stop default sit animation (IMPORTANT!)

                // Get gender of user
                
string gender osGetGender(user);

                
// Select and play a random animation
                
if (gender == "male") {
                    
chosen_anim llList2String(male_animationsllFloor(llFrand(llGetListLength(male_animations))));
                } else if (
gender == "female") {
                    
chosen_anim llList2String(female_animationsllFloor(llFrand(llGetListLength(female_animations))));
                } else {
                    
chosen_anim llList2String(unknown_animationsllFloor(llFrand(llGetListLength(unknown_animations))));
                }
                
osAvatarPlayAnimation(userchosen_anim);  // Play the chosen animation
                
state running// Switch to "running" state to monitor animation playback
            
} else {
                
used FALSE;
                
llSetAlpha(1.0,ALL_SIDES); // Make the poseball visible again when user stands up
                
osAvatarStopAnimation(userchosen_anim); // Stop animation when user stands up
                
user NULL_KEY// Ensure user value is empty
            
}
        }

        if(
change CHANGED_INVENTORY)
        {
            
llResetScript(); // Reset script if inventory changes
        
}
    }
}

state running
{
    
state_entry()
    {
        
// Additional actions can be performed when the animation is playing
    
}

    
on_rez(integer start_param)
    {
        
llResetScript();
    }

    
changed(integer change)
    {
        if(
change CHANGED_LINK)
        {
            
used FALSE;
            
llSetAlpha(1.0,ALL_SIDES); // Make the poseball visible again when user stands up
            
osAvatarStopAnimation(userchosen_anim); // Stop animation when user stands up
            
user NULL_KEY// Ensure user value is empty
            
llSleep(0.1);
            
state default;
        }
    }
}

state error
{
    
state_entry()
    {
        
llOwnerSay("This poseball does not contain any animations. Please add some.");
    }
 
    
changed(integer change)
    {
        if(
change CHANGED_INVENTORY)
        {
            
llOwnerSay("Change detected. Initializing.");
            
llResetScript();
        }
    }

Ein Metaversum sind viele kleine Räume, die nahtlos aneinander passen,
sowie direkt sichtbar und begehbar sind, als wäre es aus einem Guss.



[-] The following 3 users say Thank You to Manfred Aabye for this post:
  • Bogus Curry, Dorena Verne, Pius Noel
Zitieren


Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste