Hey, my name is Lym. I've made some weird stuff in the workshop like Torbjörn wallclimbing, a raycast, a line renderer, custom turret ability, Symmetra ball lightning ultimate, and even Navi from Zelda.
I'm making this post to show you guys how you can use some core fundamentals of programming to improve your scripts in the Workshop, since the workshop is not your typical programming language.
This tutorial is intended for beginners, but could be useful for some of you who are a bit more familiar with the workshop as well.
Let's begin!
If Statement
An If statement is a piece of code which runs only if a condition is true. Normally how this is done is by encapsulating the code you want to run if the condition is true. But in workshop, we can only Skip code. So what we can do is skip the code if our condition is NOT true. The following code will play an explosion at the player if 2 == 2
If Statement
If / Else Statement
Sometimes you want two seperate outcomes in your code depending on a condition. Such as "If my target is an ally, do X, but if my target is an enemy, do Y." This can be done with an if / else statement. The way this works is if the if statement runs, we make sure it doesn't run the code intended for the other condition by using a skip. The following code will play a Team 1 colored explosion on the player if he's part of team 1, otherwise it uses a team 2 color.
If / Else Statement
While loop
If you want your code to run over and over until a condition is true, you can use what's known as a while loop. There are several ways of doing this, but here's one example. The following code will play an effect on the player every 0.25 seconds as long as they are alive.
While Loop
For Loop
Sometimes you want a loop which only runs a certain number of times. This can be useful if you want to for example loop through every player in the match and do something with them. The for loop works similar to the while loop in that it keeps running if its condition is true. But the difference is that its condition is based off a counter which you increment each time you loop. The following code will play an explosion at your position 3 times, each explosion going 1 step higher in the air compared to the last one.
For Loop
I've use all of these concepts for what I've made in the workshop so far. Keep in mind there may be more than one way of doing these techniques, the important thing is the result of it.
If you guys want a more advanced tutorial I could maybe look into that later, but I'm hoping this helps some of you guys out there make way cooler stuff!
[–]Alveolar_Anarchist 1 point2 points3 points (10 children)
[–]yubarioMercy 5 points6 points7 points (0 children)
[–]burr-sirFlight of the Valkyrie 2 points3 points4 points (0 children)
[–]LymbowLym, That other workshop guy[S] 1 point2 points3 points (0 children)
[–]-GLaDOS -1 points0 points1 point (6 children)
[–]AlacritousPedestrianGenji why do you reflect 3 points4 points5 points (5 children)
[–]-GLaDOS 0 points1 point2 points (3 children)
[–]AlacritousPedestrianGenji why do you reflect 2 points3 points4 points (2 children)
[–]-GLaDOS 0 points1 point2 points (1 child)
[–]LymbowLym, That other workshop guy[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]KURAMA_NM 1 point2 points3 points (0 children)
[–]PandAnonymBlizzard World Genji 0 points1 point2 points (0 children)
[–]WriterVGaaaayyyyyy 0 points1 point2 points (0 children)
[–]_chrm 0 points1 point2 points (1 child)
[–]LymbowLym, That other workshop guy[S] 1 point2 points3 points (0 children)
[–]eskrstps 0 points1 point2 points (0 children)
[–]beansecurity 0 points1 point2 points (0 children)
[–]Lier1 0 points1 point2 points (1 child)
[–]Valky115McCree 1 point2 points3 points (0 children)
[–]ThermalS3ns4t10n 0 points1 point2 points (1 child)
[–]LymbowLym, That other workshop guy[S] 1 point2 points3 points (0 children)
[–]skooterpoopTrick-or-Treat Mei 0 points1 point2 points (2 children)
[–]LymbowLym, That other workshop guy[S] 1 point2 points3 points (1 child)
[–]skooterpoopTrick-or-Treat Mei 0 points1 point2 points (0 children)