aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-02-22 05:43:11 +1000
committerDavid Walter Seikel2012-02-22 05:43:11 +1000
commit8dffe12c4e80e3d58e7825530632880214ed04cd (patch)
treef34a7a1f44185af600c05eaf79a400c14d5f2411 /LuaSL/src
parentFix up the EOF fix up, and commentry++. (diff)
downloadSledjHamr-8dffe12c4e80e3d58e7825530632880214ed04cd.zip
SledjHamr-8dffe12c4e80e3d58e7825530632880214ed04cd.tar.gz
SledjHamr-8dffe12c4e80e3d58e7825530632880214ed04cd.tar.bz2
SledjHamr-8dffe12c4e80e3d58e7825530632880214ed04cd.tar.xz
Implement llGetScriptName().
Diffstat (limited to 'LuaSL/src')
-rw-r--r--LuaSL/src/LSL.lua11
-rw-r--r--LuaSL/src/LuaSL_compile.c7
2 files changed, 16 insertions, 2 deletions
diff --git a/LuaSL/src/LSL.lua b/LuaSL/src/LSL.lua
index a89c06f..8861bf3 100644
--- a/LuaSL/src/LSL.lua
+++ b/LuaSL/src/LSL.lua
@@ -25,6 +25,7 @@ upvalue--either way is a bit more efficient and less error prone.
25 25
26local LSL = {}; 26local LSL = {};
27local SID = ""; 27local SID = "";
28local scriptName = "";
28 29
29-- Debugging aids 30-- Debugging aids
30 31
@@ -567,6 +568,13 @@ function --[[list]] LSL.llParseString2List(--[[string]] In, --[[list]] l, --[[li
567function --[[list]] LSL.llParseStringKeepNulls(--[[string]] In, --[[list]] l, --[[list]] l1) return {} end; 568function --[[list]] LSL.llParseStringKeepNulls(--[[string]] In, --[[list]] l, --[[list]] l1) return {} end;
568 569
569 570
571-- LSL script functions
572
573function --[[string]] LSL.llGetScriptName()
574 return scriptName
575end
576
577
570-- Crements stuff. 578-- Crements stuff.
571 579
572function LSL.preDecrement(name) _G[name] = _G[name] - 1; return _G[name]; end; 580function LSL.preDecrement(name) _G[name] = _G[name] - 1; return _G[name]; end;
@@ -612,11 +620,12 @@ function LSL.stateChange(x)
612 end 620 end
613end; 621end;
614 622
615function LSL.mainLoop(sid, x) 623function LSL.mainLoop(sid, name, x)
616 local status, errorMsg = luaproc.newchannel(sid) 624 local status, errorMsg = luaproc.newchannel(sid)
617 local result 625 local result
618 626
619 SID = sid 627 SID = sid
628 scriptName = name
620 629
621 LSL.EOF = "\n\n\n" -- Fix this up now. 630 LSL.EOF = "\n\n\n" -- Fix this up now.
622 631
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c
index 873e6c4..de103b7 100644
--- a/LuaSL/src/LuaSL_compile.c
+++ b/LuaSL/src/LuaSL_compile.c
@@ -2275,13 +2275,18 @@ boolean compileLSL(gameGlobals *game, Ecore_Con_Client *client, char *SID, char
2275 { 2275 {
2276 lua_State *L; 2276 lua_State *L;
2277 int err; 2277 int err;
2278 char *ext;
2278 2279
2279 fprintf(out, "--// Generated code goes here.\n\n"); 2280 fprintf(out, "--// Generated code goes here.\n\n");
2280 fprintf(out, "local _bit = require(\"bit\")\n"); 2281 fprintf(out, "local _bit = require(\"bit\")\n");
2281 fprintf(out, "local _LSL = require(\"LSL\")\n\n"); 2282 fprintf(out, "local _LSL = require(\"LSL\")\n\n");
2282 fprintf(out, "local _SID = [=[%s]=]\n\n", compiler.SID); 2283 fprintf(out, "local _SID = [=[%s]=]\n\n", compiler.SID);
2284 strcpy(buffer, basename(compiler.fileName));
2285 if ((ext = rindex(buffer, '.')))
2286 ext[0] = '\0';
2287 fprintf(out, "local _scriptName = [=[%s]=]\n\n", buffer);
2283 outputLeaf(out, OM_LUA, compiler.ast); 2288 outputLeaf(out, OM_LUA, compiler.ast);
2284 fprintf(out, "\n\n_LSL.mainLoop(_SID, _defaultState)\n"); // This actually starts the script running. 2289 fprintf(out, "\n\n_LSL.mainLoop(_SID, _scriptName, _defaultState)\n"); // This actually starts the script running.
2285 fprintf(out, "\n--// End of generated code.\n\n"); 2290 fprintf(out, "\n--// End of generated code.\n\n");
2286 fclose(out); 2291 fclose(out);
2287 2292