From ebeb96bab2ab86d0c43e5cfb56d8782aaf40c40e Mon Sep 17 00:00:00 2001 From: Ashley Wright Date: Mon, 4 Nov 2024 07:19:39 +0300 Subject: [PATCH] Add image support in descriptions --- odysseus/convertFtbQuests.ts | 45 ++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/odysseus/convertFtbQuests.ts b/odysseus/convertFtbQuests.ts index ddf9e95..cd4f038 100644 --- a/odysseus/convertFtbQuests.ts +++ b/odysseus/convertFtbQuests.ts @@ -553,7 +553,7 @@ export const convertFtbQuests = async ( const fileWrites: Promise[] = []; const warnings = new Set(); - const formatString = (text: string) => { + const formatString = (text: string, description = false) => { let result = ""; for (let i = 0; i < text.length; ++i) { @@ -571,6 +571,47 @@ export const convertFtbQuests = async ( continue; } + if (description && character === "{") { + let end = text.indexOf("}", i + 1); + + const fieldsStrings = text.substring(i + 1, end).split(" "); + + const fields = fieldsStrings.map((field): [name: string, value: string] => { + const nameEnd = field.indexOf(":"); + + const name = field.substring(0, nameEnd); + const value = field.substring(nameEnd + 1); + + return [name, value]; + }); + + const obj = Object.fromEntries(fields); + + if ("image" in obj) { + text += ` formatString(s, true)) ?.map((s) => (s.length ? s : "
")) ?? []), ...(rewardsIds.length