Change font size
It is currently Fri Jul 19, 2019 4:24 pm

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 2   [ 11 posts ]
Go to page 1, 2  Next
Author Message
 Post subject: vocabulary memory game
PostPosted: Tue Mar 27, 2018 10:42 am 
Furious Typer

Joined: Mon Feb 13, 2017 1:53 pm
Posts: 65
Hi!
I've made a vocabulary memory game (German - English).
You're supposed to find the English word for each German word.

The German and the English word are written on a cubic 1x1x1 meter sized prim in a texture.
It works as follows:

1. You click on the German word.
This activates the word.

On clicking, the German word "shouts" the particular German word for 10 seconds.


2. Now you have to click on the right English word.
The English word, when clicked on, "listens" and "senses" this German word
and then moves directly side by side next to the German word, hereby showing that it is the correct word.


Now my problem:

After the 2 words have combined, I want them to disassemble again after some time,
so the next player can play again.
But the two prims never disassemble on their own.
They remain next to each other.
This means that the next player cannot play any more, since he/ she already sees the correct solutions.

Here is how I would like it to work:

- Ideally, the English word should move back to its original position.
(If that's to difficult, it can also just move to a random different position (same z-value, though).)

- This should be triggered by clicking the English word again.


I tried to insert timer events, but it didn't work.

Here are the two scripts
(since I'm a newbie, they're probably not very clean.
I'm always open for improvement suggestions):

1. The German word:
-------------------------------------------------------------------------------------------
integer count;
integer ON;

default

{
touch_start(integer total_number)

{
llSetTimerEvent(1.0* (ON = !ON)); //Turns timer ON and OFF

}

timer()


{

llShout(1001,"German word");
++count;

if(count == 10)

{
llSetTimerEvent(0.0); // Timer shut off in 10 seconds
llResetScript();
}

}}


-----------------------------------------------------------------------------
2. The English word:
-----------------------------------------------------------------------------

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

default{

touch_start(integer total_number)

{
llListen(1001,"", NULL_KEY, "");


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

listen(integer channel, string name, key id, string message)
{
if (message == "German word")

gON = !gON; if (gON)

{

llSensorRepeat("","German word",SCRIPTED,10000.0,PI,0.1); //Following my scripted vehicle

}

else

{
llSensorRemove();
}

}

sensor(integer num)
{

llSetKeyframedMotion([(llDetectedPos(0) - llGetPos()) + <1.0,0.0,0.0>*
llDetectedRot(0), NormRot(llDetectedRot(0)/llGetRot()),0.1],[]);
llResetScript();

}
}

-----------------------------------------------------------------------------------
Thanks very much for your help in advance!


Top
 Profile  
 
 Post subject: Re: vocabulary memory game
PostPosted: Wed Mar 28, 2018 6:28 am 
Furious Typer
User avatar

Joined: Fri Mar 26, 2010 12:11 pm
Posts: 220
Location: Belgium / Brussels
marshall genord {L_WROTE}:
Here are the two scripts
(since I'm a newbie, they're probably not very clean.
I'm always open for improvement suggestions):

Here are two basic suggestions:
- Write your script properly, respect the indentation.
- Debug your script, it will help you understand what's happening.

PS: Use bbcode "code" when you post a script on the forum. :)

_________________
Webmaster @ digitalconcepts.free.fr & digigrids.free.fr


Top
 Profile  
 
 Post subject: Re: vocabulary memory game
PostPosted: Wed Mar 28, 2018 7:00 am 
Furious Typer
User avatar

Joined: Fri Mar 26, 2010 12:11 pm
Posts: 220
Location: Belgium / Brussels
There are several ways to make this vocabulary memory game ...

Exemple scripts:
KFM Vocabulary Memory Game Emitter v0.1
1) Create a prim
- Name: German
- Description: Vokabular,Vocabulary
2) Put the "Emitter" script inside
{L_CODE}:
// KFM Vocabulary Memory Game Emitter v0.1 by djphil (CC-BY-NC-SA 4.0)

integer canal = -123654789;
integer tempo = 5;
integer echo;
integer count;
integer power;
string lang;
string word;
string trad;

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

        if (llGetListLength(buffer) == 2)
        {
            word = llList2String(buffer, 0);
            trad = llList2String(buffer, 1);
        }
       
        else
        {
            word = "Error detected";
        }

        llSetText("lang: " + lang + "\nword: " + word + "\nstate: ready", <1.0, 1.0, 1.0>, 1.0);
    }
   
    touch_start(integer number)
    {
        llListenRemove(echo);
        count = 0;

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

        else
        {
            llSetTimerEvent(0.0);
        }

        llSetText("lang: " + lang + "\nword: " + word + "\nstate: ready", <1.0, 1.0, 1.0>, 1.0);
    }

    listen(integer channel, string name, key id, string message)
    {
        if (name == "English")
        {
            if (message == word)
            {
                llSetTimerEvent(0.0);
                state move;
            }
        }
    }

    timer()
    {
        llSetTimerEvent(1.0);
        llShout(canal, word + "," +(string)llGetPos() + "," + (string)llGetRot());

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

        llSetText("lang: " + lang + "\nword: " + word + "\ntimeleft: " + (tempo - count), <1.0, 1.0, 1.0>, 1.0);
        ++count;
    }
}

