Import (./import)
Settings for importing a TyranoScript project with lim import. lim import uses the built-in conversion table for the standard commands,
with each plugin’s ./import (and ./import of the package that import.tyrano.profile points to) laid over it in the order of plugins.
Command specs (parameter types, unnamed parameters, defaults) are looked up from the command tables in ./commands, so here you write only how they correspond to .ks.
const profile: TyranoImportProfile = {
mappings: [
// turn [stamp_show storage=… x=…] into @stamp; storage in .ks is image in @stamp
{ command: "stamp", tags: ["stamp_show"], params: { image: "storage" } },
{ command: "stamp-clear", tags: ["stamp_clear"] },
],
};
export default profile;
mappings(an array ofTagMapping): the conversion table from .ks tags to commands.commandis the name of the command to convert to, andtagsare the names of the .ks tags to convert from.paramsmaps “.lim parameter name → .ks parameter name”. Parameters you don’t list use their name with-turned into_, andnullmeans there’s no counterpart in .ks.- If you don’t write anything else, the conversion is mechanical (of the values written in the .ks, only those that differ from the command’s defaults are written out, and parameters that weren’t converted are left in the diagnostics).
- When mechanical conversion isn’t enough, use
convert(pm, tag, ctx).ctx.specis the command’s spec,ctx.mechanical(pm)is for converting mechanically after tidying the values, andctx.convertAs(command, pm, tag)is for handing off to another conversion table. Returning null falls back to mechanical conversion. - For forms you want to leave to the built-in conversion, use
defer(pm)(to turn only certain destinations of[jump]into your own command, for example); list .ks parameters not to convert inignore; and useswallowStopto remove the[s]right after.
scriptRules/scriptProfile: replace JS in[iscript]with commands (return the replacement .lim lines, or null if the rule doesn’t apply)unsupportedTags: tags that aren’t handled, and why (importing them gives an error with the reason, and they’re listed inlim referencetoo)tags: conversions for tags that can’t be written in the table (tag name →(pm) => TagConversion | null; takes precedence over the table)plugins: TyranoScript plugins whose work is taken over (they aren’t reported as manual work even if they have JS)skipFiles: .ks files not to convert as story text (ones the system screens take care of, such as the title screen)afterImport(ctx): writes out project-specific data (JSON underdata/) and returns the character definitions (if the project keeps settings in the same form as Tyrano Tatie under another name,castFromTatieSettingscan turn them into character definitions)writeCast(ctx): writes character definitions saved in the sprite position editor back to the import sourcebackport: for writing back (lim backport), the reverse conversion that turns command lines back into .ks tags (command name →(line, originalTag) => tag text | null). Writing back finds parameters by rewriting them with the conversion table and the original tag as a model, so you usually don’t need this. Use it for commands that can’t be turned back from a model alone, such as conversions written withtags(tyrano-backport.md)
The conversion table for the standard commands (@image and so on) is STD_MAPPINGS in the engine (packages/ks-import/src/std-tags in the public repository).
You can read it as an example of how to write conversion tables.