From 693440574b11316222f107743a90cdbf2936eb18 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Fri, 24 Feb 2012 04:40:00 +1000 Subject: Implement llSetScriptState(). --- LuaSL/src/LuaSL.h | 2 +- LuaSL/src/LuaSL_main.c | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/LuaSL/src/LuaSL.h b/LuaSL/src/LuaSL.h index ae0c26f..f03b885 100644 --- a/LuaSL/src/LuaSL.h +++ b/LuaSL/src/LuaSL.h @@ -54,7 +54,7 @@ typedef struct Evas_Object *bg; // Our background edje, also the game specific stuff. Evas_Object *edje; // The edje of the background. Ecore_Con_Server *server; - Eina_Hash *scripts; + Eina_Hash *scripts, *names; int logDom; const char *address; int port; diff --git a/LuaSL/src/LuaSL_main.c b/LuaSL/src/LuaSL_main.c index 5a56a88..388b151 100644 --- a/LuaSL/src/LuaSL_main.c +++ b/LuaSL/src/LuaSL_main.c @@ -29,6 +29,7 @@ static Eina_Bool _timer_timer_cb(void *data) static void _sendBack(void * data) { scriptMessage *message = data; + gameGlobals *game = message->script->game; if (0 == strncmp(message->message, "llSleep(", 8)) ecore_timer_add(atof(&(message->message)[8]), _sleep_timer_cb, message->script); @@ -44,8 +45,41 @@ static void _sendBack(void * data) else message->script->timer = ecore_timer_add(message->script->timerTime, _timer_timer_cb, message->script); } + else if (0 == strncmp(message->message, "llSetScriptState(", 17)) + { + char name[PATH_MAX]; + char *temp; + script *them; + boolean state = TRUE; + + strncpy(name, message->script->fileName, PATH_MAX); + if ((temp = rindex(name, '/'))) + temp[1] = '\0'; + strcat(name, &(message->message[18])); + if ((temp = rindex(name, '""'))) + { + temp[0] = '\0'; + while (isspace(*temp)) + temp++; + if (',' == *temp) + temp++; + while (isspace(*temp)) + temp++; + state = '1' == *temp; + } + strcat(name, ".lsl"); + if ((them = eina_hash_find(game->names, name))) + { + if (state) + sendToChannel(them->SID, "start()", NULL, NULL); + else + sendToChannel(them->SID, "stop()", NULL, NULL); + } + else + PE("Can't stop script %s", name); + } else - sendBack(message->script->game, message->script->client, message->script->SID, message->message); + sendBack(game, message->script->client, message->script->SID, message->message); free(message); } @@ -100,6 +134,7 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_D me->game = game; me->client = ev->client; eina_hash_add(game->scripts, me->SID, me); + eina_hash_add(game->names, me->fileName, me); sendBack(game, ev->client, SID, "compiled(true)"); } else @@ -165,6 +200,7 @@ int main(int argc, char **argv) { loggingStartup(&game); game.scripts = eina_hash_string_superfast_new(NULL); + game.names = eina_hash_string_superfast_new(NULL); if (ecore_con_init()) { if ((game.server = ecore_con_server_add(ECORE_CON_REMOTE_TCP, game.address, game.port, &game))) -- cgit v1.1