aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-02-04 10:32:18 +1000
committerDavid Walter Seikel2012-02-04 10:32:18 +1000
commitbf8c2c0c8de5f741f69e46209a191990391b608f (patch)
tree8d79f8e5441c4b71ce6c56b6ecf178d66b52cceb /LuaSL
parentImplement basic states. (diff)
downloadSledjHamr-bf8c2c0c8de5f741f69e46209a191990391b608f.zip
SledjHamr-bf8c2c0c8de5f741f69e46209a191990391b608f.tar.gz
SledjHamr-bf8c2c0c8de5f741f69e46209a191990391b608f.tar.bz2
SledjHamr-bf8c2c0c8de5f741f69e46209a191990391b608f.tar.xz
Make states actually work.
Diffstat (limited to 'LuaSL')
-rw-r--r--LuaSL/src/LuaSL_compile.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c
index 66f5174..fe401c8 100644
--- a/LuaSL/src/LuaSL_compile.c
+++ b/LuaSL/src/LuaSL_compile.c
@@ -1845,7 +1845,7 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state
1845 fprintf(file, "stateChange("); 1845 fprintf(file, "stateChange(");
1846 if (statement->identifier.text) 1846 if (statement->identifier.text)
1847 outputText(file, &(statement->identifier), TRUE); 1847 outputText(file, &(statement->identifier), TRUE);
1848 fprintf(file, ")"); 1848 fprintf(file, "State)");
1849 } 1849 }
1850 break; 1850 break;
1851 } 1851 }
@@ -2094,7 +2094,7 @@ static void outputFunctionToken(FILE *file, outputMode mode, LSL_Leaf *content)
2094 else if (OM_LUA == mode) 2094 else if (OM_LUA == mode)
2095 { 2095 {
2096 if (func->state) 2096 if (func->state)
2097 fprintf(file, "\n\n%s.%s = function(", func->state, func->name.text); 2097 fprintf(file, "\n\n%sState.%s = function(", func->state, func->name.text);
2098 else 2098 else
2099 { 2099 {
2100 fprintf(file, "\n\nfunction "); 2100 fprintf(file, "\n\nfunction ");
@@ -2269,7 +2269,7 @@ static void outputStateToken(FILE *file, outputMode mode, LSL_Leaf *content)
2269 { 2269 {
2270 fprintf(file, "\n\n--[[state]] "); 2270 fprintf(file, "\n\n--[[state]] ");
2271 outputText(file, &(state->name), !(LSL_NOIGNORE & content->toKen->flags)); 2271 outputText(file, &(state->name), !(LSL_NOIGNORE & content->toKen->flags));
2272 fprintf(file, " = {};"); 2272 fprintf(file, "State = {};");
2273 outputRawBlock(file, mode, state->block, FALSE); 2273 outputRawBlock(file, mode, state->block, FALSE);
2274 } 2274 }
2275 } 2275 }
@@ -2336,15 +2336,15 @@ static boolean doneParsing(LuaSL_compiler *compiler)
2336 { 2336 {
2337 fprintf(out, "--// Pre declared helper stuff.\n"); 2337 fprintf(out, "--// Pre declared helper stuff.\n");
2338 fprintf(out, "local bit = require(\"bit\")\n"); 2338 fprintf(out, "local bit = require(\"bit\")\n");
2339 fprintf(out, "currentState = { state_exit = function() end }\n"); 2339 fprintf(out, "currentState = {}\n");
2340 fprintf(out, "function preDecrement(name) _G[name] = _G[name] - 1; return _G[name]; end;\n"); 2340 fprintf(out, "function preDecrement(name) _G[name] = _G[name] - 1; return _G[name]; end;\n");
2341 fprintf(out, "function preIncrement(name) _G[name] = _G[name] + 1; return _G[name]; end;\n"); 2341 fprintf(out, "function preIncrement(name) _G[name] = _G[name] + 1; return _G[name]; end;\n");
2342 fprintf(out, "function postDecrement(name) local temp = _G[name]; _G[name] = _G[name] - 1; return temp; end;\n"); 2342 fprintf(out, "function postDecrement(name) local temp = _G[name]; _G[name] = _G[name] - 1; return temp; end;\n");
2343 fprintf(out, "function postIncrement(name) local temp = _G[name]; _G[name] = _G[name] + 1; return temp; end;\n"); 2343 fprintf(out, "function postIncrement(name) local temp = _G[name]; _G[name] = _G[name] + 1; return temp; end;\n");
2344 fprintf(out, "function stateChange(x) currentState.state_exit(); curruntState = x; currentState.state_entry(); end;\n"); 2344 fprintf(out, "function stateChange(x) if nil ~= currentState.state_exit then currentState.state_exit(); end currentState = x; if nil ~= currentState.state_entry then currentState.state_entry(); end end;\n");
2345 fprintf(out, "--// Generated code goes here.\n\n"); 2345 fprintf(out, "--// Generated code goes here.\n\n");
2346 outputLeaf(out, OM_LUA, compiler->ast); 2346 outputLeaf(out, OM_LUA, compiler->ast);
2347// fprintf(out, "\n\nstateChange(default)\n"); 2347 fprintf(out, "\n\n--stateChange(defaultState)\n"); // This actually starts the script running. Not ready for that yet, gotta implement some ll*() functions first. So commented it out in Lua.
2348 fprintf(out, "\n--// End of generated code.\n\n"); 2348 fprintf(out, "\n--// End of generated code.\n\n");
2349 fclose(out); 2349 fclose(out);
2350 sprintf(buffer, "../../libraries/luajit-2.0/src/luajit \"%s\"", luaName); 2350 sprintf(buffer, "../../libraries/luajit-2.0/src/luajit \"%s\"", luaName);