____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
A futuristic real-time strategy game.
This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project.
Distributed under the "GNU General Public License"00001 // ____ _ __ 00002 // / __ )____ _____ | | / /___ ___________ 00003 // / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/ 00004 // / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ ) 00005 // /_____/\____/____/ |__/|__/\__,_/_/ /____/ 00006 // 00007 // A futuristic real-time strategy game. 00008 // This file is part of Bos Wars. 00009 // 00011 // 00012 // (c) Copyright 1998-2008 by Lutz Sammer and Jimmy Salmon 00013 // 00014 // This program is free software; you can redistribute it and/or modify 00015 // it under the terms of the GNU General Public License as published by 00016 // the Free Software Foundation; only version 2 of the License. 00017 // 00018 // This program is distributed in the hope that it will be useful, 00019 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 // GNU General Public License for more details. 00022 // 00023 // You should have received a copy of the GNU General Public License 00024 // along with this program; if not, write to the Free Software 00025 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00026 // 02111-1307, USA. 00027 00028 #ifndef __SCRIPT_H__ 00029 #define __SCRIPT_H__ 00030 00032 00033 /*---------------------------------------------------------------------------- 00034 -- Includes 00035 ----------------------------------------------------------------------------*/ 00036 00037 #include <string> 00038 00039 #ifdef __cplusplus 00040 extern "C" { 00041 #endif 00042 #include "lua.h" 00043 #include "lauxlib.h" 00044 #include "lualib.h" 00045 #ifdef __cplusplus 00046 } 00047 #endif 00048 00049 /*---------------------------------------------------------------------------- 00050 -- Declarations 00051 ----------------------------------------------------------------------------*/ 00052 00053 class CFile; 00054 00055 typedef struct _lua_user_data_ { 00056 int Type; 00057 void *Data; 00058 } LuaUserData; 00059 00060 enum { 00061 LuaUnitType = 100, 00062 LuaSoundType, 00063 }; 00064 00065 extern lua_State *Lua; 00066 00067 extern int LuaLoadFile(const std::string &file); 00068 extern int LuaCall(int narg, int clear, bool exitOnError = true); 00069 00070 #define LuaError(l, args) \ 00071 do { \ 00072 fprintf(stdout, "%s:%d: ", __FILE__, __LINE__); \ 00073 fprintf(stdout, args); \ 00074 fprintf(stdout, "\n"); \ 00075 lua_pushfstring(l, args); lua_error(l); \ 00076 } while (0) 00077 00078 #define LuaCheckArgs(l, args) \ 00079 do { \ 00080 if (lua_gettop(l) != args) { \ 00081 LuaError(l, "incorrect argument"); \ 00082 } \ 00083 } while (0) 00084 00085 /*---------------------------------------------------------------------------- 00086 -- Variables 00087 ----------------------------------------------------------------------------*/ 00088 00089 extern std::string CclStartFile; 00090 extern int CclInConfigFile; 00091 00092 /*---------------------------------------------------------------------------- 00093 -- Functions 00094 ----------------------------------------------------------------------------*/ 00095 00096 extern const char *LuaToString(lua_State *l, int narg); 00097 extern int LuaToNumber(lua_State *l, int narg); 00098 extern bool LuaToBoolean(lua_State *l, int narg); 00099 00100 extern void CclGarbageCollect(int fast); 00101 extern void InitCcl(void); 00102 extern void LoadCcl(void); 00103 extern void SaveCcl(CFile *file); 00104 extern void SavePreferences(void); 00105 extern char *SaveGlobal(lua_State *l, bool is_root); 00106 extern int CclCommand(const std::string &command, bool exitOnError = true); 00107 00109 00110 #endif // !__SCRIPT_H__
1.5.6