summaryrefslogtreecommitdiff
path: root/src/scripting
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2013-06-08 18:31:30 +0200
committerErik Schilling <ablu.erikschilling@googlemail.com>2013-08-26 22:56:47 +0200
commit1e5a15c0a5e24fb4b358fff75a7082d65496e1f9 (patch)
tree741756128a3587768fa02dbbdd9ba64820afe6cb /src/scripting
parent44ee071d7ece5a2023f79307f36e8a244c9e7b3a (diff)
downloadmanaserv-1e5a15c0a5e24fb4b358fff75a7082d65496e1f9.tar.gz
manaserv-1e5a15c0a5e24fb4b358fff75a7082d65496e1f9.tar.bz2
manaserv-1e5a15c0a5e24fb4b358fff75a7082d65496e1f9.tar.xz
manaserv-1e5a15c0a5e24fb4b358fff75a7082d65496e1f9.zip
Readded level handling
Things done: Wrote a entity:give_experience function (lua side only). Renamed characterpoints to attributepoints (no db update. Did not want to do one for a simple rename). Temponary introduced a ATTR_LEVEL constant. TODO: dehardcode this. Script binds for settings the correction and attribute points.
Diffstat (limited to 'src/scripting')
-rw-r--r--src/scripting/lua.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index 624fbda1..13373d81 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -1838,6 +1838,68 @@ static int entity_remove_attribute_modifier(lua_State *s)
return 0;
}
+/** LUA entity:attribute_points (being)
+ * entity:attribute_points()
+ **
+ * Valid only for character entities.
+ *
+ * *Returns:* Returns the amount of available attribute points.
+ */
+static int entity_attribute_points(lua_State *s)
+{
+ Entity *being = checkCharacter(s, 1);
+ auto *characterComponent = being->getComponent<CharacterComponent>();
+ lua_pushinteger(s, characterComponent->getAttributePoints());
+ return 1;
+}
+
+/** LUA entity:set_attribute_points (being)
+ * entity:set_attribute_points(int amount)
+ **
+ * Valid only for character entities.
+ *
+ * Sets the amount of attribute points for the entity
+ */
+static int entity_set_attribute_points(lua_State *s)
+{
+ Entity *being = checkCharacter(s, 1);
+ int points = luaL_checkint(s, 2);
+ auto *characterComponent = being->getComponent<CharacterComponent>();
+ characterComponent->setAttributePoints(points);
+ return 0;
+}
+
+/** LUA entity:correction_points (being)
+ * entity:correction_points()
+ **
+ * Valid only for character entities.
+ *
+ * *Returns:* Returns the amount of available correction points.
+ */
+static int entity_correction_points(lua_State *s)
+{
+ Entity *being = checkCharacter(s, 1);
+ auto *characterComponent = being->getComponent<CharacterComponent>();
+ lua_pushinteger(s, characterComponent->getCorrectionPoints());
+ return 1;
+}
+
+/** LUA entity:set_correction_points (being)
+ * entity:set_correction_points(int amount)
+ **
+ * Valid only for character entities.
+ *
+ * Sets the amount of correction points for the entity
+ */
+static int entity_set_correction_points(lua_State *s)
+{
+ Entity *being = checkCharacter(s, 1);
+ int points = luaL_checkint(s, 2);
+ auto *characterComponent = being->getComponent<CharacterComponent>();
+ characterComponent->setCorrectionPoints(points);
+ return 0;
+}
+
/** LUA entity:gender (being)
* entity:gender()
**
@@ -3350,6 +3412,10 @@ LuaScript::LuaScript():
{ "modified_attribute", entity_get_modified_attribute },
{ "apply_attribute_modifier", entity_apply_attribute_modifier },
{ "remove_attribute_modifier", entity_remove_attribute_modifier },
+ { "attribute_points", entity_attribute_points },
+ { "set_attribute_points", entity_set_attribute_points },
+ { "correction_points", entity_correction_points },
+ { "set_correction_points", entity_set_correction_points },
{ "gender", entity_get_gender },
{ "set_gender", entity_set_gender },
{ "hair_color", entity_get_hair_color },