Jump to content

Recommended Posts

Papyrus-2-Typescript


Transforms *.psc header files to *.ts files that can be used by modders in Skyrim Platform.

 

Warning
This program and libraries aren't meant to be used by mod users, but modders using Skyrim Platform for making mods only.

 

THIS WON'T MAKE SENSE TO YOU IF YOU ARE NOT A MODDER.

About
This program is meant to be used to transform SKSE definition libraries to Typescript for using them in Skyrim Platform, so you can use in Typescript all your SKSE libraries the same way you would be using them in Papyrus (here's a real life usage example of using JContainers conversion for an actually working plugin).

This program's aim is not to automate whole language features translation, but only function headers.
If the *.psc file contains actual code (think PapyrusUtil.psc) the function header will be converted, but the rest will be output verbatim, waiting for a human to come and fix it.

Usage
Drag and drop all your *.psc files to the executable.
It will generate *.ts files in the same folder as its input.

Using converted files
Put all your converted files inside some folder, then add that folder inside the folder where skyrimPlatform.ts is located.

location.png.accf7cb33f16a22627cf8baa91c

Folders in this image look like shortcuts because they are actually symlinks (the same technology Vortex uses to manage your mods).
You don't need to use symlinks. You can just drop your folders there.

Once folders are where they are supposed to be, import modules from Typescript as usual.

import { on } from "skyrimPlatform"
import * as JArray from "JContainers/JArray"

// Lines irrelevant to our illustration purposes were ommited.

on('update', () => {
  const a = JArray.object()
  JArray.addInt(a, 5)
  const t: number = JArray.getInt(a, 0)

  // This outputs `5`, indeed.
  printConsole(`Array value: ${t}`)
})


I've added to my github project some converted files for libraries I use myself.
Grab them at the conversions folder.

BEWARE: Not all functions have been tested.

Remarks
This program has no way to know the intention of the humans that made the scripts, so it's always advisable to manually check all generated files to make sure everything is declared as it should.

Take note the program assumes generated scripts will be put in some subfolder to the folder where skyrimPlatform.ts is found, otherwise you'll get "Cannot find module..." type of errors when coding your plugin.

If you want to have your scripts in some other place, you can always just change the relative path of each importfor each *.ts file, of course.

Github project page
Source code here


  • Submitter
  • Submitted
    10/19/2021
  • Category
  • Requires
    Skyrim Platform
  • Regular Edition Compatible
    No

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use