Jump to content

Event triggered If two or more people touch an object, or do something simultaneously


AlinaNazmeeva
 Share

You are about to reply to a thread that has been inactive for 1837 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi everyone,

I am very new in SL and just started learning LSL scripting, and have almost zero programming experience. 

I wonder if it is possible to script certain events triggered by multiple other events, happening in a certain time range.

I have been thinking of designing a game-like collaborative experience, where people could build/design something together by rearranging and moving around prefabricated pieces, like lego. I want to trigger certain events(door opening, other objects appear) if multiple people do something, for example they touch some object at the same time (or within 10 seconds). Or if they place some objects in certain locations on the land, it triggers other things.

Do you think it is realistic to make something like that? I know I have very limited skills, but maybe someone can give me any tips how to start scripting in that direction?

I think I do have a relatively clear understanding of what are the potential events and what can trigger them, and the variables included within these events/triggers. But no clue how to script it:) 

I hope this question makes sense! 

Link to comment
Share on other sites

here is what I would try

  1. create a global dummy integer variable set it to 0
  2. at touch start set it to 1 , at touch end set it to 0 again
  3. create if clause
  4. in case dummy integer already is 1 at touch start ... execute colaborative event thing

No guarantee 2 persons can touch at once though, but would be my first try on this...

if it does not work make timer event reset 1 to 0 after 10 seconds...

 

Edited by Fionalein
  • Thanks 1
Link to comment
Share on other sites

Yes, what you describe is quite possible within LSL. And as you will see, there are many ways to approach solving problems. :)

Speaking to your example about multiple people clicking a single object together, let's take a look at the touch event.

This event will continually trigger as long as the object containing the script is being clicked on - as in, the user hovers their mouse over the object and holds down the left mouse button. The event handler comes bundled with an integer variable, usually depicted as "num_detected". This represents the number of users who are currently clicking on the object at this exact point in time. Other functions exist to use these as indexes to reference the avatars touching it, but you can simply test if the number is equal to or greater than the desired value in order to trigger another effect.

For example:

default
{
    touch(integer num_detected)
    {
        if (num_detected >= 2)
        {
            llSay(0,"Two or more people are currently clicking on me!");
        }
    }
}

 

The wiki as a lot of good beginner tutorials you can peruse to get familiar with scripting in LSL. It's often best to start out with small projects before jumping into something large and complex.

http://wiki.secondlife.com/wiki/Category:LSL_Tutorials

Edited by Fenix Eldritch
typos
  • Like 1
  • Thanks 3
Link to comment
Share on other sites

56 minutes ago, AlinaNazmeeva said:

 

You are talking about a system that is way beyond your capabilities. Also the two examples supplied for this type of system are too crude. The touchers ID KEY should be used to lock out all other agents from script usage while the timer is active. First thing you need to do is write flow chart of what has to do what before you can even start scripting the elements. Without that flow chart you would be just guessing as you go along which will keep throwing you back to scripts you have already written and have to modify.  The system you describe is no easy feat using LSL.

Edited by steph Arnott
Link to comment
Share on other sites

1 hour ago, AlinaNazmeeva said:

Do you think it is realistic to make something like that? I know I have very limited skills, but maybe someone can give me any tips how to start scripting in that direction?

Quite reasonable, and it's a low risk project.  As Fenix says, there are many possible ways to do it, mostly within the reach of a new scripter. As Steph indicates, you will almost certainly want to add all sorts of bells and whistles to anticipate possible ways that the user can screw up (or simply misinterpret what you intended).  Planning for all of the possible "Ooops!" moments can take much more time and effort in the end than writing the basic script, but you've picked a fairly easy problem to practice on.  Try what Fenix and Fionalein have suggested, experiment with them to see where they might have drawbacks or loopholes, and then start "fixing" them.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1837 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...