//-----------------------------------------------------------------------------
// Expose CSourcePython.
//-----------------------------------------------------------------------------
void export_source_python_plugin(scope _core)
{
	class_<CSourcePython, bases<IEntityListener>, boost::noncopyable>("_SourcePythonPlugin", no_init);

	// Singleton...
	_core.attr("_sp_plugin") = boost::ref(g_SourcePythonPlugin);
}
Exemple #2
0
    void module_::operator[](scope s)
    {
        if (m_name)
        {
            lua_pushstring(m_state, m_name);
            lua_gettable(m_state, LUA_GLOBALSINDEX);

            if (!lua_istable(m_state, -1))
            {
                lua_pop(m_state, 1);

                lua_newtable(m_state);
                lua_pushstring(m_state, m_name);
                lua_pushvalue(m_state, -2);
                lua_settable(m_state, LUA_GLOBALSINDEX);
            }
        }
        else
        {
            lua_pushvalue(m_state, LUA_GLOBALSINDEX);
        }

        lua_pop_stack guard(m_state);

        s.register_(m_state);
    }
Exemple #3
0
void module_::operator[](scope s)
{
    lua_State* L = m_table.interpreter();

    m_table.push(L);

    lua_pop_stack guard(L);

    s.register_(L);
}
//-----------------------------------------------------------------------------
// Exports IPhysics.
//-----------------------------------------------------------------------------
void export_physics(scope _physics)
{
	class_<IPhysicsWrapper, boost::noncopyable> Physics("Physics", no_init);

	Physics.def(
		"get_active_environment_by_index",
		&IPhysicsWrapper::GetActiveEnvironmentByIndex,
		manage_new_object_policy()
	);

	//Physics ADD_MEM_TOOLS_WRAPPER(IPhysicsWrapper, IPhysics);

	_physics.attr("physics") = object(ptr(Wrap<IPhysicsWrapper>(physics)));
}
//-----------------------------------------------------------------------------
// Exports IBotManager.
//-----------------------------------------------------------------------------
void export_botmanager(scope _bots)
{
	class_<IBotManager, boost::noncopyable>("_BotManager", no_init)
		.def("get_bot_controller",
			&IBotManager::GetBotController,
			"Returns the BotController object for the given bot edict.",
			args("edict"),
			reference_existing_object_policy()
		)

		.def("create_bot",
			&IBotManager::CreateBot,
			"Creates a new bot and spawns it into the server.",
			args("bot_name"),
			reference_existing_object_policy()
		)

		ADD_MEM_TOOLS(IBotManager)
	;

	_bots.attr("bot_manager") = object(ptr(botmanager));
}
Exemple #6
0
    void module_::operator[](scope s)
    {
        if (m_name)
        {
            lua_getglobal(m_state, m_name);

            if (!lua_istable(m_state, -1))
            {
                lua_pop(m_state, 1);

                lua_newtable(m_state);
                lua_pushvalue(m_state, -1);
                lua_setglobal(m_state, m_name);
            }
        }
        else
        {
            lua_pushglobaltable(m_state);
        }

        lua_pop_stack guard(m_state);

        s.register_(m_state);
    }
