mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Merge pull request #10 from G-e-n-e-v-e-n-s-i-S/get-card-styling
add get_card_styling function for export scripts
This commit is contained in:
@@ -0,0 +1,17 @@
|
|||||||
|
Function: get_card_styling
|
||||||
|
|
||||||
|
--Usage--
|
||||||
|
> get_card_styling(card, set: set)
|
||||||
|
|
||||||
|
Get the styling data of a [[type:card]].
|
||||||
|
|
||||||
|
This is for use in exporter scripts. In card scripts, use the "styling" predefined variable instead.
|
||||||
|
|
||||||
|
--Parameters--
|
||||||
|
! Parameter Type Description
|
||||||
|
| @input@ [[type:card]] The card you want to retrieve the styling data 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 value "is foil" from the card's styling options
|
||||||
|
> card_is_foil := get_card_styling(card)["is_foil"] or else false
|
||||||
@@ -97,6 +97,7 @@ These functions are built into the program, other [[type:function]]s can be defi
|
|||||||
|
|
||||||
! Cards <<<
|
! Cards <<<
|
||||||
| [[fun:new_card]] Construct a new [[type:card]] object.
|
| [[fun:new_card]] Construct a new [[type:card]] object.
|
||||||
|
| [[fun:get_card_styling]] Get the styling data of a [[type:card]].
|
||||||
|
|
||||||
! HTML export <<<
|
! HTML export <<<
|
||||||
| [[fun:to_html]] Convert [[type:tagged text]] to html.
|
| [[fun:to_html]] Convert [[type:tagged text]] to html.
|
||||||
|
|||||||
@@ -662,6 +662,17 @@ SCRIPT_FUNCTION(random_select_many) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCRIPT_FUNCTION(get_card_styling) {
|
||||||
|
SCRIPT_PARAM_C(ScriptValueP, input);
|
||||||
|
SCRIPT_PARAM_C(ScriptValueP, set);
|
||||||
|
ScriptObject<CardP>* c = dynamic_cast<ScriptObject<CardP>*>(input.get());
|
||||||
|
ScriptObject<Set*>* s = dynamic_cast<ScriptObject<Set*>*>(set.get());
|
||||||
|
if (s && c) {
|
||||||
|
return to_script(&s->getValue()->stylingDataFor(c->getValue()));
|
||||||
|
}
|
||||||
|
throw ScriptError(_("invalid set or card argument"));
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Keywords
|
// ----------------------------------------------------------------------------- : Keywords
|
||||||
|
|
||||||
|
|
||||||
@@ -747,7 +758,8 @@ void init_script_basic_functions(Context& ctx) {
|
|||||||
ctx.setVariable(_("to_color"), script_to_color);
|
ctx.setVariable(_("to_color"), script_to_color);
|
||||||
ctx.setVariable(_("to_date"), script_to_date);
|
ctx.setVariable(_("to_date"), script_to_date);
|
||||||
ctx.setVariable(_("to_code"), script_to_code);
|
ctx.setVariable(_("to_code"), script_to_code);
|
||||||
ctx.setVariable(_("type_name"), script_type_name);
|
ctx.setVariable(_("type_name"), script_type_name);
|
||||||
|
ctx.setVariable(_("get_card_styling"), script_get_card_styling);
|
||||||
// math
|
// math
|
||||||
ctx.setVariable(_("abs"), script_abs);
|
ctx.setVariable(_("abs"), script_abs);
|
||||||
ctx.setVariable(_("random_real"), script_random_real);
|
ctx.setVariable(_("random_real"), script_random_real);
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ $built_in_functions = array(
|
|||||||
'filter_list' =>'',
|
'filter_list' =>'',
|
||||||
'random_shuffle' =>'',
|
'random_shuffle' =>'',
|
||||||
'random_select' =>'',
|
'random_select' =>'',
|
||||||
'random_select_many' =>'',
|
'random_select_many' =>'',
|
||||||
|
'get_card_styling' =>'',
|
||||||
// keywords
|
// keywords
|
||||||
'expand_keywords' =>'', 'expand_keywords_rule'=>'expand_keywords',
|
'expand_keywords' =>'', 'expand_keywords_rule'=>'expand_keywords',
|
||||||
'keyword_usage' =>'',
|
'keyword_usage' =>'',
|
||||||
@@ -232,4 +233,4 @@ function highlight_script_string($code) {
|
|||||||
return $code;
|
return $code;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user