Skip to content

Commit

Permalink
📚 Added scripting doc for console + cvars
Browse files Browse the repository at this point in the history
  • Loading branch information
ohlidalp committed Sep 1, 2021
1 parent 6bcbbad commit 1c746d0
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 24 deletions.
34 changes: 34 additions & 0 deletions doc/angelscript/CVarClass.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

/**
* @brief Types and special attributes of cvars.
* @note Default cvar type is string - To create a string cvar, enter '0' as flags.
*/
enum CVarFlags
{
CVAR_TYPE_BOOL = BITMASK(1),
CVAR_TYPE_INT = BITMASK(2),
CVAR_TYPE_FLOAT = BITMASK(3),
CVAR_ARCHIVE = BITMASK(4), //!< Will be written to RoR.cfg
CVAR_NO_LOG = BITMASK(5) //!< Will not be written to RoR.log
};

/**
* @brief A console variable, usually defined in RoR.cfg but also created by users or scripts.
*/
class CVarClass
{
public:

/**
* @brief Get the value converted to string, works with any CVAR_TYPE.
*/
std::string const& getStr() const { return m_value_str; }

float getFloat() const { return m_value_num; }

int getInt() const { return (int)m_value_num; }

bool getBool() const { return (bool)m_value_num; }

std::string const& getName() const { return m_name; }
};
35 changes: 35 additions & 0 deletions doc/angelscript/ConsoleClass.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@


/**
* @brief A class that gives you access to console variables (cvars), usually defined in RoR.cfg file.
* @note This object is created automatically as global variable `console`.
*/
class ConsoleClass
{
public:
/**
* @brief Add CVar and parse default value if specified
*/
CVar* cVarCreate(std::string const& name, std::string const& long_name,
int flags, std::string const& val = std::string());

/**
* Parse value by cvar type
*/
void cVarAssign(CVar* cvar, std::string const& value);

/**
* Find cvar by short/long name
*/
CVar* cVarFind(std::string const& input_name);

/**
* Set existing cvar by short/long name. Return the modified cvar (or NULL if not found)
*/
CVar* cVarSet(std::string const& input_name, std::string const& input_val);

/**
* Get cvar by short/long name, or create new one using input as short name.
*/
CVar* cVarGet(std::string const& input_name, int flags);
};
24 changes: 0 additions & 24 deletions doc/angelscript/SettingsClass.h

This file was deleted.

0 comments on commit 1c746d0

Please # to comment.