|
Post by khluxaeterna on Jan 8, 2021 0:07:11 GMT
Greetings all! I hope 2021 finds you well. So I've been working on improving a Yu-Gi-Oh template, and I wanted to make a style for Rush Duels, Problem is, the monster Levels are rendered as a single number in the Rush style, as opposed to the stars the regular styles use and I want it to be able to convert properly when switching styles. card field: type: text name: rush_level description: `=] * = no. of level script: to_int(number_of_items(in: level_filter(value) ) ) I attempted to use these functions to try "counting the stars" and matching the resulting value with the symbol font to generate the number image, but it hasn't been working as intended. I should mention I have no actual coding experience, so maybe there's an obvious solution I'm not seeing. 
|
|
|
Post by cajun on Jan 8, 2021 3:29:37 GMT
if contains(value, match:"*") then len(value) else value should convert a string of ****s into its number; for a true converting back and forth you'd need a value that tells which type to return though, something like
if render_as_number() then
if contains(value, match:"*") then len(value) else value
else
if contains(value, match:"*") then value else for x from 1 to value do "*" where render_as_number := false in the main script, and := true in the style file of this specific template.
|
|
|
Post by khluxaeterna on Jan 8, 2021 11:46:25 GMT
Hi cajun! Thank you for your quick reply.
Forgot to mention I have the Rush Levels as a separate card field from the regular Levels. Would I need to make them a single field for those codes and where should I place them?
|
|
|
Post by cajun on Jan 10, 2021 10:11:29 GMT
Hi cajun! Thank you for your quick reply.
Forgot to mention I have the Rush Levels as a separate card field from the regular Levels. Would I need to make them a single field for those codes and where should I place them?
if rush_level is a different field then you can script it as
default: len(card.levels) or whatever the field name of the normal levels is. then if you change a card to this, it will convert to that number, and if you have a new card on this, you can type in the number
|
|
|
Post by khluxaeterna on Jan 14, 2021 17:47:55 GMT
I believe I got that done right, but now I keep getting a console error and I'm not quite sure what the problem is:
Variable not set: len
while updating card value 'rush_level'
I've attached my 'script' and 'card_field' files as well as the "style" file for the Rush template.
Your assistance so far is greatly appreciated! Attachments:card_fields (13.54 KB)
script (9.8 KB)
style (44.59 KB)
|
|
|
Post by cajun on Jan 14, 2021 22:39:12 GMT
I believe I got that done right, but now I keep getting a console error and I'm not quite sure what the problem is:
Variable not set: len
while updating card value 'rush_level'
I've attached my 'script' and 'card_field' files as well as the "style" file for the Rush template.
Your assistance so far is greatly appreciated! oh my mistake, the function is length for MSE, not len
|
|
|
Post by khluxaeterna on Jan 15, 2021 0:34:50 GMT
An easy mistake.  Corrected it, and now it says this
Can't convert from string ("") to collection
in function length
while updating card value 'rush_level'
So far, attempting to convert a single * from the regular style results in a string of *s instead of a number in the Rush style, vice versa doesn't seem to do anything.
Related question: does linking the fields in the style files like this do anything?
level := { card.rush_level }
|
|
|
Post by cajun on Jan 15, 2021 21:14:47 GMT
An easy mistake.  Corrected it, and now it says this
Can't convert from string ("") to collection
in function length
while updating card value 'rush_level'
So far, attempting to convert a single * from the regular style results in a string of *s instead of a number in the Rush style, vice versa doesn't seem to do anything.
Related question: does linking the fields in the style files like this do anything?
level := { card.rush_level }
uhhhh weird
for that second thing, that will make "level()" return card.rush_level, it will have no effect on card.level
|
|
|
Post by khluxaeterna on Jan 16, 2021 22:05:10 GMT
Sorry, I was using version 2.0.1. Updated it and there's no console error, but it still does as I described in my last post.
Gonna try making them a single field, and fix the scripts to render the symbol fonts properly for each style.
|
|