Merge remote-tracking branch 'haganbmj/master' into clear-console

This commit is contained in:
Brendan Hagan
2022-07-01 21:00:57 -04:00
4 changed files with 52 additions and 2 deletions
+22 -1
View File
@@ -382,6 +382,26 @@ SCRIPT_FUNCTION(count_chosen) {
SCRIPT_RETURN(count);
}
}
}
// ----------------------------------------------------------------------------- : Extra Card Fields
SCRIPT_FUNCTION(extra_data) {
SCRIPT_PARAM_C(String, input);
SCRIPT_PARAM_C(CardP, card);
SCRIPT_PARAM_C(StyleSheetP, stylesheet);
// Transform input to standard field name syntax.
// Other functions are doing lookups for ValuePs, which I assume is doing some of this automatically.
String canonical_field_name = canonical_name_form(input);
FOR_EACH(valueP, card->extraDataFor(*stylesheet)) {
if (valueP->fieldP->name == canonical_field_name) {
SCRIPT_RETURN(valueP);
}
}
return delay_error(ScriptErrorNoMember("extra_data()", input));
}
// ----------------------------------------------------------------------------- : Init
@@ -395,5 +415,6 @@ void init_script_editor_functions(Context& ctx) {
ctx.setVariable(_("require_choice"), script_require_choice);
ctx.setVariable(_("exclusive_choice"), script_exclusive_choice);
ctx.setVariable(_("require_exclusive_choice"), script_require_exclusive_choice);
ctx.setVariable(_("remove_choice"), script_remove_choice);
ctx.setVariable(_("remove_choice"), script_remove_choice);
ctx.setVariable(_("extra_data"), script_extra_data);
}