diff --git a/doc/function/get_card_stylesheet.txt b/doc/function/get_card_stylesheet.txt new file mode 100644 index 00000000..d1d74502 --- /dev/null +++ b/doc/function/get_card_stylesheet.txt @@ -0,0 +1,17 @@ +Function: get_card_stylesheet + +--Usage-- +> get_card_stylesheet(card, set: set) + +Get the stylesheet of a [[type:card]]. + +This is for use in exporter scripts. In card scripts, use the "stylesheet" predefined variable instead. + +--Parameters-- +! Parameter Type Description +| @input@ [[type:card]] The card you want to retrieve the stylesheet from. +| @set@ [[type:set]] The set the card belongs to. In an exporter script, this can be ommited since "set" is a predefined variable. + +--Examples-- +> # Retrieve the card regions from the card's stylesheet +> card_regions := get_card_stylesheet(card).card_regions diff --git a/doc/function/index.txt b/doc/function/index.txt index 5613a740..fd30267e 100644 --- a/doc/function/index.txt +++ b/doc/function/index.txt @@ -99,6 +99,7 @@ These functions are built into the program, other [[type:function]]s can be defi ! Cards <<< | [[fun:new_card]] Construct a new [[type:card]] object. | [[fun:get_card_styling]] Get the styling data of a [[type:card]]. +| [[fun:get_card_styesheet]] Get the stylesheet of a [[type:card]]. ! HTML export <<< | [[fun:to_html]] Convert [[type:tagged text]] to html. diff --git a/src/script/functions/basic.cpp b/src/script/functions/basic.cpp index c6b16795..1f57bfb1 100644 --- a/src/script/functions/basic.cpp +++ b/src/script/functions/basic.cpp @@ -680,6 +680,17 @@ SCRIPT_FUNCTION(get_card_styling) { throw ScriptError(_("invalid set or card argument")); } +SCRIPT_FUNCTION(get_card_stylesheet) { + SCRIPT_PARAM_C(ScriptValueP, input); + SCRIPT_PARAM_C(ScriptValueP, set); + ScriptObject* c = dynamic_cast*>(input.get()); + ScriptObject* s = dynamic_cast*>(set.get()); + if (s && c) { + return to_script(&s->getValue()->stylesheetFor(c->getValue())); + } + throw ScriptError(_("invalid set or card argument")); +} + // ----------------------------------------------------------------------------- : Keywords @@ -768,6 +779,7 @@ void init_script_basic_functions(Context& ctx) { ctx.setVariable(_("to_code"), script_to_code); ctx.setVariable(_("type_name"), script_type_name); ctx.setVariable(_("get_card_styling"), script_get_card_styling); + ctx.setVariable(_("get_card_stylesheet"), script_get_card_stylesheet); // math ctx.setVariable(_("abs"), script_abs); ctx.setVariable(_("random_real"), script_random_real); diff --git a/tools/website/drupal/mse-drupal-modules/highlight.inc b/tools/website/drupal/mse-drupal-modules/highlight.inc index 26dae510..8c1b0ba7 100644 --- a/tools/website/drupal/mse-drupal-modules/highlight.inc +++ b/tools/website/drupal/mse-drupal-modules/highlight.inc @@ -49,7 +49,8 @@ $built_in_functions = array( 'random_shuffle' =>'', 'random_select' =>'', 'random_select_many' =>'', - 'get_card_styling' =>'', + 'get_card_styling' =>'', + 'get_card_stylesheet' =>'', // keywords 'expand_keywords' =>'', 'expand_keywords_rule'=>'expand_keywords', 'keyword_usage' =>'',