16 #include "boost/variant/static_visitor.hpp"
23 #include "formula/callable_objects.hpp"
42 std::vector<variant>
values;
47 for(
size_t i = 1;
i <=
n;
i++) {
53 }
else if(key ==
"__map") {
54 std::map<variant,variant>
values;
66 void get_inputs(std::vector<formula_input>* inputs)
const {
83 if(mState == lua->
mState) {
104 return lhs < rhs ? -1 : (lhs > rhs ? 1 : 0);
111 return mState < lua->
mState ? -1 : 1;
131 typedef std::map<variant,variant>::value_type kv_type;
133 for(
const kv_type&
v : val.
as_map()) {
141 const unit& u = u_ref->get_unit();
156 std::vector<formula_input> inputs;
209 bool need_delete =
false;
295 return "Adding formula metatable...\n";
#define lua_isnoneornil(L, n)
LUA_API void lua_pushlightuserdata(lua_State *L, void *p)
LUA_API void lua_createtable(lua_State *L, int narray, int nrec)
#define lua_pushcfunction(L, f)
LUA_API void lua_getfield(lua_State *L, int idx, const char *k)
const map_location & get_location() const
bool luaW_tovconfig(lua_State *L, int index, vconfig &vcfg)
Gets an optional vconfig from either a table or a userdata.
LUA_API void lua_settop(lua_State *L, int idx)
LUA_API int lua_type(lua_State *L, int idx)
size_t underlying_id() const
The unique internal ID of the unit.
config get_parsed_config() const
LUA_API int lua_gettop(lua_State *L)
const game_logic::formula_callable * as_callable() const
LUA_API void lua_settable(lua_State *L, int idx)
#define lua_tointeger(L, i)
GLuint const GLfloat * val
#define lua_tonumber(L, i)
const std::map< variant, variant > & as_map() const
luatypekey const getunitKey
LUA_API int lua_absindex(lua_State *L, int idx)
LUA_API void * lua_newuserdata(lua_State *L, size_t size)
GLboolean GLenum GLenum GLvoid * values
unit * luaW_tounit(lua_State *L, int index, bool only_on_map)
Converts a Lua value to a unit pointer.
LUA_API int lua_compare(lua_State *L, int index1, int index2, int op)
LUA_API int lua_isstring(lua_State *L, int idx)
void get_inputs(std::vector< formula_input > *inputs) const
LUA_API const char * lua_pushlstring(lua_State *L, const char *s, size_t len)
LUA_API int lua_getmetatable(lua_State *L, int objindex)
LUA_API int lua_setmetatable(lua_State *L, int objindex)
LUA_API void lua_pushnil(lua_State *L)
LUA_API void lua_pushnumber(lua_State *L, lua_Number n)
Encapsulates the map of the game.
Storage for a unit, either owned by the Lua code (ptr != 0), a local variable unit (c_ptr != 0)...
bool luaW_totstring(lua_State *L, int index, t_string &str)
Converts a scalar to a translatable string.
LUA_API void * lua_touserdata(lua_State *L, int idx)
bool luaW_hasmetatable(lua_State *L, int index, luatypekey key)
Returns true if the metatable of the object is the one found in the registry.
LUA_API void lua_rawset(lua_State *L, int idx)
const std::string & as_string() const
luatypekey const formulaKey
#define lua_tostring(L, i)
LUA_API int lua_isnumber(lua_State *L, int idx)
static vconfig unconstructed_vconfig()
This is just a wrapper for the default constructor; it exists for historical reasons and to make it c...
lua_callable(lua_State *L, int i)
LUA_API void lua_gettable(lua_State *L, int idx)
LUA_API size_t lua_rawlen(lua_State *L, int idx)
#define LUA_REGISTRYINDEX
LUA_API const void * lua_topointer(lua_State *L, int idx)
#define lua_istable(L, n)
void luaW_pushlocation(lua_State *L, const map_location &ml)
Converts a map location object to a Lua table pushed at the top of the stack.
A variable-expanding proxy for the config class.
const std::vector< variant > & as_list() const
int do_compare(const formula_callable *other) const
variant get_value(const std::string &key) const
unit_iterator find(size_t id)
const std::string & str() const
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
LUALIB_API int luaL_typerror(lua_State *L, int narg, const char *tname)
LUA_API void lua_rawget(lua_State *L, int idx)
GLsizei const GLcharARB ** string
LUA_API const char * lua_pushstring(lua_State *L, const char *s)
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
LUA_API int lua_next(lua_State *L, int idx)
bool luaW_tolocation(lua_State *L, int index, map_location &loc)
Converts an optional table or pair of integers to a map location object.
#define luaL_checkstring(L, n)