本文整理汇总了C++中LUA_DEBUG_END函数的典型用法代码示例。如果您正苦于以下问题:C++ LUA_DEBUG_END函数的具体用法?C++ LUA_DEBUG_END怎么用?C++ LUA_DEBUG_END使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LUA_DEBUG_END函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _get_int_attrib
static void _get_int_attrib(lua_State *L, const char *key, int &output,
const int default_output)
{
LUA_DEBUG_START(L);
lua_pushstring(L, key);
lua_gettable(L, -2);
if (lua_isnil(L, -1)) {
output = default_output;
} else {
output = lua_tointeger(L,-1);
}
lua_pop(L, 1);
LUA_DEBUG_END(L, 0);
}
示例2: LUA_DEBUG_START
void LuaShipDef::Register()
{
lua_State *l = Lua::manager->GetLuaState();
LUA_DEBUG_START(l);
lua_newtable(l);
for (std::map<ShipType::Id,ShipType>::const_iterator i = ShipType::types.begin(); i != ShipType::types.end(); ++i)
{
const ShipType &st = (*i).second;
lua_newtable(l);
pi_lua_settable(l, "id", (*i).first.c_str());
pi_lua_settable(l, "name", st.name.c_str());
pi_lua_settable(l, "modelName", st.modelName.c_str());
pi_lua_settable(l, "tag", EnumStrings::GetString("ShipTypeTag", st.tag));
pi_lua_settable(l, "angularThrust", st.angThrust);
pi_lua_settable(l, "capacity", st.capacity);
pi_lua_settable(l, "hullMass", st.hullMass);
pi_lua_settable(l, "basePrice", double(st.baseprice)*0.01);
pi_lua_settable(l, "minCrew", st.minCrew);
pi_lua_settable(l, "maxCrew", st.maxCrew);
pi_lua_settable(l, "defaultHyperdrive", EnumStrings::GetString("EquipType", st.hyperdrive));
lua_newtable(l);
for (int t = ShipType::THRUSTER_REVERSE; t < ShipType::THRUSTER_MAX; t++)
pi_lua_settable(l, EnumStrings::GetString("ShipTypeThruster", t), st.linThrust[t]);
pi_lua_readonly_table_proxy(l, -1);
lua_setfield(l, -3, "linearThrust");
lua_pop(l, 1);
lua_newtable(l);
for (int slot = Equip::SLOT_CARGO; slot < Equip::SLOT_MAX; slot++)
pi_lua_settable(l, EnumStrings::GetString("EquipSlot", slot), st.equipSlotCapacity[slot]);
pi_lua_readonly_table_proxy(l, -1);
lua_setfield(l, -3, "equipSlotCapacity");
lua_pop(l, 1);
pi_lua_readonly_table_proxy(l, -1);
lua_setfield(l, -3, (*i).first.c_str());
lua_pop(l, 1);
}
pi_lua_readonly_table_proxy(l, -1);
lua_setglobal(l, "ShipDef");
lua_pop(l, 1);
LUA_DEBUG_END(l, 0);
}
示例3: LUA_DEBUG_START
void Player::SetShipType(const ShipType::Id &shipId) {
Ship::SetShipType(shipId);
lua_State *l = Lua::manager->GetLuaState();
LUA_DEBUG_START(l);
LuaObject<Player>::PushToLua(this);
lua_pushcclosure(l, onEquipChangeListener, 1);
LuaRef lr(Lua::manager->GetLuaState(), -1);
ScopedTable(m_equipSet).CallMethod("AddListener", lr);
lua_pop(l, 1);
LUA_DEBUG_END(l, 0);
}
示例4: l_luachatform_set_face
/*
* Method: SetFace
*
* Set the properties used to generate the face
*
* > form:SetFace({
* > female = female,
* > armour = armour,
* > seed = seed,
* > name = name,
* > title = title,
* > })
*
* Parameters:
*
* female - if true, the face will be female. If false, the face will be
* male. If not specified, a gender will be chosen at random.
*
* armour - if true, the face will wear armour, otherwise the face will have
* clothes and accessories.
*
* seed - the seed for the random number generator. if not specified, the
* station seed will be used. if 0, a random seed will be generated
*
* name - name of the person. If not specified, a random one will be generated.
*
* title - the person's job or other suitable title. If not specified, nothing
* will be shown.
*
* Example:
*
* > form:SetFace({
* > female = true,
* > armour = false,
* > seed = 1234,
* > name = "Steve",
* > title = "Station manager",
* > })
*
* Availability:
*
* alpha 10
*
* Status:
*
* experimental
*/
static int l_luachatform_set_face(lua_State *l)
{
LuaChatForm *form = LuaObject<LuaChatForm>::CheckFromLua(1);
luaL_checktype(l, 2, LUA_TTABLE);
LUA_DEBUG_START(l);
Uint32 flags = 0;
Uint32 seed = 0;
std::string name = "";
std::string title = "";
lua_getfield(l, 2, "female");
if (lua_isnil(l, -1))
flags = FaceVideoLink::GENDER_RAND;
else if (lua_toboolean(l, -1))
flags = FaceVideoLink::GENDER_FEMALE;
else
flags = FaceVideoLink::GENDER_MALE;
lua_pop(l, 1);
lua_getfield(l, 2, "armour");
if (lua_toboolean(l, -1))
flags |= FaceVideoLink::ARMOUR;
lua_pop(l, 1);
lua_getfield(l, 2, "seed");
if (!lua_isnil(l, -1))
seed = luaL_checkinteger(l, -1);
lua_pop(l, 1);
lua_getfield(l, 2, "name");
if (!lua_isnil(l, -1))
name = luaL_checkstring(l, -1);
lua_pop(l, 1);
lua_getfield(l, 2, "title");
if (!lua_isnil(l, -1))
title = luaL_checkstring(l, -1);
lua_pop(l, 1);
LUA_DEBUG_END(l, 0);
form->SetFaceFlags(flags);
form->SetFaceSeed(seed);
form->SetCharacterName(name);
form->SetCharacterTitle(title);
return 0;
}
示例5: GetNameGenFunc
static bool GetNameGenFunc(lua_State *l, const char *func)
{
LUA_DEBUG_START(l);
lua_getglobal(l, "NameGen");
if (lua_isnil(l, -1)) {
lua_pop(l, 1);
LUA_DEBUG_END(l, 0);
return false;
}
lua_getfield(l, -1, func);
if (lua_isnil(l, -1)) {
lua_pop(l, 2);
LUA_DEBUG_END(l, 0);
return false;
}
lua_remove(l, -2);
LUA_DEBUG_END(l, 1);
return true;
}
示例6: GetAdvert
void LuaChatForm::OnClose() {
StationAdvertForm::OnClose();
lua_State *l = Lua::manager->GetLuaState();
int ref = GetAdvert()->ref;
LUA_DEBUG_START(l);
if (m_commodityTradeWidget) {
lua_getfield(l, LUA_REGISTRYINDEX, "PiAdverts");
assert(lua_istable(l, -1));
lua_pushinteger(l, ref);
lua_gettable(l, -2);
assert(!lua_isnil(l, -1));
lua_pushstring(l, "tradeWidgetFunctions");
lua_pushnil(l);
lua_settable(l, -3);
lua_pop(l, 2);
}
if (!AdTaken()) return;
lua_getfield(l, LUA_REGISTRYINDEX, "PiAdverts");
assert(lua_istable(l, -1));
lua_pushinteger(l, ref);
lua_gettable(l, -2);
assert(!lua_isnil(l, -1));
lua_getfield(l, -1, "onDelete");
if (!lua_isnil(l, -1)) {
lua_pushinteger(l, ref);
pi_lua_protected_call(l, 1, 0);
}
else
lua_pop(l, 1);
lua_pop(l, 1);
lua_pushinteger(l, ref);
lua_pushnil(l);
lua_settable(l, -3);
lua_pop(l, 1);
LUA_DEBUG_END(l, 0);
}
示例7: init_global_table
// Create the table and leave a copy on the stack for further use
static void init_global_table(lua_State *l) {
LUA_DEBUG_START(l);
lua_newtable(l);
lua_newtable(l);
lua_pushliteral(l, "__index");
lua_getglobal(l, "_G");
lua_rawset(l, -3);
lua_setmetatable(l, -2);
lua_pushvalue(l, -1);
lua_setfield(l, LUA_REGISTRYINDEX, "ConsoleGlobal");
LUA_DEBUG_END(l, 1);
}
示例8: Queue
void Queue(const char *event, const ArgsBase &args)
{
lua_State *l = Lua::manager->GetLuaState();
LUA_DEBUG_START(l);
if (!_get_method_onto_stack(l, "Queue")) return;
int top = lua_gettop(l);
lua_pushstring(l, event);
args.PrepareStack();
pi_lua_protected_call(l, lua_gettop(l) - top, 0);
LUA_DEBUG_END(l, 0);
}
示例9: l_lang_get_dictionary
/*
* Function: GetDictionary
*
* Retrieve a Lua table for the current language.
*
* > dict = Lang.GetDictionary()
* > print(dict['WE_HAVE_NO_BUSINESS_WITH_YOU'])
*
* Return:
*
* dict - A Lua table mapping language token to translated string.
*
* Availability:
*
* alpha 15
*
* Status:
*
* stable
*/
static int l_lang_get_dictionary(lua_State *l)
{
LUA_DEBUG_START(l);
lua_getfield(l, LUA_REGISTRYINDEX, "LangCoreDictionary");
if (lua_isnil(l, -1)) {
lua_pop(l, 1);
_build_dictionary_table(l);
pi_lua_table_ro(l);
lua_pushvalue(l, -1);
lua_setfield(l, LUA_REGISTRYINDEX, "LangCoreDictionary");
}
LUA_DEBUG_END(l, 1);
return 1;
}
示例10: l_spacestation_add_advert
/*
* Method: AddAdvert
*
* Add an advertisement to the station's bulletin board
*
* > ref = station:AddAdvert(description, chatfunc, deletefunc)
*
* Parameters:
*
* description - text to display in the bulletin board
*
* chatfunc - function to call when the ad is activated. The function is
* passed three parameters: a <ChatForm> object for the ad
* conversation display, the ad reference returned by <AddAdvert>
* when the ad was created, and an integer value corresponding to
* the action that caused the activation. When the ad is initially
* selected from the bulletin board, this value is 0. Additional
* actions (and thus values) are defined by the script via
* <ChatForm.AddAction>.
*
* deletefunc - optional. function to call when the ad is removed from the
* bulletin board. This happens when <RemoveAdvert> is called,
* when the ad is cleaned up after
* <ChatForm.RemoveAdvertOnClose> is called, and when the
* <SpaceStation> itself is destroyed (eg the player leaves the
* system).
*
* Return:
*
* ref - an integer value for referring to the ad in the future. This value
* will be passed to the ad's chat function and should be passed to
* <RemoveAdvert> to remove the ad from the bulletin board.
*
* Example:
*
* > local ref = station:AddAdvert(
* > "FAST SHIP to deliver a package to the Epsilon Eridani system.",
* > function (ref, opt) ... end,
* > function (ref) ... end
* > )
*
* Availability:
*
* alpha 10
*
* Status:
*
* stable
*/
static int l_spacestation_add_advert(lua_State *l)
{
LUA_DEBUG_START(l);
SpaceStation *s = LuaSpaceStation::GetFromLua(1);
std::string description = luaL_checkstring(l, 2);
luaL_checktype(l, 3, LUA_TFUNCTION); // any type of function
bool have_delete = false;
if (lua_gettop(l) >= 4) {
luaL_checktype(l, 4, LUA_TFUNCTION); // any type of function
have_delete = true;
}
int ref = s->AddBBAdvert(description, _create_chat_form);
lua_getfield(l, LUA_REGISTRYINDEX, "PiAdverts");
if (lua_isnil(l, -1)) {
lua_pop(l, 1);
lua_newtable(l);
lua_pushvalue(l, -1);
lua_setfield(l, LUA_REGISTRYINDEX, "PiAdverts");
}
lua_pushinteger(l, ref);
lua_newtable(l);
lua_pushstring(l, "onChat");
lua_pushvalue(l, 3);
lua_settable(l, -3);
if (have_delete) {
lua_pushstring(l, "onDelete");
lua_pushvalue(l, 4);
lua_settable(l, -3);
}
lua_settable(l, -3);
lua_pop(l, 1);
LUA_DEBUG_END(l,0);
_register_for_station_delete(s);
lua_pushinteger(l, ref);
return 1;
}
示例11: _json_to_lua
static void _json_to_lua(lua_State *l, const Json &data)
{
LUA_DEBUG_START(l);
switch (data.type()) {
case Json::nullValue:
lua_pushnil(l);
break;
case Json::intValue:
case Json::uintValue:
case Json::realValue:
lua_pushnumber(l, data.asDouble());
break;
case Json::stringValue: {
const std::string &str(data.asString());
lua_pushlstring(l, str.c_str(), str.size());
break;
}
case Json::booleanValue:
lua_pushboolean(l, data.asBool());
break;
case Json::arrayValue: {
lua_newtable(l);
for (int i = 0; i < int(data.size()); i++) {
lua_pushinteger(l, i+1);
_json_to_lua(l, data[i]);
lua_rawset(l, -3);
}
break;
}
case Json::objectValue: {
lua_newtable(l);
for (Json::const_iterator i = data.begin(); i != data.end(); ++i) {
const std::string &key(i.key().asString());
lua_pushlstring(l, key.c_str(), key.size());
_json_to_lua(l, *i);
lua_rawset(l, -3);
}
break;
}
}
LUA_DEBUG_END(l, 1);
}
示例12: register_class
static void register_class(lua_State *L, const char *tname, luaL_Reg *meta)
{
LUA_DEBUG_START(L);
luaL_newmetatable(L, tname);
luaL_setfuncs(L, meta, 0);
// map the metatable to its own __index
lua_pushvalue(L, -1);
lua_setfield(L, -2, "__index");
// publish the metatable
lua_setglobal(L, tname);
LUA_DEBUG_END(L, 0);
}
示例13: l_space_spawn_ship_parked
/*
* Function: SpawnShipParked
*
* Create a ship and place it in one of the given <SpaceStation's> parking spots.
*
* > ship = Space.SpawnShipParked(type, station)
*
* For orbital stations the parking spots are some distance from the door, out
* of the path of ships entering and leaving the station. For group stations
* the parking spots are directly above the station, usually some distance
* away.
*
* Parameters:
*
* type - the name of the ship
*
* station - the <SpaceStation> to place the near
*
* Return:
*
* ship - a <Ship> object for the new ship, or nil if there was no space
* inside the station
* Availability:
*
* alpha 10
*
* Status:
*
* experimental
*/
static int l_space_spawn_ship_parked(lua_State *l)
{
if (!Pi::game)
luaL_error(l, "Game is not started");
LUA_DEBUG_START(l);
const char *type = luaL_checkstring(l, 1);
if (! ShipType::Get(type))
luaL_error(l, "Unknown ship type '%s'", type);
SpaceStation *station = LuaObject<SpaceStation>::CheckFromLua(2);
int slot;
if (!station->AllocateStaticSlot(slot))
return 0;
Ship *ship = new Ship(type);
assert(ship);
double parkDist = station->GetStationType()->parkingDistance;
parkDist -= ship->GetPhysRadius(); // park inside parking radius
double parkOffset = 0.5 * station->GetStationType()->parkingGapSize;
parkOffset += ship->GetPhysRadius(); // but outside the docking gap
double xpos = (slot == 0 || slot == 3) ? -parkOffset : parkOffset;
double zpos = (slot == 0 || slot == 1) ? -parkOffset : parkOffset;
vector3d parkPos = vector3d(xpos, parkDist, zpos);
parkPos = station->GetPosition() + station->GetOrient() * parkPos;
// orbital stations have Y as axis of rotation
matrix3x3d rot = matrix3x3d::RotateX(M_PI/2) * station->GetOrient();
ship->SetFrame(station->GetFrame());
ship->SetVelocity(vector3d(0.0));
ship->SetPosition(parkPos);
ship->SetOrient(rot);
Pi::game->GetSpace()->AddBody(ship);
ship->AIHoldPosition();
LuaObject<Ship>::PushToLua(ship);
LUA_DEBUG_END(l, 1);
return 1;
}
示例14: Ship
Player::Player(ShipType::Id shipId): Ship(shipId)
{
SetController(new PlayerShipController());
InitCockpit();
lua_State *l = Lua::manager->GetLuaState();
LUA_DEBUG_START(l);
LuaObject<Player>::PushToLua(this);
lua_pushcclosure(l, onEquipChangeListener, 1);
LuaRef lr(Lua::manager->GetLuaState(), -1);
ScopedTable(m_equipSet).CallMethod("AddListener", lr);
lua_pop(l, 1);
LUA_DEBUG_END(l, 0);
}
示例15: LUA_DEBUG_START
void LuaConsole::Register()
{
lua_State *l = Pi::luaManager->GetLuaState();
LUA_DEBUG_START(l);
static const luaL_reg methods[] = {
{ "AddLine", l_console_addline },
{ 0, 0 }
};
luaL_register(l, "Console", methods);
lua_pop(l, 1);
LUA_DEBUG_END(l, 0);
}