state move
{
    state_entry()
    {
        llListenRemove(echo);
        echo = llListen(canal, "English", NULL_KEY, "");
        llSetText("lang: " + lang + "\nword: " + word + "\ntrad: " + trad, <1.0, 1.0, 1.0>, 1.0);
    }

    listen(integer channel, string name, key id, string message)
    {
        if (name == "English")
        {
            if (message == word)
            {
                llResetScript();
            }
        }
    }
}

KFM Vocabulary Memory Game Reciever v0.1
1) Create a prim
- Name: English
- Description: Vocabulary,Vokabular
2) Put the "Reciever" script inside
{L_CODE}:
// KFM Vocabulary Memory Game Reciever v0.1 by djphil (CC-BY-NC-SA 4.0)

integer canal = -123654789;
integer tempo = 5;
integer echo;
integer count;
integer power;
string lang;
string word;
string trad;
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()
    {
        lang = llGetObjectName();
        list buffer = llCSV2List(llGetObjectDesc());
       
        if (llGetListLength(buffer) == 2)
        {
            word = llList2String(buffer, 0);
            trad = llList2String(buffer, 1);
        }

        else
        {
            word = "Error\nDetected";
        }

        llSetText("lang: " + lang + "\nword: " + word + "\nstate: 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, "German", NULL_KEY, "");
            llSetTimerEvent(0.1);
        }

        else
        {
            llSetTimerEvent(0.0);
        }

        llSetText("lang: " + lang + "\nword: " + word + "\nstate: ready", <1.0, 1.0, 1.0>, 1.0);
    }
   
    listen(integer channel, string name, key id, string message)
    {
        if (name == "German")
        {
            list buffer = llCSV2List(message);
           
            if (llGetListLength(buffer) == 3)
            {
                message = llList2String(buffer, 0);
                pos = llList2Vector(buffer, 1);
                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("lang: " + lang + "\nword: " + word + "\ntimeleft: " + (tempo - count), <1.0, 1.0, 1.0>, 1.0);
        ++count;
    }
}

state move
{
    state_entry()
    {
        rotation spin = NormRot(llEuler2Rot(<0.0, 0.0, 180.0> * DEG_TO_RAD));

        llSetTimerEvent(0.1);

        llSetKeyframedMotion([
            <0.0, 0.0, 1.0> * llGetRot(), ZERO_ROTATION, 0.5,
            pos - llGetPos() + ZERO_VECTOR * llGetRot(), ZERO_ROTATION, 1.0,
            ZERO_VECTOR, spin, 0.5,
            ZERO_VECTOR, ZERO_ROTATION, 1.0,
            llGetPos() - pos + ZERO_VECTOR * llGetRot(), ZERO_ROTATION, 1.0,
            -<0.0, 0.0, 1.0> * llGetRot(), ZERO_ROTATION, 0.5,
            ZERO_VECTOR, spin, 0.5
        ], [KFM_MODE, KFM_FORWARD]);       
    }

    timer()
    {
        llSetTimerEvent(1.0);

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

        if (count > 5)
        {
            llShout(canal, trad);
            llResetScript();
        }

        llSetText("lang: " + lang + "\nword: " + word + "\ntrad: " + trad, <1.0, 1.0, 1.0>, 1.0);
        ++count;
    }
}

Note: You can create like that, as many prim as you want.
For that, you just have to change the description of the prims.

Enjoy! :P

_________________
Webmaster @ digitalconcepts.free.fr & digigrids.free.fr


Top
 Profile  
 
 Post subject: Re: vocabulary memory game
PostPosted: Wed Mar 28, 2018 11:32 am 
Furious Typer

Joined: Mon Feb 13, 2017 1:53 pm
Posts: 65
Thank you, Sir! :)
It works wonderfully.

