aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-02-23 03:02:00 +1000
committerDavid Walter Seikel2012-02-23 03:02:00 +1000
commit3ce55cc1d5e3269af2102935cba67265cc068336 (patch)
tree8ad1953ff6b166c023a21d4da676ad09c8d08497 /LuaSL
parentImplement llSleep(), and wait a bit longer for the test, now that it's sleepi... (diff)
downloadSledjHamr-3ce55cc1d5e3269af2102935cba67265cc068336.zip
SledjHamr-3ce55cc1d5e3269af2102935cba67265cc068336.tar.gz
SledjHamr-3ce55cc1d5e3269af2102935cba67265cc068336.tar.bz2
SledjHamr-3ce55cc1d5e3269af2102935cba67265cc068336.tar.xz
Implement llSetTimerEvent(), though it wont work so well until the events system is in place at the Lua end.
Diffstat (limited to 'LuaSL')
-rw-r--r--LuaSL/src/LuaSL.h3
-rw-r--r--LuaSL/src/LuaSL_main.c31
2 files changed, 29 insertions, 5 deletions
diff --git a/LuaSL/src/LuaSL.h b/LuaSL/src/LuaSL.h
index 6d495fa..ae0c26f 100644
--- a/LuaSL/src/LuaSL.h
+++ b/LuaSL/src/LuaSL.h
@@ -66,11 +66,12 @@ typedef struct
66 char SID[PATH_MAX]; 66 char SID[PATH_MAX];
67 char fileName[PATH_MAX]; 67 char fileName[PATH_MAX];
68 struct timeval startTime; 68 struct timeval startTime;
69 float compileTime; 69 float compileTime, timerTime;
70 int bugs, warnings; 70 int bugs, warnings;
71 boolean running; 71 boolean running;
72 gameGlobals *game; 72 gameGlobals *game;
73 Ecore_Con_Client *client; 73 Ecore_Con_Client *client;
74 Ecore_Timer *timer;
74} script; 75} script;
75 76
76typedef struct 77typedef struct
diff --git a/LuaSL/src/LuaSL_main.c b/LuaSL/src/LuaSL_main.c
index 04145b5..fcbfa03 100644
--- a/LuaSL/src/LuaSL_main.c
+++ b/LuaSL/src/LuaSL_main.c
@@ -8,19 +8,42 @@ static Eina_Strbuf *clientStream;
8 8
9static Eina_Bool _sleep_timer_cb(void *data) 9static Eina_Bool _sleep_timer_cb(void *data)
10{ 10{
11 char *SID = data; 11 script *script = data;
12 gameGlobals *game = script->game;
12 13
13printf("Waking up %s\n", SID); 14 PD("Waking up %s", script->SID);
14 sendToChannel(SID, "0.0", NULL, NULL); 15 sendToChannel(script->SID, "0.0", NULL, NULL);
15 return ECORE_CALLBACK_CANCEL; 16 return ECORE_CALLBACK_CANCEL;
16} 17}
17 18
19static Eina_Bool _timer_timer_cb(void *data)
20{
21 script *script = data;
22 gameGlobals *game = script->game;
23
24 PD("Timer for %s", script->SID);
25 sendToChannel(script->SID, "events.timer()", NULL, NULL);
26 return ECORE_CALLBACK_RENEW;
27}
28
18static void _sendBack(void * data) 29static void _sendBack(void * data)
19{ 30{
20 scriptMessage *message = data; 31 scriptMessage *message = data;
21 32
22 if (0 == strncmp(message->message, "llSleep(", 8)) 33 if (0 == strncmp(message->message, "llSleep(", 8))
23 ecore_timer_add(atof(&(message->message)[8]), _sleep_timer_cb, message->script->SID); 34 ecore_timer_add(atof(&(message->message)[8]), _sleep_timer_cb, message->script);
35 else if (0 == strncmp(message->message, "llSetTimerEvent(", 16))
36 {
37 message->script->timerTime = atof(&(message->message)[16]);
38 if (0.0 == message->script->timerTime)
39 {
40 if (message->script->timer)
41 ecore_timer_del(message->script->timer);
42 message->script->timer = NULL;
43 }
44 else
45 message->script->timer = ecore_timer_add(message->script->timerTime, _timer_timer_cb, message->script);
46 }
24 else 47 else
25 sendBack(message->script->game, message->script->client, message->script->SID, message->message); 48 sendBack(message->script->game, message->script->client, message->script->SID, message->message);
26 free(message); 49 free(message);