Need some help with Fonts and Scripting [Resolved]

Login or register to post comments
Mon, 2017-05-15 18:59
Mahx Michael
Mahx Michael's picture

Hello again A happy smile
I have two independant questions this time:

1) Do anyone recognize this font?

Spoiler:



The symbols 1, 3, B and C might be the ones to give it away.
What tecniques does other template makers use to recognize and find text fonts?

2) Can you help me out with this script?
I want to make script that provides automatic card numbers, like in the magic template, only for a Cardfight Vanguard game/style template. The script magic uses is so complex and advanced that I struggle with unraveling it so that it can become a simple numbering system that are adapted to the new game.
The script magic uses filters out tokens and counters and orders the cards after shape, color, type, rarity etc. but Cardfight Vanguard uses very different shapes and values than magic.
For example, the color of the card is based on wich clan it is in. The only shapes as of now is a normal and a two faced for «legion». The type field would most likely be clan name then race, and rarity is a string of letters instead of a selection choice.
Could you help me write a siple numbering system, without too much filters and sorting?

Mon, 2017-05-15 20:18
Cajun
Cajun's picture

There are font id sites like WhatTheFont and FontSquirrel's matcherator. Using that looks like it's Adelon Serial.

2 I'll need to look at better in a bit. Not familiar with Vanguard so not sure what you want the end result to be.

