#I really should just create an IntelliJ
1 messages ยท Page 1 of 1 (latest)
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:
npx tstl // compile TS to ./dist/bundle.lua???- Call
tts-editor'ssaveAndPlay()
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
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. ๐
MORE DUCT TAPE!!!
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.
saveAndPlay is the update of the scripts. You send a list of object GUIDs together with their script/UI. TTS will then update it and reload the game. Sending an empty list basically is just a reload without changing anything
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()
ahhh -- perfect
I was thinking I might have to copy the file to the TTS installation directory vs. sending it through an API call
That script.replace(/\n/g, "\n") seems redundant now that I'm looking at it ๐
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.
hmm... do you develop in TS though?
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.
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.
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?
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.
Gotcha -- missed the option to not bundle
Just saw "To skip bundling, set "luaBundle": null in the configuration."
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.
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?
JavaScript's this.
duh, that's what I meant
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. ๐
Declaration files for the Tabletop Simulator API.. Latest version: 2.0.0, last published: 14 days ago. Start using @typed-tabletop-simulator/declaration in your project by running npm i @typed-tabletop-simulator/declaration. There are no other projects in the npm registry using @typed-tabletop-simulator/declaration.