Skip to content

Commit

Permalink
Script: Add the ^class* system variable
Browse files Browse the repository at this point in the history
  • Loading branch information
dscharrer committed Jan 13, 2022
1 parent 03b94e9 commit 2c3616f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -26,6 +26,7 @@ Modding:
* Added support for having more than 20 spells active
* Added the ^angleto_… system variable returning the the direction to another entity
* Added the ^caster* system variable to get the caster of the given spell or summoned entity
* Added the ^class* system variable to get the class name of the given entity or spell
* Added the ^hover system variable returning the entity under the mouse cursor
* Added the ^onscreen* and ^offscreen* system variables to determine if an entity is shown on screen (feature request #1593)
* Added the ^spell* system variable to get the ID of the newest active spell cast by the given entity
Expand Down
10 changes: 10 additions & 0 deletions src/script/Script.cpp
Expand Up @@ -994,6 +994,16 @@ ValueType getSystemVar(const script::Context & context, std::string_view name,
return TYPE_TEXT;
}

if(name == "^class") {
txtcontent = context.getEntity() ? context.getEntity()->className() : "";
return TYPE_TEXT;
}

if(name == "^class" || boost::starts_with(name, "^class_")) {
txtcontent = EntityId(name.substr(7)).className();
return TYPE_TEXT;
}

break;
}

Expand Down

0 comments on commit 2c3616f

Please sign in to comment.