scripting/lua_api.hpp

Go to the documentation of this file.
00001 /* $Id: lua_api.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2009 - 2012 by Guillaume Melquiond <guillaume.melquiond@gmail.com>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 
00016 #ifndef SCRIPTING_LUA_API_HPP
00017 #define SCRIPTING_LUA_API_HPP
00018 
00019 #include <cstddef>
00020 
00021 struct lua_State;
00022 class config;
00023 class vconfig;
00024 class unit;
00025 
00026 bool luaW_pcall(lua_State *L , int nArgs, int nRets, bool allow_wml_error = false);
00027 unit *luaW_tounit(lua_State *L, int index, bool only_on_map = false);
00028 void luaW_pushconfig(lua_State *L, config const &cfg);
00029 bool luaW_toconfig(lua_State *L, int index, config &cfg, int tstring_meta = 0);
00030 bool luaW_tovconfig(lua_State *L, int index, vconfig &vcfg);
00031 
00032 /**
00033  * Storage for a unit, either owned by the Lua code (#ptr != 0), on a
00034  * recall list (#side != 0), or on the map. Shared units are represented
00035  * by their underlying ID (#uid).
00036  */
00037 class lua_unit
00038 {
00039     size_t uid;
00040     unit *ptr;
00041     int side;
00042     lua_unit(lua_unit const &);
00043 
00044 public:
00045     lua_unit(size_t u): uid(u), ptr(NULL), side(0) {}
00046     lua_unit(unit *u): uid(0), ptr(u), side(0) {}
00047     lua_unit(int s, size_t u): uid(u), ptr(NULL), side(s) {}
00048     ~lua_unit();
00049     bool on_map() const { return !ptr && side == 0; }
00050     int on_recall_list() const { return side; }
00051     unit *get();
00052 };
00053 
00054 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:03:09 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs