Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
/*
|
|
|
|
* LuaCallWrapper.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "api/Registry.h"
|
|
|
|
#include "LuaStack.h"
|
2023-02-05 18:24:34 +02:00
|
|
|
#include <type_traits>
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
|
2022-08-15 13:38:17 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
namespace scripting
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace detail
|
|
|
|
{
|
|
|
|
|
2021-02-16 16:07:30 +02:00
|
|
|
template<int ...>
|
|
|
|
struct Seq {};
|
|
|
|
|
|
|
|
template<int N, int ...S>
|
|
|
|
struct Gens : Gens<N-1, N-1, S...> {};
|
|
|
|
|
|
|
|
template<int ...S>
|
|
|
|
struct Gens<0, S...>
|
|
|
|
{
|
|
|
|
typedef Seq<S...> type;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename R, typename ... Args>
|
|
|
|
class LuaArgumentsTuple
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
using TupleData = std::tuple<Args ...>;
|
|
|
|
using Functor = R(*)(Args ...);
|
|
|
|
|
|
|
|
TupleData args;
|
|
|
|
Functor f;
|
|
|
|
|
|
|
|
LuaArgumentsTuple(Functor _f)
|
|
|
|
:f(_f),
|
|
|
|
args()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
STRONG_INLINE int invoke(lua_State * L)
|
|
|
|
{
|
|
|
|
return callFunc(L, typename Gens<sizeof...(Args)>::type());
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
template<int ...N>
|
|
|
|
int callFunc(lua_State * L, Seq<N...>)
|
|
|
|
{
|
|
|
|
LuaStack S(L);
|
|
|
|
|
|
|
|
bool ok[sizeof...(Args)] = {(S.tryGet(N+1, std::get<N>(args)))...};
|
|
|
|
|
|
|
|
if(std::count(std::begin(ok), std::end(ok), false) > 0)
|
|
|
|
return S.retVoid();
|
|
|
|
|
|
|
|
|
|
|
|
R ret = f(std::get<N>(args) ...);
|
|
|
|
S.clear();
|
|
|
|
S.push(ret);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class LuaFunctionInvoker
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
template<typename R, typename ... Args>
|
|
|
|
static STRONG_INLINE int invoke(lua_State * L, R(*f)(Args ...))
|
|
|
|
{
|
|
|
|
LuaArgumentsTuple<R, Args ...> args(f);
|
|
|
|
return args.invoke(L);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
}
|
|
|
|
|
2021-02-16 16:07:30 +02:00
|
|
|
template <typename F, F f>
|
|
|
|
class LuaFunctionWrapper
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static int invoke(lua_State * L)
|
|
|
|
{
|
|
|
|
return detail::LuaFunctionInvoker::invoke(L, f);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
//TODO: this should be the only one wrapper type
|
|
|
|
//
|
|
|
|
template <typename U, typename M, M m>
|
|
|
|
class LuaMethodWrapper
|
|
|
|
{
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename U, typename T, typename R, R(T:: * method)()const>
|
|
|
|
class LuaMethodWrapper <U, R(T:: *)()const, method>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static int invoke(lua_State * L)
|
|
|
|
{
|
|
|
|
LuaStack S(L);
|
|
|
|
const U * obj = nullptr;
|
|
|
|
|
|
|
|
if(!S.tryGet(1,obj))
|
|
|
|
return S.retVoid();
|
|
|
|
|
|
|
|
static auto functor = std::mem_fn(method);
|
|
|
|
|
|
|
|
S.clear();
|
|
|
|
S.push(functor(obj));
|
|
|
|
return S.retPushed();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-02-16 16:07:30 +02:00
|
|
|
template <typename U, typename T, typename R, R(T:: * method)()>
|
|
|
|
class LuaMethodWrapper <U, R(T:: *)(), method>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static int invoke(lua_State * L)
|
|
|
|
{
|
|
|
|
LuaStack S(L);
|
|
|
|
U * obj = nullptr;
|
|
|
|
|
|
|
|
if(!S.tryGet(1,obj))
|
|
|
|
return S.retVoid();
|
|
|
|
|
|
|
|
static auto functor = std::mem_fn(method);
|
|
|
|
|
|
|
|
S.clear();
|
|
|
|
S.push(functor(obj));
|
|
|
|
return S.retPushed();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
template <typename U, typename T, void(T:: * method)()const>
|
|
|
|
class LuaMethodWrapper <U, void(T:: *)()const, method>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static int invoke(lua_State * L)
|
|
|
|
{
|
|
|
|
LuaStack S(L);
|
|
|
|
const U * obj = nullptr;
|
|
|
|
|
|
|
|
if(!S.tryGet(1,obj))
|
|
|
|
return S.retVoid();
|
|
|
|
|
|
|
|
static auto functor = std::mem_fn(method);
|
|
|
|
S.clear();
|
|
|
|
functor(obj);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-02-16 16:07:30 +02:00
|
|
|
template <typename U, typename T, void(T:: * method)()>
|
|
|
|
class LuaMethodWrapper <U, void(T:: *)(), method>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static int invoke(lua_State * L)
|
|
|
|
{
|
|
|
|
LuaStack S(L);
|
|
|
|
U * obj = nullptr;
|
|
|
|
|
|
|
|
if(!S.tryGet(1,obj))
|
|
|
|
return S.retVoid();
|
|
|
|
|
|
|
|
static auto functor = std::mem_fn(method);
|
|
|
|
S.clear();
|
|
|
|
functor(obj);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
template <typename U, typename T, typename R, typename P1, R(T:: * method)(P1)const>
|
|
|
|
class LuaMethodWrapper <U, R(T:: *)(P1)const, method>
|
|
|
|
{
|
2023-02-05 18:24:34 +02:00
|
|
|
using PM1 = std::remove_cv_t<std::remove_reference_t<P1>>;
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
public:
|
|
|
|
static int invoke(lua_State * L)
|
|
|
|
{
|
|
|
|
LuaStack S(L);
|
|
|
|
const U * obj = nullptr;
|
|
|
|
|
|
|
|
if(!S.tryGet(1,obj))
|
|
|
|
return S.retVoid();
|
|
|
|
|
2023-02-05 18:24:34 +02:00
|
|
|
PM1 p1;
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
if(!S.tryGet(2, p1))
|
|
|
|
return S.retVoid();
|
|
|
|
|
|
|
|
static auto functor = std::mem_fn(method);
|
|
|
|
S.clear();
|
|
|
|
S.push(functor(obj, p1));
|
|
|
|
return S.retPushed();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-02-16 16:07:30 +02:00
|
|
|
template <typename U, typename T, typename R, typename P1, R(T:: * method)(P1)>
|
|
|
|
class LuaMethodWrapper <U, R(T:: *)(P1), method>
|
|
|
|
{
|
2023-02-05 18:24:34 +02:00
|
|
|
using PM1 = std::remove_cv_t<std::remove_reference_t<P1>>;
|
2021-02-16 16:07:30 +02:00
|
|
|
public:
|
|
|
|
static int invoke(lua_State * L)
|
|
|
|
{
|
|
|
|
LuaStack S(L);
|
|
|
|
U * obj = nullptr;
|
|
|
|
|
|
|
|
if(!S.tryGet(1,obj))
|
|
|
|
return S.retVoid();
|
|
|
|
|
2023-02-05 18:24:34 +02:00
|
|
|
PM1 p1;
|
2021-02-16 16:07:30 +02:00
|
|
|
if(!S.tryGet(2, p1))
|
|
|
|
return S.retVoid();
|
|
|
|
|
|
|
|
static auto functor = std::mem_fn(method);
|
|
|
|
S.clear();
|
|
|
|
S.push(functor(obj, p1));
|
|
|
|
return S.retPushed();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
template <typename U, typename T, typename P1, void(T:: * method)(P1)const>
|
|
|
|
class LuaMethodWrapper <U, void(T:: *)(P1)const, method>
|
|
|
|
{
|
2023-02-05 18:24:34 +02:00
|
|
|
using PM1 = std::remove_cv_t<std::remove_reference_t<P1>>;
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
public:
|
|
|
|
static int invoke(lua_State * L)
|
|
|
|
{
|
|
|
|
LuaStack S(L);
|
|
|
|
const U * obj = nullptr;
|
|
|
|
|
|
|
|
if(!S.tryGet(1,obj))
|
|
|
|
return S.retVoid();
|
|
|
|
|
2023-02-05 18:24:34 +02:00
|
|
|
PM1 p1;
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
if(!S.tryGet(2, p1))
|
|
|
|
return S.retVoid();
|
|
|
|
|
|
|
|
static auto functor = std::mem_fn(method);
|
|
|
|
S.clear();
|
|
|
|
functor(obj, p1);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-02-16 16:07:30 +02:00
|
|
|
template <typename U, typename T, typename P1, void(T:: * method)(P1)>
|
|
|
|
class LuaMethodWrapper <U, void(T:: *)(P1), method>
|
|
|
|
{
|
2023-02-05 18:24:34 +02:00
|
|
|
using PM1 = std::remove_cv_t<std::remove_reference_t<P1>>;
|
2021-02-16 16:07:30 +02:00
|
|
|
public:
|
|
|
|
static int invoke(lua_State * L)
|
|
|
|
{
|
|
|
|
LuaStack S(L);
|
|
|
|
U * obj = nullptr;
|
|
|
|
|
|
|
|
if(!S.tryGet(1,obj))
|
|
|
|
return S.retVoid();
|
|
|
|
|
2023-02-05 18:24:34 +02:00
|
|
|
PM1 p1;
|
2021-02-16 16:07:30 +02:00
|
|
|
if(!S.tryGet(2, p1))
|
|
|
|
return S.retVoid();
|
|
|
|
|
|
|
|
static auto functor = std::mem_fn(method);
|
|
|
|
S.clear();
|
|
|
|
functor(obj, p1);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
};
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
|
|
|
|
template <typename U, typename T, typename R, typename P1, typename P2, R(T:: * method)(P1, P2)const>
|
|
|
|
class LuaMethodWrapper <U, R(T:: *)(P1, P2)const, method>
|
|
|
|
{
|
2023-02-05 18:24:34 +02:00
|
|
|
using PM1 = std::remove_cv_t<std::remove_reference_t<P1>>;
|
|
|
|
using PM2 = std::remove_cv_t<std::remove_reference_t<P2>>;
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
public:
|
|
|
|
static int invoke(lua_State * L)
|
|
|
|
{
|
|
|
|
LuaStack S(L);
|
|
|
|
const U * obj = nullptr;
|
|
|
|
|
|
|
|
if(!S.tryGet(1, obj))
|
|
|
|
return S.retVoid();
|
|
|
|
|
2023-02-05 18:24:34 +02:00
|
|
|
PM1 p1;
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
if(!S.tryGet(2, p1))
|
|
|
|
return S.retVoid();
|
|
|
|
|
2023-02-05 18:24:34 +02:00
|
|
|
PM2 p2;
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
if(!S.tryGet(3, p2))
|
|
|
|
return S.retVoid();
|
|
|
|
|
|
|
|
static auto functor = std::mem_fn(method);
|
|
|
|
S.clear();
|
|
|
|
S.push(functor(obj, p1, p2));
|
|
|
|
return S.retPushed();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename U, typename T, typename P1, typename P2, void(T:: * method)(P1, P2)const>
|
|
|
|
class LuaMethodWrapper <U, void(T:: *)(P1, P2)const, method>
|
|
|
|
{
|
2023-02-05 18:24:34 +02:00
|
|
|
using PM1 = std::remove_cv_t<std::remove_reference_t<P1>>;
|
|
|
|
using PM2 = std::remove_cv_t<std::remove_reference_t<P2>>;
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
public:
|
|
|
|
static int invoke(lua_State * L)
|
|
|
|
{
|
|
|
|
LuaStack S(L);
|
|
|
|
const U * obj = nullptr;
|
|
|
|
|
|
|
|
if(!S.tryGet(1, obj))
|
|
|
|
return S.retVoid();
|
|
|
|
|
2023-02-05 18:24:34 +02:00
|
|
|
PM1 p1;
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
if(!S.tryGet(2, p1))
|
|
|
|
return S.retVoid();
|
|
|
|
|
2023-02-05 18:24:34 +02:00
|
|
|
PM2 p2;
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
if(!S.tryGet(3, p2))
|
|
|
|
return S.retVoid();
|
|
|
|
|
|
|
|
static auto functor = std::mem_fn(method);
|
|
|
|
S.clear();
|
|
|
|
functor(obj, p1, p2);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
2022-08-15 13:38:17 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|