Change font size
It is currently Wed Aug 21, 2019 12:37 am

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 2 of 2   [ 11 posts ]
Go to page Previous  1, 2
Author Message
 Post subject: Re: vocabulary memory game
PostPosted: Sat May 18, 2019 3:40 pm 
Furious Typer

Joined: Mon Feb 13, 2017 1:53 pm
Posts: 65
Hi again!
At some point, with some help from other users, I managed to adjust the script the way I wanted it to be.
For other users possibly interested in this, I'm posting it below:
{L_CODE}:
// KFM Vocabulary Memory Game Reciever v0.2 by djphil (CC-BY-NC-SA 4.0) and Qie Niangao
//https://community.secondlife.com/forums/topic/434279-llsetkeyframedmotion-forward-and-back/

list KFMcommand;//changed original script here.

integer canal = -123654789;
integer tempo = 5;
integer echo;
integer count;
integer power;
string lang;
string word;
string trad;
string prim;
vector pos;
rotation rot;

rotation NormRot(rotation Q)
{
    float MagQ = llSqrt(Q.x*Q.x + Q.y*Q.y +Q.z*Q.z + Q.s*Q.s);
    return <Q.x/MagQ, Q.y/MagQ, Q.z/MagQ, Q.s/MagQ>;
}

default
{
    state_entry()
    {
        list buffer = llCSV2List(llGetObjectName());

        if (llGetListLength(buffer) == 2)
        {
            lang = llStringTrim(llList2String(buffer, 0), STRING_TRIM);
            prim = llStringTrim(llList2String(buffer, 1), STRING_TRIM);
        }

        else
        {
            llOwnerSay("Error: Bad prim name detected");
            return;
        }

        buffer = llCSV2List(llGetObjectDesc());

        if (llGetListLength(buffer) == 2)
        {
            word = llStringTrim(llList2String(buffer, 0), STRING_TRIM);
            trad = llStringTrim(llList2String(buffer, 1), STRING_TRIM);
        }
       
        else
        {
            llOwnerSay("Error: Bad prim desc detected");
            return;
        }

        llSetText("state: ready", <1.0, 1.0, 1.0>, 1.0);

        llSetLinkPrimitiveParamsFast(LINK_THIS, [
            PRIM_PHYSICS_SHAPE_TYPE,
            PRIM_PHYSICS_SHAPE_CONVEX
        ]);
    }

    touch_start(integer number)
    {
        llListenRemove(echo);
        count = 0;

        if (power =! power)
        {
            echo = llListen(canal, prim + "," + lang, NULL_KEY, "");
            llSetTimerEvent(0.1);
        }

        else
        {
            llSetTimerEvent(0.0);
        }

        llSetText("state: ready", <1.0, 1.0, 1.0>, 1.0);
    }
   
    listen(integer channel, string name, key id, string message)
    {
        list buffer = llCSV2List(name);

        if (llGetListLength(buffer) == 2)
        {
            name = llList2String(buffer, 0);

            if (name == prim)
            {
                buffer = llCSV2List(message);
               
                if (llGetListLength(buffer) == 3)
                {
                    message = llList2String(buffer, 0);
                    pos = (vector)llList2String(buffer, 1);//changed original script here.
                    rot = llList2Rot(buffer, 1);
   
                    if (message == trad)
                    {
                        llListenRemove(echo);
                        power =! power;
                        llShout(canal, message);
                        state move;
                    }
                }   
            }
        }
    }

    timer()
    {
        llSetTimerEvent(1.0);

        llShout(canal, word + "," + (string)llGetPos() + "," + (string)llGetRot());

        if (count > tempo)
        {
            llResetScript();
        }

        llSetText("time left: " + (tempo - count), <1.0, 1.0, 1.0>, 1.0);
        ++count;
    }
}

state move//changed original script here.
{
    state_entry()
    {
        llOwnerSay(llGetScriptName()+" in move state with pos = "+(string)pos);
        rotation spin = NormRot(llEuler2Rot(<90.0, 0.0, 0.0> * DEG_TO_RAD));
        KFMcommand = [
            <0.0, 0.0, 1.0> * llGetRot(), ZERO_ROTATION, 0.5,
            pos - llGetPos(), ZERO_ROTATION, 1.0,
            ZERO_VECTOR, spin, 0.5
            ];
        llSetKeyframedMotion(KFMcommand, [KFM_MODE, KFM_FORWARD]);
        llSleep(5);
    }
    touch_end(integer num_detected)
    {
        llShout(canal, word + "," + (string)llGetPos() + "," + (string)llGetRot());
        llSetKeyframedMotion(KFMcommand, [KFM_MODE, KFM_REVERSE]);
        llShout(canal, trad);
        //llSetText("lang: " + lang + "\nword: " + word + "\ntrad: " + trad, <1.0, 1.0, 1.0>, 1.0);
        llResetScript();
}
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 2 of 2   [ 11 posts ]
Go to page Previous  1, 2


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net