Reality Glitch
2/2 Zombie
Posts: 129
Color Alignment: White, Blue, Red, Green, Colorless
|
Post by Reality Glitch on Nov 21, 2023 2:08:44 GMT
tl;dr — This is what "center aligned" looks like, but the middle box is the default every card will have and the boxes before it trow off the alignment. I'm working on a template for the Flesh and Blood trading card game by Legend Story Studios, which has a center-aligned type box, and hit a non-favorable interaction between it and the combined_editor() function. I need to implement the combined_editor() in order for the card frame to react appropriately to the contents of the type box (without brute-forcing the code), but the center-alignment is measured from field1 instead of the entire combined field. Even if I could get it to center based on the entire field, there's the problem that it still registers not only each individual field, but the separators as well when calculating field width, even when all the component fields are empty, which offsets any that aren't, so it's never truly center unless only the first field is filled. Relying on hide_when_empty isn't an option, because it removes every field after the first one rather than only the last field and the middle field is the one that's the default which every card has. Even if I merged card types and supertypes like the M:tG template does, getting hybrid frames to look at only one side of a "/" (forward-slash) in the type box or the other is beyond my limited knowledge of M.S.E.'s code, so there's still the issue of the default field being the middle field. Tangentially related: I added in "soft_after_emptry: true," but that's being completely ignored (neither working, nor throwing up an error message), so I don't know what to do about that if I don't go the "supertype and card type on a shared word-list" route.
|
|
|
Post by cajun on Nov 21, 2023 2:56:57 GMT
how do Flesh and Blood typelines work. might be better to just code a workaround built for it.
|
|
Reality Glitch
2/2 Zombie
Posts: 129
Color Alignment: White, Blue, Red, Green, Colorless
|
Post by Reality Glitch on Nov 21, 2023 22:19:58 GMT
They are normally center-aligned and usually have a card type and a class and/or talent (collectively called "supertypes") with possible subtypes (separated by a long dash) and/or hybrid "talents + classes" (with each group of supertypes separated by a forward slash). There are some cards that have the "Weapon" and/or "Equipment" types in addition to another card type and a handful of D.F.C.'s without a talent but no card type on their back face, but "one type + one or two supertypes" is the default (especially since the supertype "Generic" is used for cards without classes or talents).
|
|
|
Post by cajun on Nov 22, 2023 12:39:25 GMT
k, some options 1. keep using the combined editor, but manually center it by using card_style.type.content_width and manually subtracting the excess width by checking when they're active (so when card.sub_types is empty, offset it by the invisible emdash's length) 2. divide these into three not-combined boxes, with "card type" as the main one and "super types" and "sub types" scripted to locate themselves based on that. 3. divide these into two not-combined boxes, "super types" and "card types", using a zero-width space to divide the two and have the two word list dropdowns available, and "sub types" for a specific example of #1, using made up numbers
manual_center_left_coord := { type_width := card_style.type.content_width ## 100 if remove_tags(card.sub_type) == "" then type_width := type_width - 25 ## subtract the length of invisible em dash else type_width := type_width - 5 ## subtract the length of the excess space maximum_type_width := 200 minimum_type_left := 30 ## the left: property when the type is max size offset := (maximum_type_width-type_width)/2 ## to center, we need this much on each size minimum_type_left + offset ## so starting here, @80, centers the text }
|
|
Reality Glitch
2/2 Zombie
Posts: 129
Color Alignment: White, Blue, Red, Green, Colorless
|
Post by Reality Glitch on Nov 24, 2023 8:26:36 GMT
k, some options 1. keep using the combined editor, but manually center it by using card_style.type.content_width and manually subtracting the excess width by checking when they're active (so when card.sub_types is empty, offset it by the invisible emdash's length) I wasn't quite sure where to put the example code; the actual block itself is in the script file, but "script: combined_editor(foobar) + manual_center_left_coord()" just adds the length as a string to the end of the rest of the field, and adding it to the "right:" field shrunk it by a static amount. I'm probably doing something wrong here, but the former attempt had me realize I could tell it to add extra spaces to the end of combined field only when the fields in front are blank, thus pushing everything to the left to compensate. It's something I wouldn't have realized was possible if I didn't try to implement your suggestion, so you still helped me, and I'm grateful for that. If it's not too much to add to this same thread, I have a tangentially related issue: the separator between the first and second fields is invisible when both are empty or just the second field is empty (which is part of what I want), but not when just the first field is empty (which I'd like to fix). I tried adding "soft_after_empty: true," to the combined_editor(), and it isn't throwing any errors at me, but neither does that line actually do any thing. I tried using and if/then/else statement in the separator field to remove it entirely, but that has a lag issue where it won't update until I make further input to that field.
|
|
|
Post by cajun on Nov 25, 2023 9:35:41 GMT
I wasn't quite sure where to put the example code; the actual block itself is in the script file, but "script: combined_editor(foobar) + manual_center_left_coord()" just adds the length as a string to the end of the rest of the field, and adding it to the "right:" field shrunk it by a static amount. I'm probably doing something wrong here, but the former attempt had me realize I could tell it to add extra spaces to the end of combined field only when the fields in front are blank, thus pushing everything to the left to compensate. It's something I wouldn't have realized was possible if I didn't try to implement your suggestion, so you still helped me, and I'm grateful for that. it's for "left:". that's why it's named manual center left coordinate. If it's not too much to add to this same thread, I have a tangentially related issue: the separator between the first and second fields is invisible when both are empty or just the second field is empty (which is part of what I want), but not when just the first field is empty (which I'd like to fix). I tried adding "soft_after_empty: true," to the combined_editor(), and it isn't throwing any errors at me, but neither does that line actually do any thing. I tried using and if/then/else statement in the separator field to remove it entirely, but that has a lag issue where it won't update until I make further input to that field. i'm not sure i get your problem. you want the dash to show up when you only have a subtype? idgi, but if that, do a supertype filter using a zero width space
card field: type: text name: super type script: super_type_filter(value)
zwsp := "" ## this is a zero-width space, an invisible character super_type_filter := { if input == "" or input == zwsp then zwsp ## if the super type is empty, make it a zwsp else replace(input, match:"{zwsp}", replace:"") ## otherwise, remove the zwsp } more_complicated_filter := { input := replace(input, match:"{zwsp}", replace:"") ## if you're doing other filter stuff already, start by removing the zwsp ## then do the other stuff here ## then check if it's empty at the end, you may need to remove tags if remove_tags(input) == "" ## empty, not zwsp then input := zwsp ## or "<word-list-foo>{zwsp}</word-list-foo>" or whatever it needs }
|
|
Reality Glitch
2/2 Zombie
Posts: 129
Color Alignment: White, Blue, Red, Green, Colorless
|
Post by Reality Glitch on Nov 26, 2023 0:24:27 GMT
If it's not too much to add to this same thread, I have a tangentially related issue: the separator between the first and second fields is invisible when both are empty or just the second field is empty (which is part of what I want), but not when just the first field is empty (which I'd like to fix). I tried adding "soft_after_empty: true," to the combined_editor(), and it isn't throwing any errors at me, but neither does that line actually do any thing. I tried using and if/then/else statement in the separator field to remove it entirely, but that has a lag issue where it won't update until I make further input to that field. i'm not sure i get your problem. you want the dash to show up when you only have a subtype? idgi, but if that, do a supertype filter using a zero width space Other way around; by default the dash shows when there is a subtype, even when there is not a type or supertype.
|
|
|
Post by cajun on Nov 26, 2023 2:18:25 GMT
change the separator parameter to if remove_tags(card.super_type) == "" then "" else "-"
|
|
Reality Glitch
2/2 Zombie
Posts: 129
Color Alignment: White, Blue, Red, Green, Colorless
|
Post by Reality Glitch on Nov 27, 2023 3:51:19 GMT
change the separator parameter to if remove_tags(card.super_type) == "" then "" else "-" I tried that; it works, but it won't update the separator until I further edit the type box after each time I add remove input from the subtype field. I'm guessing that's just something I have to live with?
|
|
|
Post by cajun on Nov 27, 2023 4:50:48 GMT
change the separator parameter to if remove_tags(card.super_type) == "" then "" else "-" I tried that; it works, but it won't update the separator until I further edit the type box after each time I add remove input from the subtype field. I'm guessing that's just something I have to live with? you have access to value which is the value of the combined typeline after the user edits it but before you do any extra edits to you. You can process that to determine how the separator should be handled rather than card.super_type
|
|
Reality Glitch
2/2 Zombie
Posts: 129
Color Alignment: White, Blue, Red, Green, Colorless
|
Post by Reality Glitch on Nov 27, 2023 7:01:17 GMT
I tried that; it works, but it won't update the separator until I further edit the type box after each time I add remove input from the subtype field. I'm guessing that's just something I have to live with? you have access to value which is the value of the combined typeline after the user edits it but before you do any extra edits to you. You can process that to determine how the separator should be handled rather than card.super_type Oh! Thank you! I’m pretty much exclusively self-taught from reverse engineering existing templates, so I don’t know all the intricacies of the programing language used. And thank you for your patience and for humoring my requests.
|
|
Reality Glitch
2/2 Zombie
Posts: 129
Color Alignment: White, Blue, Red, Green, Colorless
|
Post by Reality Glitch on Dec 1, 2023 2:58:27 GMT
Sorry to bother you again cajun, but I'm having trouble with how to implement the "value" variable properly. It started off simple enough: it's processing "contains()" and "not contains()" as though they were each other instead, but later I discovered that it'll flip back and forth between interpretations just from undoing and/or redo a change to the combined field's input. I tried resetting the cache, but that didn't clear the problem either. This is the code I'm currently working with. If the problem isn't in this section I'm at a complete loss as to where to look next. combined_editor( field1: card.hybrid_supertype, separator1: ( if contains(value, match: remove_tags(card.hybrid_supertype)) then if contains(value, match: remove_tags(card.base_supertype)) then " " else language().zwsp else "/ " ), field2: card.base_supertype, separator2: ( if contains(value, match: remove_tags(card.type)) then " " else language().zwsp ), field3: card.type, separator3: if contains(value, match: remove_tags(card.hybrid_supertype)) and contains(value, match: remove_tags(card.base_supertype)) and contains(value, match: remove_tags(card.type)) then " " else "- ", field4: card.subtype, soft_before_empty: true, hide_when_empty: false )
|
|