Currently looking into implementing this myself. Haven’t seen much regarding this. Just posting this here so I know not to waste my time if it’s already being worked on by someone else, or perhaps we could pull our resources and work on it together.
For anyone unaware, a language server lets you do fancy stuff like this: https:/ /code.visualstudio.com/api/language-extensions/programmatic-language-features#show-code-completion-proposals
and it can be extended for other editors as well, not just VSC.
I was thinking something along the same lines, although what I had in mind was implementing a scripting language alongside a compiler that would turn said scripts into workshop rules that could then be pasted into the game directly. This would allow for much shorter and easier to read workshop scripts while retaining most if not all of the functionality as well as potentially adding support for things like utility functions or simpler string assembly.
I like your idea though, having syntax highlighting and auto complete would already be a huge step into the right direction towards having a fully feature-complete scripting language/IDE for the Overwatch Workshop.
I’ve not messed around with language extensions myself but I’d be willing to look into it. I checked out the link and it doesn’t sound too bad. What language where you planning on using for the server backend?
1 Like
A custom preprocessor sounds interesting, but it also seems orders of magnitude more complicated. I think supporting vanilla syntax in IDEs is the first step.
The VSC docs are all using TypeScript, which I’m familiar with, so probably that.
Agreed. Well, I’ll have a look at the sample project and see if I can wrap my head around how it works. Never used TypeScript before and not too familiar with JavaScript either but that won’t stop me lol
I’ve been waiting for someone to do all of the Type definitions
.
Hi, just wanted to speak up and say that I am in fact working on something exactly like this. You can read my post that I made here https:/ /us.forums.blizzard.com/en/overwatch/t/python-to-workshop-code/348831 or check out my Github page (adapap/owscript). My go-to language is Python and what i’m working on is a transpiler, which as @Fredi68 wrote, turns a “script” of raw text into workshop rules. I’m also not a huge fan of IDEs (to each their own, I guess), but my plan was to implement completions in Sublime Text 3 after writing the basic aspects of the language. As of this moment, I’m setting up a skeleton of the Type definitions @Scrumrot so feel free to join me and discuss about how to go about this kind of project.
Sounds very interesting, I’ll have a look at this as well. I’m much more comfortable with Python too, so if there should be any need I might just be able to help out with some things.
sounds like quite the challenge.
People will need to remember, the workshop has no scope variables between rules, it is scope viriable between individual players, and globally.
The other issues is if people start trying to create complex objects in python and try to have to convert to workshop script.
Exactly why I think supporting vanilla syntax in an IDE is way more important than trying to make opinionated changes to the syntax via a preprocessor.
I’ve already got the language server up and running, with a custom language set up. Now I’ve just got to fill in all the autocompletions and do the grunt work.
well I for one was imagining only supporting a strict subset of Python syntax. Having full on OOP for OWW probably wouldn’t work anyways; you might be able to somehow create a dodgy class attribute structure using arrays but I don’t know how methods or even functions could be implemented. However, certain things like variable substitution on a global level would be nice and there may even be ways of “cheating” the system using arrays:
As long as there is technically no “upper limit” to the amount of elements that can be added to an array, we could just append arbitrary objects and reference them in the code using array indexing. The transpiler could then do the work of substituting “boss_hp” to Array of Global Variable A index 12, thereby increasing the amount of available variables significantly.
As for scoping, I agree this becomes an issue and one would either have to disallow overwriting variables in different scopes (impractical) or consider all variables global by default. I personally could live with the second solution.
All of this of course is entirely hypothetical and I have not checked back with the actual workshop to see what is and isn’t possible. However, I don’t think that trying to establish where the limits on how far we can go lies is a bad thing.
Damn that was fast.
So the bulk of what remains is creating a database of all the actions, conditions and values then? I’d love to have a look at this, is there a repo for it?
I will be rooting for you guys. I would also love to take a look at the repos too =3
Will get it up soon, and post here when I do. Essentially yes but it’s wayyyy more complicated than just that. Lot of moving parts. But yeah should be doable
1 Like
My brain is just completely fried right now but I have an outline for how i’d like to setup the transpiling process on my github page (adapap/owscript). I think it works for basic event instructions but I am stuck working on the various values trying to figure out how to handle it.
EDIT: I guess I just needed a small break to realize it had to do with list mutability
. Anyways the latest commit on my GH has a test case. The .ows file is an input, and it generates the .txt file. Variable assignment also works. I think from now on development should be simple as I laid the groundwork for a number of workshop features.
Reddit post with Github link:
https:/ /www.reddit.com/r/OverwatchCustomGames/comments/bso1j4/working_on_ide_support_for_workshop_syntax/?
@Vice Looks good, I’ll try this out later. I can already see how that would get complicated rather quickly though.
@Legendary So I ran my own experiments today and yeah, dealing with the way the workshop code does some stuff is a nightmare.
I guess I am kind of attempting to solve this from the “other end”, using the Python ast module to parse code into a tree and then cherry picking the stuff I need from that to create workshop code. Surprisingly enough this actually appears to work, at least for the simple examples I tested so far. Currently running my head against the wall that is control structures and while loops are giving me some trouble but should be doable with enough time.
My biggest worry is that we will end up just completely overloading the OWW scripting engine with these projects of ours lol
Like you said, it is really a matter of the upper limit of the elements we’re allow in an array.
With the addition of the Modify Global Variable At Index and Modify Player Variable At Index, we can actually create complex objects with the use of two arrays. One to store all the data, while the second one to store the index of the start and end of object data in the array. Combine that with Slice Array, we can insert data to extend the size easily.
We can solve the for loops now that we can add the index value to an array and create a copy of the value using Slice Array of the element.
Everything is possible with programming, the only real limiting factor has always been the hardware limitations. The limit of what the workshop allow can simulate a hardware limitations for the converter.
Yeah I was using a similar construct with arrays containing information about the running loop to allow jumping between different parts of the rule to do complex iterations. I was even considering implementing some sort of stack frame system but I stopped after my brain was about to explode lol. However, I ran into a problem there and while I’m here I may as well describe it in hopes that someone has a solution.
The way I was doing while loops was using the Loop If action to evaluate a condition after executing a block (like a Do While in other languages). Then I had a Skip instruction at the very start that would jump immediately to the start of the while block. However, it turns out that you cannot have a Wait action after a skip action if you want it to count towards the loop wait requirement so the only way I found to fix this was to delay the entire rule execution by 0.25 seconds which is far from ideal.
Is there a better way of implementing while loops without the requirement of having each loop be self contained in a single rule?
Wouldn’t the WHILE loop be solve by having the loop check condition set up in the condition block before the action block even take place instead?
And if you want a DO WHILE loop, you set up the conditions within the LOOP IF parameter in the Actions block without anything in the Condition block instead.
Well my problem is that I am making this way too complicated. My end goal is to allow something like this:
while cond1:
while cond2:
do something...
The program then keeps track which loop it is running using a variable and every time the rule loops back to the start it skips ahead into the block that is currently executing. For example, if the second while loop was currently executing, the pointer would be set to line 2 in this case, causing the first loop body and Loop If instruction to be skipped on each rule iteration. It should be noted that I did make sure to use player variables for this wherever possible to prevent race conditions.
But OWW doesn’t let me do this. At least not without adding a 0.25 second delay to the very start of the rule. It makes sense too, since otherwise you could theoretically just skip over Wait() actions, creating a possibly infinite loop that never pauses.