diff options
author | David Walter Seikel | 2014-05-16 10:35:20 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-05-16 10:35:20 +1000 |
commit | 75195c769c629098a72143d8684bc73c7e864a86 (patch) | |
tree | 4ae5e7f51e7f3143a2d5f574bfa4e2673a1d934b | |
parent | Move timeDiff() to LumbrJack, it has more than one user now. (diff) | |
download | SledjHamr-75195c769c629098a72143d8684bc73c7e864a86.zip SledjHamr-75195c769c629098a72143d8684bc73c7e864a86.tar.gz SledjHamr-75195c769c629098a72143d8684bc73c7e864a86.tar.bz2 SledjHamr-75195c769c629098a72143d8684bc73c7e864a86.tar.xz |
Implement llGetTime() and friends.
-rw-r--r-- | src/LuaSL/LuaSL_main.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/LuaSL/LuaSL_main.c b/src/LuaSL/LuaSL_main.c index 4d589a1..c2a4855 100644 --- a/src/LuaSL/LuaSL_main.c +++ b/src/LuaSL/LuaSL_main.c | |||
@@ -82,6 +82,30 @@ void scriptSendBack(void * data) | |||
82 | 82 | ||
83 | if (0 == strncmp(message->message, "llSleep(", 8)) | 83 | if (0 == strncmp(message->message, "llSleep(", 8)) |
84 | ecore_timer_add(atof(&(message->message)[8]), _sleep_timer_cb, message->script); | 84 | ecore_timer_add(atof(&(message->message)[8]), _sleep_timer_cb, message->script); |
85 | else if (0 == strncmp(message->message, "llResetTime(", 12)) | ||
86 | { | ||
87 | gettimeofday(&message->script->startTime, NULL); | ||
88 | } | ||
89 | else if (0 == strncmp(message->message, "llGetTime(", 10)) | ||
90 | { | ||
91 | struct timeval now; | ||
92 | float time = timeDiff(&now, &message->script->startTime); | ||
93 | char result[128]; | ||
94 | |||
95 | snprintf(result, sizeof(result), "return %f", time); | ||
96 | sendToChannel(ourGlobals, message->script->SID, result); | ||
97 | } | ||
98 | else if (0 == strncmp(message->message, "llGetAndResetTime(", 18)) | ||
99 | { | ||
100 | struct timeval now; | ||
101 | float time = timeDiff(&now, &message->script->startTime); | ||
102 | char result[128]; | ||
103 | |||
104 | // Reset it before doing anything else once the result is known. | ||
105 | gettimeofday(&message->script->startTime, NULL); | ||
106 | snprintf(result, sizeof(result), "return %f", time); | ||
107 | sendToChannel(ourGlobals, message->script->SID, result); | ||
108 | } | ||
85 | else if (0 == strncmp(message->message, "llSetTimerEvent(", 16)) | 109 | else if (0 == strncmp(message->message, "llSetTimerEvent(", 16)) |
86 | { | 110 | { |
87 | message->script->timerTime = atof(&(message->message)[16]); | 111 | message->script->timerTime = atof(&(message->message)[16]); |
@@ -208,6 +232,7 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_D | |||
208 | if (me) | 232 | if (me) |
209 | { | 233 | { |
210 | sprintf(buf, "%s.lua.out", me->fileName); | 234 | sprintf(buf, "%s.lua.out", me->fileName); |
235 | gettimeofday(&me->startTime, NULL); | ||
211 | newProc(buf, TRUE, me); | 236 | newProc(buf, TRUE, me); |
212 | } | 237 | } |
213 | } | 238 | } |