summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/spell-language3
-rw-r--r--src/map/magic-expr.c8
2 files changed, 11 insertions, 0 deletions
diff --git a/doc/spell-language b/doc/spell-language
index d5a798a..5ce5520 100644
--- a/doc/spell-language
+++ b/doc/spell-language
@@ -422,6 +422,9 @@ The following functions are available:
+ not : int -> int
Logical negation. (NOT bitwise negation.)
+ + neg : int -> int
+ Bitwise negation.
+
+ name_of : entity -> string
| spell -> string
Retrieves the name either of an entity or of a spell.
diff --git a/src/map/magic-expr.c b/src/map/magic-expr.c
index 04e5e60..d22e596 100644
--- a/src/map/magic-expr.c
+++ b/src/map/magic-expr.c
@@ -312,6 +312,13 @@ fun_not(env_t *env, int args_nr, val_t *result, val_t *args)
}
static int
+fun_neg(env_t *env, int args_nr, val_t *result, val_t *args)
+{
+ RESULTINT = ~ARGINT(0);
+ return 0;
+}
+
+static int
fun_gte(env_t *env, int args_nr, val_t *result, val_t *args)
{
if (TY(0) == TY_STRING || TY(1) == TY_STRING) {
@@ -1028,6 +1035,7 @@ static fun_t functions[] = {
{ "<<", "ii", 'i', fun_bitshl },
{ ">>", "ii", 'i', fun_bitshr },
{ "not", "i", 'i', fun_not },
+ { "neg", "i", 'i', fun_neg },
{ "max", "ii", 'i', fun_max },
{ "min", "ii", 'i', fun_min },
{ "is_in", "la", 'i', fun_is_in },