You just saved me from a lot of pain, since I just figured out that my old script does not work at all
when there are additional word-prims around.

This has great potential for lots of different assignments and quizzes.
I can see lots of opportunities. :)

Yes, I'll try my best to improve my formatting etc. next time.


Maybe just one question:
The description part you gave is not literally part of the script (Vocabulary,Vokabular and vice versa).
Can this description part be changed at all or does it always have to remain the same?


Top
 Profile  
 
 Post subject: Re: vocabulary memory game
PostPosted: Wed Mar 28, 2018 1:40 pm 
Furious Typer
User avatar

Joined: Fri Mar 26, 2010 12:11 pm
Posts: 220
Location: Belgium / Brussels
marshall genord {L_WROTE}:
Maybe just one question:
The description part you gave is not literally part of the script (Vocabulary,Vokabular and vice versa).
Can this description part be changed at all or does it always have to remain the same?

For the game to work you need at least a winning combination. Which means minimum two prims with name AND description as explained above. The name and the desciption of the prims is not optional. It is essential to the proper functioning of the script.

I use the description of the prim because it is easy to add many different words without having to change each time in the script. You just change the name and description and you do reset script and it's ready to use

For example if you want to play with the word "programming"
Prim 1 will be:
- Name: German
- Description: Programmierung,Programming
Prim 2 will be:
- Name: English
- Description: Programming,Programmierung

_________________
Webmaster @ digitalconcepts.free.fr & digigrids.free.fr


Last edited by dj phil on Sat Mar 31, 2018 7:18 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: vocabulary memory game
PostPosted: Wed Mar 28, 2018 1:58 pm 
Furious Typer
User avatar

Joined: Fri Mar 26, 2010 12:11 pm
Posts: 220
Location: Belgium / Brussels
marshall genord {L_WROTE}:
Here are the two scripts
(since I'm a newbie, they're probably not very clean.
I'm always open for improvement suggestions):

About using llSensorRepeat( string name, key id, integer type, float range, float arc, float rate );
If one day you need to use llSensorRepeat in a script, pay attention to this:
- range value is from 0.0 to 96.0 (use 1000.0 is bad).
- rate value should not be too small (0.1 is too small).
Always try to stay above or equal to 1.0 (and same for llSetTimerEvent(1.0)).
(ref: wiki sl)

_________________
Webmaster @ digitalconcepts.free.fr & digigrids.free.fr


Top
 Profile  
 
 Post subject: Re: vocabulary memory game
PostPosted: Mon Apr 02, 2018 12:43 pm 
Furious Typer
User avatar

Joined: Fri Mar 26, 2010 12:11 pm
Posts: 220
Location: Belgium / Brussels
With v0.2 you can more easily use any language.
If you want to use any another language, you simply change the name of the prim.
The script does the rest.

KFM Vocabulary Memory Game Emitter v0.2
1) Create a prim
- Name: German,English
- Description: Vokabular,Vocabulary
2) Put the "Emitter" script inside
{L_CODE}:
// KFM Vocabulary Memory Game Emitter v0.2 by djphil (CC-BY-NC-SA 4.0)

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

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("lang: " + lang + "\nword: " + word + "\nstate: ready", <1.0, 1.0, 1.0>, 1.0);
    }
   
    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("lang: " + lang + "\nword: " + word + "\nstate: 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)
            {
                if (message == word)
                {
                    llSetTimerEvent(0.0);
                    state move;
                }
            }
        }
    }

    timer()
    {
        llSetTimerEvent(1.0);
        llShout(canal, word + "," +(string)llGetPos() + "," + (string)llGetRot());

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

        llSetText("lang: " + lang + "\nword: " + word + "\ntimeleft: " + (tempo - count), <1.0, 1.0, 1.0>, 1.0);
        ++count;
    }
}

state move
{
    state_entry()
    {
        llListenRemove(echo);
        echo = llListen(canal, prim + "," + lang, NULL_KEY, "");
        llSetText("lang: " + lang + "\nword: " + word + "\ntrad: " + trad, <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)
            {
                if (message == word)
                {
                    llResetScript();
                }
            }
        }
    }
}

KFM Vocabulary Memory Game Reciever v0.2
1) Create a prim
- Name: English,German
- Description: Vocabulary,Vokabular
2) Put the "Reciever" script inside
{L_CODE}:
// KFM Vocabulary Memory Game Reciever v0.2 by djphil (CC-BY-NC-SA 4.0)

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("lang: " + lang + "\nword: " + word + "\nstate: 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("lang: " + lang + "\nword: " + word + "\nstate: 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 = llList2Vector(buffer, 1);
                    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("lang: " + lang + "\nword: " + word + "\ntimeleft: " + (tempo - count), <1.0, 1.0, 1.0>, 1.0);
        ++count;
    }
}

