Files
MagicSetEditor2/doc/function/new_card.txt
T
2025-08-07 18:45:12 +02:00

33 lines
1.5 KiB
Plaintext

Function: new_card
--Usage--
> new_card(map_of_field_names_to_values)
Creates a new [[type:card]] object. The card is not automatically added to a set. Use the [[fun:add_card_to_set]] function for that.
The argument is a map from card field names to values, for example @new_card([name: "My Card"])@ creates a card with the name @"My Card"@, and all other fields at their default value.
The map can also contain the following built-in keys: notes, id, linked_card_1 to linked_card_4, linked_relation_1 to linked_relation_4, stylesheet, styling_data, and extra_data. For styling_data and extra_data, the value must itself be a map from field names to values. Be sure to define a stylesheet before these.
NOTE: you should use underscores instead of spaces in field names.
--Parameters--
! Parameter Type Description
| @input@ [[type:map]] of field names to field values Field values to set
| @ignore_field_not_found@ [[type:boolean]] Optional. If set to true, key/value pairs that don't correspond to a field will be ignored instead of throwing.
--Examples--
> # Create a new card
> my_card := new_card(
> [ name: "My Card"
>> , rule_text: "This card is <i>mine</i>!"
>> , stylesheet: "magic-m15-adventure.mse-style"
>> , styling_data: [frames: "Reversed, vehicle", chop_main: "5,5"]
> ])
>
> # Write an image of the card to a file
> write_image_file(my_card, file: "my_card.png")
> # Add the card to the current set
> add_card_to_set(my_card)