These forums are CLOSED. Please visit the new forums HERE
Touch event limiter? |
|
Doc Nerd
Registered User
Join date: 7 Oct 2005
Posts: 20
|
11-15-2005 18:19
Is there a way I could set a touch event in a script to be available x seconds after it's last touch event? Say like the default script saying "Touched"; is there a way that the object will only say "Touched" after say 10 seconds has passed? I'm working on something that will have a touch even that will cause it to say something, and then do a simple action, but I don't want it to spam the area with the message I've set it to say. (I've heard the term "deviling" used to describe this.)
|
Alexis Ingersoll
Registered User
Join date: 26 Jan 2005
Posts: 14
|
11-15-2005 18:30
Sure, you could create a kind of a proxy handler. When it receives a touch event, it would setup a timer for 10 seconds, and any extra touch events would get dropped on the floor. When the timer handler fires, it says the "touched" message and then resets everything.
|
Alexis Ingersoll
Registered User
Join date: 26 Jan 2005
Posts: 14
|
11-15-2005 19:17
Because my last message wasn't really helpful, I'll post two scripts which may be helpful to what you are trying to do. I'm not exactly sure which semantics you were exactly looking for, so I'll post two flavors.
The first script makes the touch handler available only every 10 seconds. You can use it immediately when the script starts, but once you press it once, it ignores everything for 10 seconds. Once the 10 seconds are up, it will respond again (just once) and then do the 10 second thing all over again. You can replace the llSay(0, 'Touched." ![]() integer available = TRUE; integer TIMER_LENGTH = 10; // in seconds default { state_entry() { llSay(0, "Hello, Avatar!" ![]() } touch_start(integer total_number) { if (available) { available = FALSE; llSay(0, "Touched." ![]() llSetTimerEvent(TIMER_LENGTH); } } timer() { llSetTimerEvent(0); // clear timer available = TRUE; } } To not make the post too lengthy, I'll post the second script in the next message. |
Alexis Ingersoll
Registered User
Join date: 26 Jan 2005
Posts: 14
|
11-15-2005 19:20
Here's the second script. This one *delays* response to a touch event by 10 seconds. That's probably not what you were looking for, but it wasn't clear to me. If a touch event is received, it will count down for 10 seconds and then fire the llSay(0, "Touched."
![]() integer timerSet = FALSE; integer TIMER_LENGTH = 10; // in seconds default { state_entry() { llSay(0, "Hello, Avatar!" ![]() } touch_start(integer total_number) { if (!timerSet) { llSetTimerEvent(TIMER_LENGTH); timerSet = TRUE; } } timer() { llSetTimerEvent(0); timerSet = FALSE; llSay(0, "Touched." ![]() } } Hope these help a little. If not, please feel free to IM me in world and we can try things together! Good luck. |
Aurael Neurocam
Will script for food
Join date: 25 Oct 2005
Posts: 267
|
11-15-2005 19:26
CODE
This has the advantage of not using a timer loop and being generally simpler. |
Alexis Ingersoll
Registered User
Join date: 26 Jan 2005
Posts: 14
|
11-15-2005 19:30
That is true! That is a much nicer script.
|
Gaz Hornpipe
Registered User
Join date: 29 Sep 2005
Posts: 36
|
11-16-2005 00:35
Alternatively.. (using a timer though
![]() CODE default The real difference here is that because you are changing to a state that does not contain a touch event handler, all touches will be completely ignored.. in fact you will not even get the mouse cursor change that shows when an object can be touched. |
Alexis Ingersoll
Registered User
Join date: 26 Jan 2005
Posts: 14
|
11-16-2005 00:52
That's interesting about the mouse cursor change (or lack thereof). I'll definitely remember that one. Thanks for posting!
|
Doc Nerd
Registered User
Join date: 7 Oct 2005
Posts: 20
|
11-16-2005 06:03
Gaz is teh winnar!
|
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
|
11-16-2005 10:41
Try llMinEventDelay()... depending on what you want to do, it might work for you.
|