state move
{
    state_entry()
    {
        rotation spin = NormRot(llEuler2Rot(<0.0, 0.0, 180.0> * DEG_TO_RAD));

        llSetTimerEvent(0.1);

        llSetKeyframedMotion([
            <0.0, 0.0, 1.0> * llGetRot(), ZERO_ROTATION, 0.5,
            pos - llGetPos() + ZERO_VECTOR * llGetRot(), ZERO_ROTATION, 1.0,
            ZERO_VECTOR, spin, 0.5,
            ZERO_VECTOR, ZERO_ROTATION, 1.0,
            llGetPos() - pos + ZERO_VECTOR * llGetRot(), ZERO_ROTATION, 1.0,
            -<0.0, 0.0, 1.0> * llGetRot(), ZERO_ROTATION, 0.5,
            ZERO_VECTOR, spin, 0.5
        ], [KFM_MODE, KFM_FORWARD]);       
    }

    timer()
    {
        llSetTimerEvent(1.0);

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

        if (count > 5)
        {
            llShout(canal, trad);
            llResetScript();
        }

        llSetText("lang: " + lang + "\nword: " + word + "\ntrad: " + trad, <1.0, 1.0, 1.0>, 1.0);
        ++count;
    }
}

Enjoy! :P

_________________
Webmaster @ digitalconcepts.free.fr & digigrids.free.fr


Top
 Profile  
 
 Post subject: Re: vocabulary memory game
PostPosted: Mon Apr 02, 2018 3:51 pm 
Furious Typer

Joined: Mon Feb 13, 2017 1:53 pm
Posts: 65
Mate, you're awesome. 8-)
Thanks very much for your detailed reply.
I don't have time to go through the whole post right now, but I will as soon as I can.

That script beats a lot of learning games I've seen on Second Life / Opensim, even commercial ones.

Thanks again for your help!
Cheers!


Top
 Profile  
 
 Post subject: Re: vocabulary memory game
PostPosted: Sat Mar 16, 2019 8:41 am 
Furious Typer

Joined: Mon Feb 13, 2017 1:53 pm
Posts: 65
Hi again!
I'm using your vocabulary memory script for another language exercise (Syntax).
The students are supposed to form sentences out of individual words
and have to put them in the correct sentence position/ sequence.
The script seems to be suitable for this task, too.

There is just one thing I would like to adjust:

Once a word-prim has moved on top of its correct counterpart prim,
I would like the word-prim to remain on top of that counterpart prim for some time.

Thus, the student has time to slowly build a sentence
and also can look at the complete sentence for some time,
before the parts go back to their starting position.

The best way probably would be for the word-prim
to return to its starting position when clicked on a second time.

Below seems to be the respective section in the word-prim script:
{L_QUOTE}:
state move
{
state_entry()
{
rotation spin = NormRot(llEuler2Rot(<0.0, 0.0, 180.0> * DEG_TO_RAD));

llSetTimerEvent(0.1);

llSetKeyframedMotion([
<0.0, 0.0, 1.0> * llGetRot(), ZERO_ROTATION, 0.5,
pos - llGetPos() + ZERO_VECTOR * llGetRot(), ZERO_ROTATION, 1.0,
ZERO_VECTOR, spin, 0.5,
ZERO_VECTOR, ZERO_ROTATION, 1.0,
llGetPos() - pos + ZERO_VECTOR * llGetRot(), ZERO_ROTATION, 1.0,
-<0.0, 0.0, 1.0> * llGetRot(), ZERO_ROTATION, 0.5,
ZERO_VECTOR, spin, 0.5
], [KFM_MODE, KFM_FORWARD]);
}

I tried to split that part into two parts, but that failed.
Do you maybe know how to do this?
Thank you very much in advance.


Top
 Profile  
 
 Post subject: Re: vocabulary memory game
PostPosted: Sat Mar 16, 2019 9:25 am 
Furious Typer
User avatar

Joined: Fri Mar 26, 2010 12:11 pm
Posts: 220
Location: Belgium / Brussels
The movement can be broken down into 2 parts (go/return).
The first part does not change, the second part goes into the timer.
You can then play with the variable "count" to trigger the return of the object when you want.

_________________
Webmaster @ digitalconcepts.free.fr & digigrids.free.fr


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


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:  


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