supertux
Public Member Functions | List of all members
SquirrelEnvironment Class Reference

The SquirrelEnvironment contains the environment in which a script is executed, meaning a root table containing objects and variables. More...

#include <squirrel_environment.hpp>

Public Member Functions

 SquirrelEnvironment (SquirrelVM &vm, const std::string &name)
 
SquirrelVMget_vm () const
 
void expose_self ()
 Expose this engine under 'name'.
 
void unexpose_self ()
 
void try_expose (GameObject &object)
 Expose the GameObject if it has a ScriptInterface, otherwise do nothing. More...
 
void try_unexpose (GameObject &object)
 
template<typename T >
void expose (const std::string &name, std::unique_ptr< T > script_object)
 Generic expose function, T must be a type that has a create_squirrel_instance() associated with it. More...
 
void unexpose (const std::string &name)
 
void run_script (const std::string &script, const std::string &sourcename)
 Convenience function that takes an std::string instead of an std::istream&.
 
void run_script (std::istream &in, const std::string &sourcename)
 Runs a script in the context of the SquirrelEnvironment (m_table will be the roottable of this squirrel VM) and keeps a reference to the script so the script gets destroyed when the SquirrelEnvironment is destroyed). More...
 
void update (float dt_sec)
 
void wait_for_seconds (HSQUIRRELVM vm, float seconds)
 

Detailed Description

The SquirrelEnvironment contains the environment in which a script is executed, meaning a root table containing objects and variables.

Member Function Documentation

§ expose()

template<typename T >
void SquirrelEnvironment::expose ( const std::string &  name,
std::unique_ptr< T >  script_object 
)
inline

Generic expose function, T must be a type that has a create_squirrel_instance() associated with it.

§ run_script()

void SquirrelEnvironment::run_script ( std::istream &  in,
const std::string &  sourcename 
)

Runs a script in the context of the SquirrelEnvironment (m_table will be the roottable of this squirrel VM) and keeps a reference to the script so the script gets destroyed when the SquirrelEnvironment is destroyed).

§ try_expose()

void SquirrelEnvironment::try_expose ( GameObject object)

Expose the GameObject if it has a ScriptInterface, otherwise do nothing.


The documentation for this class was generated from the following files: