Jump to content

PaperScript - A modern alternative to Papyrus


Recommended Posts

Posted

So apparently I have way too much free time and I really hate Papyrus so I made a mode modern replacement.

 

PaperScript is a modern scripting language that compiles into valid Papyrus. It fixes some Papyrus issues and adds missing features.

 

The current V1 version compiles into Papyrus that can then be compiled into PEX with the native Papyrus compiler.

 

V2 will compile directly into PEX which will make it possible to implement even more features and potentially even optimize some performance issues.

 

The project is very much in an aplha, proof-of-concept stage but it is fully functional! You can download an EXE and start using it today!

 

Here is the Quick Start Guide

 

A picture is worth a thousand words so here's an example of PaperScript:

 

hidden script HelloWorld: ObjectReference {
    _localPlayer: Actor = None

    hidden property PlayerProp: Actor {
        get {
            return _localPlayer
        }

        set {
            _localPlayer = value
        }
    }

    conditional auto property Gold001: MiscItem

    def AddItem(actor: Actor, item: Form) {
        actor.AddItem(MiscItem, 1)
    }

    def CountItems(actor: Actor, item: Form) -> Int {
        return actor.GetItemCount(item)
    }

    def AddAllItems(actor: Actor, items: Form[]) {
        // range is PaperScript's foreach
        range item in items {
            actor.AddItem(item, 1)
        }
    }

    def SwitchDemo(num: Int) -> String {
        switch(num) {
            case 1 => return "One";
            case 2 => {
                return "Two"
            }
            default => return "Uknown";
        }
    }

    event OnEquipped(actor: Actor) {
        Debug.Notification("Equipped")
    }

    event OnUnequipped(actor: Actor) {
        Debug.Notification("Unequipped")
    }
}

 

Binaries for the compiler are available on GitHub and NexusMods. Any feedback is greatly appreciated! Ideally please use the Discord but feedback here is also super welcome.

 

Links

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...