00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "worldmap-script.h"
00010
00011 #include "WorldBranch.h"
00012 #include "LevelDesc.h"
00013 #include "LevelNode.h"
00014 #include "def-script.h"
00015
00016
00017 inline WorldBranch *
00018 getWorld(lua_State *L)
00019 {
00020 return dynamic_cast<WorldBranch*>(script_getLeader(L));
00021 }
00022
00023
00024
00025
00026
00027 int
00028 script_worldmap_addDesc(lua_State *L) throw()
00029 {
00030 BEGIN_NOEXCEPTION;
00031 const char *codename = luaL_checkstring(L, 1);
00032 const char *lang = luaL_checkstring(L, 2);
00033 const char *levelname = luaL_checkstring(L, 3);
00034 const char *desc = luaL_checkstring(L, 4);
00035
00036 LevelDesc *dialog = new LevelDesc(lang, levelname, desc);
00037 getWorld(L)->addDesc(codename, dialog);
00038 END_NOEXCEPTION;
00039 return 0;
00040 }
00041
00042
00043
00044
00045
00046 int
00047 script_branch_addNode(lua_State *L) throw()
00048 {
00049 BEGIN_NOEXCEPTION;
00050 const char *parent = luaL_checkstring(L, 1);
00051 const char *codename = luaL_checkstring(L, 2);
00052 const char *datafile = luaL_checkstring(L, 3);
00053 int nodeX = luaL_checkint(L, 4);
00054 int nodeY = luaL_checkint(L, 5);
00055 bool hidden = lua_toboolean(L, 6);
00056 const char *poster = luaL_optstring(L, 7, "");
00057
00058 LevelNode *node = new LevelNode(codename,
00059 Path::dataReadPath(datafile), V2(nodeX, nodeY), poster);
00060 getWorld(L)->addNode(parent, node, hidden);
00061 END_NOEXCEPTION;
00062 return 0;
00063 }
00064
00065
00066
00067
00068 int
00069 script_branch_setEnding(lua_State *L) throw()
00070 {
00071 BEGIN_NOEXCEPTION;
00072 const char *codename = luaL_checkstring(L, 1);
00073 const char *datafile = luaL_checkstring(L, 2);
00074 const char *poster = luaL_optstring(L, 3, "");
00075
00076 LevelNode *node = new LevelNode(codename,
00077 Path::dataReadPath(datafile), V2(-1, -1), poster);
00078 getWorld(L)->setEnding(node);
00079 END_NOEXCEPTION;
00080 return 0;
00081 }
00082
00083
00084
00085
00086 int
00087 script_node_bestSolution(lua_State *L) throw()
00088 {
00089 BEGIN_NOEXCEPTION;
00090 const char *codename = luaL_checkstring(L, 1);
00091 int moves = luaL_checkint(L, 2);
00092 const char *author = luaL_checkstring(L, 3);
00093
00094 getWorld(L)->bestSolution(codename, moves, author);
00095 END_NOEXCEPTION;
00096 return 0;
00097 }
00098
00099