//-----------------------------------------------------------------------------
// Exposes the messages specific constants
//-----------------------------------------------------------------------------
void export_constants(scope _messages)
{
	_messages.attr("SCREENFADE_FRACBITS") = SCREENFADE_FRACBITS;
}
Exemple #8
0
// Placing this after the specialization above suppresses a CWPro8.3 bug
inline scope::scope(scope const& new_scope)
    : object(new_scope)
    , m_previous_scope(detail::current_scope)
{
    detail::current_scope = python::incref(new_scope.ptr());
}
//-----------------------------------------------------------------------------
// Expose constants.
//-----------------------------------------------------------------------------
void export_constants(scope _core)
{
	_core.attr("SOURCE_ENGINE") = XSTRINGIFY(SOURCE_ENGINE);
	_core.attr("SOURCE_ENGINE_BRANCH") = XSTRINGIFY(SOURCE_ENGINE_BRANCH);
}
//-----------------------------------------------------------------------------
// Expose SendPropFlags.
//-----------------------------------------------------------------------------
void export_send_prop_flags(scope _props)
{
	_props.attr("SPROP_UNSIGNED") = SPROP_UNSIGNED;
	_props.attr("SPROP_COORD") = SPROP_COORD;
	_props.attr("SPROP_NOSCALE") = SPROP_NOSCALE;
	_props.attr("SPROP_ROUNDDOWN") = SPROP_ROUNDDOWN;
	_props.attr("SPROP_ROUNDUP") = SPROP_ROUNDUP;
	_props.attr("SPROP_NORMAL") = SPROP_NORMAL;
	_props.attr("SPROP_EXCLUDE") = SPROP_EXCLUDE;
	_props.attr("SPROP_XYZE") = SPROP_XYZE;
	_props.attr("SPROP_INSIDEARRAY") = SPROP_INSIDEARRAY;
	_props.attr("SPROP_PROXY_ALWAYS_YES") = SPROP_PROXY_ALWAYS_YES;
	_props.attr("SPROP_IS_A_VECTOR_ELEM") = SPROP_IS_A_VECTOR_ELEM;
	_props.attr("SPROP_COLLAPSIBLE") = SPROP_COLLAPSIBLE;
	_props.attr("SPROP_COORD_MP") = SPROP_COORD_MP;
	_props.attr("SPROP_COORD_MP_LOWPRECISION") = SPROP_COORD_MP_LOWPRECISION;
	_props.attr("SPROP_COORD_MP_INTEGRAL") = SPROP_COORD_MP_INTEGRAL;
	_props.attr("SPROP_CHANGES_OFTEN") = SPROP_CHANGES_OFTEN;
}
//-----------------------------------------------------------------------------
// Exports CGlobalVarsBase.
//-----------------------------------------------------------------------------
void export_globals(scope _globals)
{
	GlobalsBase_Visitor(

	class_<CGlobalVarsBase>("_GlobalVarsBase", init<bool>())
		.def("is_client",
			&CGlobalVarsBase::IsClient,
			"Returns True if the game is a client."
		)

		.def("get_network_base",
			&CGlobalVarsBase::GetNetworkBase,
            "for encoding m_flSimulationTime, m_flAnimTime",
            args("tick", "entity")
		)

		.def_readwrite("real_time",
			&CGlobalVarsBase::realtime,
            "Absolute time."
		)

		.def_readwrite("frame_count",
			&CGlobalVarsBase::framecount,
            "Absolute frame counter."
		)

		.def_readwrite("absolute_frame_time",
			&CGlobalVarsBase::absoluteframetime,
            "Non-paused frame time."
		)

		.def_readwrite("current_time",
			&CGlobalVarsBase::curtime,
            "Current time."
		)

		.def_readwrite("frame_time",
			&CGlobalVarsBase::frametime,
            "Time spent on last server or client frame (has nothing to do with think intervals)."
		)

		.def_readwrite("max_clients",
			&CGlobalVarsBase::maxClients,
            "Current maxplayers setting."
		)

		.def_readwrite("tick_count",
			&CGlobalVarsBase::tickcount,
            "Simulation ticks - does not increase when game is paused."
		)

		.def_readwrite("interval_per_tick",
			&CGlobalVarsBase::interval_per_tick,
            "Simulation tick interval."
		)

		.def_readwrite("interpolation_amount",
			&CGlobalVarsBase::interpolation_amount,
            "interpolation amount ( client-only ) based on fraction of next tick which has elapsed."
		)

		.def_readwrite("simulated_ticks_this_frame",
			&CGlobalVarsBase::simTicksThisFrame,
            "Simulation ticks of this frame."
		)

		.def_readwrite("network_protocol",
			&CGlobalVarsBase::network_protocol,
            "Network protocol."
		)

		.NOT_IMPLEMENTED("is_remote_client")
		
	) ADD_MEM_TOOLS(CGlobalVarsBase); // GlobalsBase_Visitor


	Globals_Visitor(

	class_< CGlobalVars, bases< CGlobalVarsBase> >("_GlobalVars", init<bool>())
		.add_property("map_name",
			make_getter(&CGlobalVars::mapname, return_value_policy<return_by_value>()),
            "Current map name."
		)

		.def_readwrite("map_version",
			&CGlobalVars::mapversion,
            "Current map version."
		)

		.add_property("start_spot",
			make_getter(&CGlobalVars::startspot, return_value_policy<return_by_value>()),
            "Start spot name."
		)

		.def_readwrite("load_type",
			&CGlobalVars::eLoadType,
            "How the current map was loaded."
		)

		.def_readwrite("map_load_failed",
			&CGlobalVars::bMapLoadFailed,
            "Failed to load map?"
		)

		.def_readwrite("is_deathmatch",
			&CGlobalVars::deathmatch,
            "Deathmatch enabled?"
		)

		.def_readwrite("is_coop",
			&CGlobalVars::coop,
            "Coop enabled?"
		)

		.def_readwrite("is_teamplay",
			&CGlobalVars::teamplay,
            "Teamplay enabled?"
		)

		.def_readwrite("max_entities",
			&CGlobalVars::maxEntities,
            "Maximum number of entities."
		)
		
		.NOT_IMPLEMENTED_ATTR("map_group_name")
		.NOT_IMPLEMENTED_ATTR("server_count")

	) ADD_MEM_TOOLS(CGlobalVars); // Globals_Visitor

	_globals.attr("global_vars") = object(ptr(gpGlobals));
}