mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-30 00:37:58 +03:00
Add __tostring metamethod to GameScriptPosition, GameScriptRotation and GameScriptColor.
Make their properties lowercase to keep them consistent with the properties of other classes. Move documentation from GameScriptPosition.h to GameScriptPosition.cpp.
This commit is contained in:
parent
b264099ff1
commit
dbe6ffdd5c
6 changed files with 82 additions and 40 deletions
|
@ -3,16 +3,39 @@
|
|||
#include <sol.hpp>
|
||||
#include "phd_global.h"
|
||||
|
||||
/***
|
||||
Represents a position in the game world.
|
||||
@classmod Position
|
||||
@pragma nostrip
|
||||
*/
|
||||
|
||||
void GameScriptPosition::Register(sol::state* state)
|
||||
{
|
||||
state->new_usertype<GameScriptPosition>("Position",
|
||||
sol::constructors<GameScriptPosition(int, int, int)>(),
|
||||
"X", &GameScriptPosition::x,
|
||||
"Y", &GameScriptPosition::y,
|
||||
"Z", &GameScriptPosition::z
|
||||
sol::meta_function::to_string, &GameScriptPosition::ToString,
|
||||
|
||||
/// (int) x coordinate
|
||||
//@mem x
|
||||
"x", &GameScriptPosition::x,
|
||||
/// (int) y coordinate
|
||||
//@mem y
|
||||
|
||||
"y", &GameScriptPosition::y,
|
||||
/// (int) z coordinate
|
||||
//@mem z
|
||||
|
||||
"z", &GameScriptPosition::z
|
||||
);
|
||||
}
|
||||
|
||||
/***
|
||||
@int X x coordinate
|
||||
@int Y y coordinate
|
||||
@int Z z coordinate
|
||||
@return A Position object.
|
||||
@function Position.new
|
||||
*/
|
||||
GameScriptPosition::GameScriptPosition(int aX, int aY, int aZ)
|
||||
{
|
||||
x = aX;
|
||||
|
@ -34,3 +57,13 @@ void GameScriptPosition::StoreInPHDPos(PHD_3DPOS& pos) const
|
|||
pos.zPos = z;
|
||||
}
|
||||
|
||||
/***
|
||||
@tparam Position position this position
|
||||
@treturn string A string showing the x, y, and z values of the position
|
||||
@function __tostring
|
||||
*/
|
||||
std::string GameScriptPosition::ToString() const
|
||||
{
|
||||
return "{" + std::to_string(x) + ", " + std::to_string(y) + ", " + std::to_string(z) + "}";
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue