|
Virtuater Voom
Registered User
Join date: 11 Apr 2007
Posts: 8
|
05-30-2007 01:45
Hello,
I have several object which i can slide from one position to another, but i don't want to move them by accidentally clicking on them. Is there a way i can script an event where i need to click an object for at least, lets say, one second to activate the movement of this object? Thanks in advance.
This is the movement script I use:
vector OpenPos = <224.8954, 26.555, 48.680>;
vector ClosedPos = <217.174, 26.555, 48.680>;
default { state_entry() { state closed; } }
state closed { touch_start(integer N) { state open; }
state_entry() { llSetPos(ClosedPos); } }
state open { touch_start(integer N) { state closed; }
state_entry() { llSetPos(OpenPos); } }
|
|
Zephyrin Zabelin
Registered User
Join date: 10 May 2007
Posts: 153
|
05-30-2007 01:49
I am pretty much a scripting beginner so what I am about to say may not be helpful at all, but could you use another option in the right-click menu rather than a simple touch? After all if you were thinking of making it use a delay, doing the right-click shouldn't actually be a time inconvenience.
|
|
Lucius Nesterov
Registered User
Join date: 12 Oct 2006
Posts: 33
|
05-30-2007 03:11
It seems the best option would be to use both touch_start() and touch_end(). So on touch_start you note the time, and on touch_end you check how much time has elapsed. E.g. state whatever { touch_start(integer num_detected) { timeStore = llGetGMTclock(); }
touch_end(integer num_detected) { float timeDiff;
timeDiff = llGetGMTclock() - timeStore; if (timeDiff>2) state nextState; } }
timeStore would be a global float, and it won't work at midnight UTC  . Be sure to check the code.
|
|
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
|
05-30-2007 08:56
The touch_end event is notorious about not firing a goodly percentage of the time. My advice would be to use the touch() event to record the first touch, then keep checking to see when the touch exceeds a set time limit. You would occasionally have to clear the variable you are checking so that it knows when to record the next "first touch" event.
|