#I really should just create an IntelliJ

1 messages ยท Page 1 of 1 (latest)

zenith hamlet
#

thanks, @stable rune ... that'd be ideal; I was thinking of hand-holding ChatGPT to see if it could rewrite the VS Code plugin for IntelliJ.

One thing I don't understand is:

  1. npx tstl // compile TS to ./dist/bundle.lua
  2. ???
  3. Call tts-editor's saveAndPlay()

How do I get the new file(s) into TTS? And how do I update Global.lua so it imports it/them?

#

thanks @manic gyro -- just moved the conversation over here

manic gyro
#

Guess a dedicated plugin for Webstorm/IntelliJ would still be better to have other things like error reporting, print feedback, etc. I don't know if it's possible to trigger commands from inside Webstorm in VS Code. If so, you could keep both running and use VS Code as the bridge to send the stuff for an intermediate solution. ๐Ÿ˜…

zenith hamlet
#

MORE DUCT TAPE!!!

stable rune
#

Honestly, an IntelliJ/Webstorm plugin probably isn't quite what you want because you're planning on transpiling TypeScript. If I was to build an IntelliJ plugin it'd handle Lua and bundling https://github.com/Benjamin-Dobell/luabundle.

manic gyro
stable rune
#

Here's one of my push.js scripts:

const fs = require('fs')

const ExternalEditorApi = require('@matanlurey/tts-editor').default

async function push() {
    const api = new ExternalEditorApi()

    try {
        console.log("Connecting to TTS...")

        await api.listen()

        console.log("Connected. Pushing...")

        const script = fs.readFileSync('./build/Global.bundle.ttslua', {encoding: 'utf8'})
        const content = script.replace(/\n/g, "\n")

        await api.saveAndPlay([
            {
                guid: "-1",
                script: content,
            },
        ])

        console.log("Pushed")
    } catch (e) {
        console.error("Failed to push to TTS")
        process.exit(1)
    }
}

push()
zenith hamlet
#

ahhh -- perfect

#

I was thinking I might have to copy the file to the TTS installation directory vs. sending it through an API call

stable rune
#

That script.replace(/\n/g, "\n") seems redundant now that I'm looking at it ๐Ÿ˜†

manic gyro
#

Also personally, I don't bundle with TSTL and instead use Benjamins luabundle instead. This ensure that the code can be consumed by the existing TTS plugins as they all rely on this bundling method.

zenith hamlet
#

hmm... do you develop in TS though?

manic gyro
#

Yes. Even UI with JSX. ^^
I mean at least for the most part. The mod I'm working on started in pure Lua, but I'm switching to TS, so it's currently mixed until everything is migrated.

stable rune
# zenith hamlet hmm... do you develop in TS though?

I don't. I'm my own IntelliJ Lua plugin that bolts types onto Lua (https://github.com/Benjamin-Dobell/IntelliJ-Luanalysis). Not even close to as powerful as TypeScript though. Honestly, if TypeScript -> Lua was further along when I started TTS dev, I probably would have never bothered taking this route.

Only problem is I like debugging... a lot ๐Ÿ˜… Given the Lua debugging is already super clunky, it'd be pretty painful trying to get it working with source maps and understanding any sort of name mangling that might be going on.

zenith hamlet
#

right... thankfully, I'm just getting started, so with ChatGPT and TSTL, I might get to avoid learning a new language I'm unlikely to use again

#

@manic gyro when you say you use luabundle instead of TSTL, how are you converting the TS to Lua before the bundling step?

manic gyro
#

I convert TS to Lua with TSTL but without the bundling option. So that every TS file will result in a Lua file. Then I run luabundle on the result, together with files that are already written in Lua.

zenith hamlet
#

Gotcha -- missed the option to not bundle

#

Just saw "To skip bundling, set "luaBundle": null in the configuration."

manic gyro
#

Not learning Lua is also probably a pipe dream though. ๐Ÿ˜… Since the errors only occur in the Lua code you have to understand what it does during debugging. Especially since there can be some "Gotchas" with TSTL where the TS code is totally fine, but the generated Lua result isn't what you are looking for. E.g. regarding the self parameter from the documentation.

zenith hamlet
#

right... I figure I can probably get by with GPT and the fact that it'll be (I think) a pretty simple game, just 3 decks of cards and some rules.

Is Lua's self similar to JavaScript's self?

stable rune
#

JavaScript's this.

zenith hamlet
#

duh, that's what I meant

manic gyro
#

Feel free to hit me up with questions regarding TSTL when you encounter them. If you haven't already, the type definitions for TTS can be found here: https://www.npmjs.com/package/@typed-tabletop-simulator/declaration
There's also the JSX library under this scope (called ui) if you need that/want to give it a try. But it's usage isn't documented at all. ๐Ÿ˜