|
Samantha Fuller
Registered User
Join date: 8 Sep 2006
Posts: 15
|
09-19-2006 19:40
Im very new to scripting and have never done programing in any other language. I need to know how to cycle through a list of actions with sequencial touches. I woud also like to to to be able to trap two or thre touch_starts in a shot period of time i havent found any script in the libary or examples that do this anywhere.
|
|
Aakanaar LaSalle
Registered User
Join date: 1 Sep 2006
Posts: 132
|
09-19-2006 22:50
Most scripts usually only worked with llDetected*(0) which is the first person in a touch_start or touch_end situation.. Usually the chances of two or more people trigguring a touch_start at the same time is very rare.. and if it happens osmeone just has to click again.. In your case however, if you think you need to handle multiple touch_starts at the same time, just use a while loop The number passed in the touch_start(integer Total) is the number of detected avatars who touched it. You can cycle through them in a while loop using llDetected*(n) e.g. touch_start(integer intTotal) { integer i = 0;
while (i <= intTotal) { string strName = llDetectedName(i); key keyID = llDetectedKey(i); // do something with all this good info we got ++i // Increase I for the next round } }
That would handle multiple touches
|
|
Howie Lament
Registered User
Join date: 22 Apr 2004
Posts: 30
|
09-20-2006 00:06
what Aakanaar is describing is not what i think the OP wants to know, but it's useful knowledge anyway. The reason why there is a "total number of touches" argument in the touch_start handler is because it ensures that clicks won't be lost if the script is too busy to handle them one by one. Anyway, it sounds like the OP wants to do something like this default { touch_start(integer num_detected) { state one; } } state one { state_entry() { llSetTimerEvent(10); } timer() { state default; } touch_start(integer num_detected) { state two; } } state two { state_entry() { llSetTimerEvent(10); } timer() { state one; } touch_start(integer num_detected) { state three; } } etc. etc.
This way, for each new click the object state changes to the next one, and after 10 seconds it goes back to the previous one. You can add more tasks to the state_entry of each state. You can also do this by increasing a variable, but states might be more easy to understand for beginners.
|
|
Aakanaar LaSalle
Registered User
Join date: 1 Sep 2006
Posts: 132
|
09-20-2006 01:06
oops.. i'm sorry, i must have mis-read the question.. I appologise.
Yea, what Howie says sounds about right.
|
|
Samantha Fuller
Registered User
Join date: 8 Sep 2006
Posts: 15
|
what is need is to trap double clicks
09-21-2006 21:57
In my origanal post i was asking two differnt questions Howe nearly got the first. And Askanaar may have been taking a stab at the second harder question. Also i got some help inworld, thanks but i still havent got a anser to my problem. The folowing code makes it clear what im trying to do. problem is it dosen't work it dosent downshift. // Gearshift script float double_click = .75; // Double click speed for downshifting // ************************************************************* float elapsed; integer num_of_clicks; string GearN; string Gear1; string Gear2; string Gear3; string Gear4; string Gear5;
default { state_entry() { num_of_clicks = 0; llWhisper(0, "In Netrual"); llWhisper(0, "Click to upshift, double click to downshift"); } touch_start(integer num_detected) { llMessageLinked(LINK_SET, 0, "Gear1", NULL_KEY); llWhisper(0, "1st gear"); state first_gear; } } state first_gear { state_entry() { elapsed = llGetAndResetTime(); } touch_start(integer num_detected) { ++num_of_clicks; if(num_of_clicks = 1 && elapsed >= double_click); { llMessageLinked(LINK_SET, 0, "Gear2", NULL_KEY); llWhisper(0, "2nd gear"); state second_gear; } if(num_of_clicks > 1 && elapsed >= double_click); { llMessageLinked(LINK_SET, 0, "GearN", NULL_KEY); llWhisper(0, "Netural"); state default; } } } state second_gear { state_entry() { elapsed = llGetAndResetTime(); } touch_start(integer num_detected) { ++num_of_clicks; if(num_of_clicks = 1 && elapsed >= double_click); { llMessageLinked(LINK_SET, 0, "Gear3", NULL_KEY); llWhisper(0, "3rd gear"); state third_gear; } if(num_of_clicks > 1 && elapsed >= double_click); { llMessageLinked(LINK_SET, 0, "GearN", NULL_KEY); llWhisper(0, "Second gear"); state first_gear; } } } state third_gear { state_entry() { // this state trunciated for illistration & testing state default; } }
|
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
09-21-2006 23:42
primitive example of how it can work in 1 state key user = NULL_KEY; // who is clicking and dbl clicking
integer place; // where are we
integer count = 10; // how many things are in que
default { touch_start(integer total_number) { if (user == NULL_KEY) { // llOwnerSay("first click no action"); //DEBUG user = llDetectedKey(0); llSetTimerEvent(0.5); } else { // llOwnerSay("second click do stuff"); //DEBUG if (place < count) { ++place; llOwnerSay((string) place ); } else { place = 1; llOwnerSay((string)place); user = NULL_KEY; } } } timer() { user = NULL_KEY; llSetTimerEvent(0); } }
|