Looks like [SetCode]/[Card#][Language] [Rarity] for the code, not much different from Magic's. That sorting system looks ugly though, 24(?) clans to account for and the grade sorting as well.

For Clans you'll want to copy the sort_name and redefine the sorting index, something to the tune of

clan_sort := {
	if card.clan == "Royal Paladin" then "CA"
	else if card.clan == "Oracle Think Tank" then "CB"
}

another one for rarity
rarity_sort := {
	if card.rarity == "RRR" then "A"
}
and a similar one for the grade, which seems to just go 0-3. You can either do the same,
grade_sort :=
{if card.grade == 3 then "A"}
etc, or it can get more wiggle room by using (9 - card.grade) which lets you scale up to grade 9.
Last bit is the filter, for promos or whatever doesn't belong in this collection. You should be able to adapt the existing to your Special and other shape if need be.

Put them together as

card_number := {
	position (
		of: card
		in: set
		order_by: { clan_sort() + rarity_sort() + grade_sort() + sort_name(card.name) }
		filter:   set_filter()
	) + 1

Then your set code is set.set_code + "/" + card_number() + set.set_language + " " + card.rarity

Cajun's Explorations
Planeswalker Template Overhaul
fluffyDeathbringer wrote:
I dunno, Cajun has a habit of doing Dubiously Working new rules stuff

Tue, 2017-05-16 10:34
Mahx Michael
Mahx Michael's picture

The clans are also text strings. Is it possible to put all the string values together and sort them with name sort?
Also, where can I safely download fonts that are not already installed on my computer?

Tue, 2017-05-16 14:54
Cajun
Cajun's picture

Quote:
The clans are also text strings. Is it possible to put all the string values together and sort them with name sort?
Are you sorting the clans alphabetically? Sounds like the only reason you'd want to do that.

Quote:
Also, where can I safely download fonts that are not already installed on my computer?
Google your font and find not-sketchy sites? I mostly stick with cooltext cause it's got more unusual fonts and has the logos built in. One I linked seems fine, FontSquirrel's got free fonts, etc.

Cajun's Explorations
Planeswalker Template Overhaul
fluffyDeathbringer wrote:
I dunno, Cajun has a habit of doing Dubiously Working new rules stuff

Tue, 2017-05-16 17:07
Mahx Michael
Mahx Michael's picture

Quote:
Are you sorting the clans alphabetically?

Is there another pattern that is more common?
How does the sorting system work, actually? I might have imagined something else. I thought each group where given a letter from A to Z, depending on the value, then they where put together in one string and then name sorted, like "color+clan+grade+name" like this "US Royal Paladin 1 name".

...Now I get why you wouldn't name-sort the clans​. They have different lengths on their names, right?

Tue, 2017-05-16 18:01
Cajun
Cajun's picture

Quote:
I thought each group where given a letter from A to Z, depending on the value, then they where put together in one string and then name sorted like "color+clan+grade+name"
Yes
Quote:
like this "US Royal Paladin 1 name".
No. Like USA1name. That sorts by US, then A, then 1, then name.

From what I saw they were arranged based off nations. And its not like magic goes Black-Blue-Green-Red-White. Since Cardfight sorts by Rarity->Clan->Grade, length is really only an issue on rarity if you're going alphabetical clans.

Cajun's Explorations
Planeswalker Template Overhaul
fluffyDeathbringer wrote:
I dunno, Cajun has a habit of doing Dubiously Working new rules stuff

Tue, 2017-05-16 23:12
Mahx Michael
Mahx Michael's picture

Ok. I think I understand how it works now. Shall try it out pretty soon (but right now it's middle of the night)

Wed, 2017-05-17 22:23
Mahx Michael
Mahx Michael's picture

What does the filter do? How does it work? What should I use it for?



Ok! Now my script file looks like this... and MSE refuses to even open a cardfight set-file!
Script
# Sorting scripts ordered by rarity -> clan -> grade -> name
rarity_sort := {
	if card.rarity == "UR" then "A"
	else if card.rarity == "GR" then "B"
	else if card.rarity == "SP" then "C"
	else if card.rarity == "RRRR" then "D"
	else if card.rarity == "RRR" then "E"
	else if card.rarity == "RR" then "F"
	else if card.rarity == "R" then "G"
	else if card.rarity == "C" then "H"
	else if card.rarity == "SGR" then "S"
	else if card.rarity == "SCR" then "T"
	else "Z"
}

# Sorting clans: First letter is for Nation, second is for Clan
clan_sort := {
	if card.clan == "Royal Paladin" then "AA"
	else if card.clan == "Oracle Think Tank" then "AB"
	else if card.clan == "Angel Feather" then "AC"
	else if card.clan == "Shadow Paladin" then "AD"
	else if card.clan == "Gold Paladin" then "AE"
	else if card.clan == "Genesis" then "AF"
	else if card.clan == "Kagero" then "BA"
	else if card.clan == "Nubatama" then "BB"
	else if card.clan == "Tachikaze" then "BC"
	else if card.clan == "Murakumo" then "BD"
	else if card.clan == "Narukami" then "BE"
	else if card.clan == "Nova Grappler" then "CA"
	else if card.clan == "Dimension Police" then "CB"
	else if card.clan == "Entranger" then "CC"
	else if card.clan == "Link Joker" then "CD"
	else if card.clan == "Spike Brothers" then "DA"
	else if card.clan == "Dark Irregulars" then "DB"
	else if card.clan == "Pale Moon" then "DC"
	else if card.clan == "Gear Chronicle" then "DD"
	else if card.clan == "Granblue" then "EA"
	else if card.clan == "Bermuda Triangle" then "EB"
	else if card.clan == "Aqua Force" then "EC"
	else if card.clan == "Megacolony" then "FA"
	else if card.clan == "Great Nature" then "FB"
	else if card.clan == "Neo Nectar" then "FC"
	else if card.clan == "Cray Elemental" then "ZA"
	else if card.clan == "Touken Ranbu" then "ZB"
	else "ZZ"
}

# Sortig grades from top and down:
grade_sort := { 9 - card.grade }

# Process the name for sorting rules
sort_name :=
	# Remove "The", "A", and "And" at the beginning
	replace@(match: "^(The|An?) ", replace: "") +
	# Remove commas and apostrophes
	replace@(match: "(,|'|’)", replace: "") +
	# Remove bold and italic tags
	replace@(match: "(<b>|<i>|</b>|</i>)", replace: "") +
	# Make lowercase
	to_lower
	
set_filter := {
	if card.shape == "legion" then { card.shape == "legion" }
	else if card.shape == "normal" then { card.shape == "normal" }
	else { card.shape == "legion" and card.shape == "normal" }
}

card_number := {
	position (
		of: card
		in: set
		order by: { rarity_sort() + clan_sort() + grade_sort() + sort_name(card.name) }
		filter: set_filter()
	) + 1
}

Wed, 2017-05-17 22:02
Cajun
Cajun's picture

Filter is what determines what goes into the count. Magic Tokens and Emblems want to use the same collection, unique from the set, promos, and other extras so their set filter is

	if card.shape == "token" or card.shape == "emblem" then
		{ card.shape == "token" or card.shape == "emblem" }

Looks like Cardfight has Special rarity cards with their own count. You'd basically just recreate Magic's special

set_filter := {
	if card.rarity == "special" then
		{ card.rarity == "special" }
	else
		{ card.rarity != "special" }
}

so the whole mess looks like

rarity_sort := {
	if card.rarity == "RRR" then "A"
	else if card.rarity == "RR" then "B"
	else if card.rarity == "R" then "C"
	else if card.rarity == "C" then "D"
	else if card.rarity == "special" then "S"
}
clan_sort := {
	if card.clan == "Royal Paladin" then "CA"
	else if card.clan == "Oracle Think Tank" then "CB"
	else ...
}
grade_sort := { 9 - card.grade }
set_filter := {
	if card.rarity == "special" then
		{ card.rarity == "special" }
	else
		{ card.rarity != "special" }
card_number := {
	position (
		of: card
		in: set
		order_by: { rarity_sort() + clan_sort() + grade_sort() + sort_name(card.name) }
		filter:   set_filter()
	) + 1
card_count := {
	number_of_items(in: set, filter: set_filter())
}
card_number_final := { (if card_number() < 100 and card_count() > 99 then "0" else "") + (if card_number() < 10 then "0" else "") + card_number() }
Tweaked for your fields and choices. Then the code you'll use to make the string is
set.set_code + ( if card.rarity == "special" then "/S" else "/") + card_number_final() + set.set_language + " " + card.rarity

Cajun's Explorations
Planeswalker Template Overhaul
fluffyDeathbringer wrote:
I dunno, Cajun has a habit of doing Dubiously Working new rules stuff

Wed, 2017-05-17 22:51
Mahx Michael
Mahx Michael's picture

Actually, cardfight now have multiple special rarities: SP, GR, SCR and SGR. How do I put that into the script?
I tried to use the card.shape for the filter, but somewhere something went wrong...
(Script is in the post above...)



Can the opening and closing of { } cause any trouble? Also, the rarity as well as clan is set by editable text, can this cause the script to crash?

Wed, 2017-05-17 23:16
Cajun
Cajun's picture

You might need the set_filter thens on a seperate line still, but the filters are off because they aren't excluding the other card types, and are even including them in the last one. You should look like this:

set_filter := {
	if card.shape == "legion"
		then { card.shape == "legion" }
	else if card.shape == "normal"
		then { card.shape == "normal" and card.shape != "legion" }
	else
		{ card.shape != "legion" and card.shape != "normal" }
}

Quote:
Also, the rarity as well as clan is set by editable text, can this cause the script to crash?
Eh, possible but incredibly unlikely at startup. If it won't open and then you open another set the console will tell you why the previous didn't work. Do you have legion and normal in the card.shape field options?

@Clans: Wouldn't a nested dropdown, ie Magic Watermarks, be a workable solution for clans? Checking text instead of choices does slow the program some.

Cajun's Explorations
Planeswalker Template Overhaul
fluffyDeathbringer wrote:
I dunno, Cajun has a habit of doing Dubiously Working new rules stuff

Thu, 2017-05-18 02:31
Mahx Michael
Mahx Michael's picture

I still can't make the script work. What exactly are you making mse do, when sending card.shape == "legion" into the filter? Is there something I need to define somewhere else in order to make the filter work?

Thu, 2017-05-18 02:46
Cajun
Cajun's picture

in your card fields you should have something like this:

card field:
	type: choice
	name: shape
	save value: false
	show statistics: false
	editable: false
	choice: legion
	choice: normal
	script:
		stylesheet   # indicate that this value should be updated when the stylesheet changes
		card_shape() # determined by the style
then your stlye should contain card_shape := { "legion" } or card_shape := { "normal" }
Then filter will separate what is using normal and legion frames. You only want to use this if legion and normal are using different numbers.

Cajun's Explorations
Planeswalker Template Overhaul
fluffyDeathbringer wrote:
I dunno, Cajun has a habit of doing Dubiously Working new rules stuff

Thu, 2017-05-18 20:14
Mahx Michael
Mahx Michael's picture

I still can't make it work. Might it be something with the name_sort? Or is it possible to not use a filter, and add one later when I learn how it works and find out what I want to filter?

Thu, 2017-05-18 21:11
Cajun
Cajun's picture

Is it crashing when you try to open or just not opening? If it doesn't open you can open another project and the console will tell you what is failing. Otherwise, yea just take filter or other pieces out of the main file until it stops breaking to narrow it down iguess.

Cajun's Explorations
Planeswalker Template Overhaul
fluffyDeathbringer wrote:
I dunno, Cajun has a habit of doing Dubiously Working new rules stuff

Thu, 2017-05-18 21:27
Mahx Michael
Mahx Michael's picture

how do I sort without a filter? Is it just to exclude the filter part?

Fri, 2017-05-19 14:00
Mahx Michael
Mahx Michael's picture

I found out what the problem was. The default charset on the notepad I was using was ANSI and not UTF-8. Also, my UTF-8 generally doesn't like the second ’, so I had to remove it. Now the script finally works A happy smile
Thank you very much, @Cajun! The font page you showed me also works great and I have found many of the fonts I need already A happy smile


Btw, is there a way to make a font installer out of a font that is already on my computer? Or do I have to find it online and then download it (to zip along with the template). You see I have problems finding the font named "Impact".

Fri, 2017-05-19 14:10
Cajun
Cajun's picture

The ANSI thing turns up so rarely I hadn't even thought of that.

The fonts on your computer should be in C://Windows/Fonts. The .ttf or .otf file acts as an installer.

Cajun's Explorations
Planeswalker Template Overhaul
fluffyDeathbringer wrote:
I dunno, Cajun has a habit of doing Dubiously Working new rules stuff

Fri, 2017-05-19 15:26
Mahx Michael
Mahx Michael's picture

OK, thanks! Found it.

Sat, 2017-05-20 11:15
Mahx Michael
Mahx Michael's picture

Now I've found out what I want to filter in the card number script. I want to count the legion cards together with the others (since I've found a way to do it, and that's how they do it IRL), and instead filter out the rarities "SP", "SCR" and "SGR" and number them separately as specials. I want the normal cards to be numbered with ### and specials with S##.

My only question is: How do I make the script separate all the special rarities into one separate category?

Sat, 2017-05-20 15:01
Cajun
Cajun's picture

Same way tokens and emblems are together. You'll likely want to make it a variable for future use anyway so lets make it here.

is_special := { card.rarity == "SP" or card.rarity == "SCR" or card.rarity == "SGR" }
set_filter := {
	if is_special() then
		{ is_special() }
	else
		{ not is_special() }
}
If it doesn't like the functions, just replace is_special() with its line and not is_special with the same but != instead of ==.
Puts your set code line at either
set.set_code + ( if is_special() then "/S" else "/") + card_number_final() + set.set_language + " " + card.rarity
set.set_code + ( if card.rarity == "SP" or card.rarity == "SCR" or card.rarity == "SGR" then "/S" else "/") + card_number_final() + set.set_language + " " + card.rarity

Cajun's Explorations
Planeswalker Template Overhaul
fluffyDeathbringer wrote:
I dunno, Cajun has a habit of doing Dubiously Working new rules stuff

Sun, 2017-09-10 21:18
Mahx Michael
Mahx Michael's picture

OK, it worked! Thanks a lot! A happy smile

EDIT: Just checking off this one as [Resolved] for order's sake.