1
0

Lua plugin cColor (#3833)

This commit is contained in:
Lane Kolbly 2017-07-12 05:30:43 -05:00 committed by Lukas Pioch
parent 793acd267f
commit b61898c30c
5 changed files with 202 additions and 6 deletions

View File

@ -1730,6 +1730,178 @@ end
},
},
},
cColor =
{
Desc = [[
Encapsulates a RGB color, e.g. for armor.
]],
Functions =
{
Clear =
{
Notes = "Resets the color to uninitialized."
},
constructor =
{
{
Returns = { {Type="cColor"} },
Notes = "Creates an uninitialized cColor. Each component must be between 0 and 255, inclusive.",
},
{
Params =
{
{
Name = "Red",
Type = "number",
},
{
Name = "Green",
Type = "number",
},
{
Name = "Blue",
Type = "number",
},
},
Returns = { {Type="cColor"} },
Notes = "Creates the specified cColor. All components must be between 0 and 255, inclusive.",
},
},
GetColor =
{
Returns =
{
{
Name = "Red",
Type = "number",
},
{
Name = "Green",
Type = "number",
},
{
Name = "Blue",
Type = "number",
},
},
Notes = "Returns the color's red, green, and blue components, respectively."
},
GetRed =
{
Returns =
{
{
Name = "Red",
Type = "number",
},
},
Notes = "Returns the color's red component."
},
GetGreen =
{
Returns =
{
{
Name = "Green",
Type = "number",
},
},
Notes = "Returns the color's green component."
},
GetBlue =
{
Returns =
{
{
Name = "Blue",
Type = "number",
},
},
Notes = "Returns the color's blue component."
},
IsValid =
{
Returns =
{
{
Type = "boolean"
},
},
Notes = "True if the color is valid, false if the color has not been set yet."
},
SetColor =
{
Params =
{
{
Name = "Red",
Type = "number"
},
{
Name = "Green",
Type = "number"
},
{
Name = "Blue",
Type = "number"
},
},
Notes = "Sets the color's red, green, and blue components. Values range from 0 to 255."
},
SetRed =
{
Params =
{
{
Name = "Red",
Type = "number",
},
},
Notes = "Sets the color's red component. Must be between 0 and 255, inclusive."
},
SetGreen =
{
Params =
{
{
Name = "Green",
Type = "number",
},
},
Notes = "Sets the color's green component. Must be between 0 and 255, inclusive."
},
SetBlue =
{
Params =
{
{
Name = "Blue",
Type = "number",
},
},
Notes = "Sets the color's blue component. Must be between 0 and 255, inclusive."
},
},
Constants =
{
COLOR_LIMIT =
{
Notes = "The upper bound (exclusive) for a color component",
},
COLOR_MAX =
{
Notes = "The maximum value for a color component",
},
COLOR_MIN =
{
Notes = "The minimum value for a color component",
},
COLOR_NONE =
{
Notes = "A constant denoting the color is invalid (note: use IsValid)",
},
},
},
cCompositeChat =
{
Desc = [[

View File

@ -46,6 +46,7 @@ $cfile "../StringUtils.h"
$cfile "../Defines.h"
$cfile "../ChatColor.h"
$cfile "../ClientHandle.h"
$cfile "../Color.h"
$cfile "../EffectID.h"
$cfile "../Server.h"
$cfile "../World.h"

View File

@ -89,6 +89,7 @@ set(BINDING_DEPENDENCIES
../ChatColor.h
../ChunkDef.h
../ClientHandle.h
../Color.h
../CompositeChat.h
../CraftingRecipes.h
../Cuboid.h

View File

@ -3297,6 +3297,24 @@ static int tolua_cChunkDesc_GetBlockTypeMeta(lua_State * a_LuaState)
static int tolua_cColor_GetColor(lua_State * tolua_S)
{
cLuaState L(tolua_S);
cColor * self;
if (!L.CheckParamSelf("cColor") || !L.GetStackValue(1, self))
{
return 0;
}
L.Push(self->GetRed(), self->GetGreen(), self->GetBlue());
return 3;
}
static int tolua_cCompositeChat_new(lua_State * a_LuaState)
{
/* Function signatures:
@ -3727,6 +3745,10 @@ void cManualBindings::Bind(lua_State * tolua_S)
tolua_function(tolua_S, "SendPluginMessage", tolua_cClientHandle_SendPluginMessage);
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cColor");
tolua_function(tolua_S, "GetColor", tolua_cColor_GetColor);
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cCompositeChat");
tolua_function(tolua_S, "new", tolua_cCompositeChat_new);
tolua_function(tolua_S, "new_local", tolua_cCompositeChat_new_local);

View File

@ -9,13 +9,12 @@
#pragma once
// tolua_begin
// tolua_begin
class cColor
{
public:
enum : unsigned int
enum eColorLimits : unsigned int
{
COLOR_MIN = 0,
COLOR_MAX = 255,
@ -28,6 +27,7 @@ public:
/** Returns whether the color is a valid color */
bool IsValid() const { return m_Color != COLOR_NONE; }
/** Changes the color */
void SetColor(unsigned char a_Red, unsigned char a_Green, unsigned char a_Blue);
@ -35,10 +35,10 @@ public:
void SetRed(unsigned char a_Red);
/** Alters the green value of the color */
void SetGreen(unsigned char a_Red);
void SetGreen(unsigned char a_Green);
/** Alters the blue value of the color */
void SetBlue(unsigned char a_Red);
void SetBlue(unsigned char a_Blue);
/** Returns the red value of the color */
unsigned char GetRed() const;
@ -55,4 +55,4 @@ public:
unsigned int m_Color;
};
}; // tolua_export