Interesting task - how to create a Tape?

Hello everyone!

I have a question, how can i make a virtual tape which can scroll by some button of player?

As example, we have some list of players/variables/icons etc. and by pressing button they must changing by circle. Okay, as example it will be Hero Icons (Lucio, Moira etc.)

At the start we can as example this list of heroes:

Moira
Lucio
Torbjorn
Mercy
Widow

Our roulette must scroll by some button

We start from here:

Moira
Lucio
Torbjorn ← We are here
Mercy
Widow

We have some Hero Icon String on some vector, as example it will be [1;1;1]

If player pressing button Primary Fire roulette scrolling and became:

Lucio
Torbjorn
Mercy ← We are here
Widow
Moira

And in backward direction, if pressed Secondary Fire, again to:

Moira
Lucio
Torbjorn ← We are here
Mercy
Widow

What is the best way to create this?

1 Like

I actually wanted to make this since some time now, but I never really knew how to do it, so I got a little scared off. But I have some ideas on how to do it. So Im gonna try to make this now.

I have made a menu wich is a light version of what you want. The only difference is that items of the menu dont move to the top if they move below the bottom (and the other way round), because I think it would be a lot harder to do (in workshop) with a lot more code. So I have made a simpler and cleaner version wich still does look good.

WYMK3

Usage:

  • Spawn in team 1.
  • Enter the red ring to open the menu.
  • Press crouch to leave the menu.
  • Press jump to use the selected item and leave the menu.
  • Press primary fire to select the next item (up).
  • Press secondary fire to select the next item (down).

Regarding the code, most of the position calculation is to place the menu in front of the player. The key lies in down * 0.2 * player variable(C). If I want to move all of the items down I just increase C and if I want to move all items up I just decrease C. Also C + 1 is the number of the selected item.

Trying to prove Workshop is Turing-complete, are we? :wink:

Dont worry, everyone still learning, even skilled workshopers :slight_smile:

Actually i guess its not what i wanted, I see its like a linked with vectors, like if pressed button its Down (1) or Up(1), but i think it must be linked with some Array, which can be modified, like i can remove one of elements from Tape or add by Append to Array, and its must be modified also.

I have idea about how to do with Down. I just make array [0] [1] [2] [3] [4] which contains Heroes of Overwatch. And create World Hero Icon as example
0 - Moira
1 - Lucio
2 - Torb
3 - Mercy
4 - Widow

So and i just create World Hero icon, where shown Icon will be [2] element of array.

So If i press Primary Fire (Down Roulette) I set some Global Variable (A) = First element of array. Then i Delete first element of array by Remove from Array and then i append it to last one by Append to Array. And getting this one:

0 - Lucio
1 - Torb
2 - Mercy
3 - Widow
4 - Moira

Now Lucio is First, and Moira last one. But i have problem, Append to Array add to array only by last element, i just cant use Append to Array to add some element in FIRST place, like with the last one. So i guess its not will be so ez like with Roulette Down. :frowning:

If you have n elements and you want to move them down by 1, you can just move them up n-1 times.

The thing is, you cant put the items as objects into the array, only a representation of the items (e.g numbers or heros), wich makes things a bit dirty imo. Of course, it is doable nonetheless. But personally im fine with my solution.

Also keep in mind that removing something from an array doesnt shift all the array elements to the new positions (afaik):

0: X
1: Y
2: Z

remove(X)

0: -
1: Y
2: Z

So you need to shift the remaining elements by hand.

Btw, in any language with classes I would agree. But in workshop everything that matters are the visuals, so what you are doing internally doesnt matter much, as long as it works and is fast. Moreover, at some point you need to display the elements, whether they are in an array or not. Or did I misunderstood you and you dont want to display the roulette menu?

I think it indeed is. And its kind of obvious.

Because afaik turing-complete means that the language can emulate a turing machine. Whats a turing machine? Its basically an automaton + an infinite tape that can be written on. An automaton can be easily done in workshop with “skip if” and it has storage (variables), even if the storage is really limited.

In other words, turing-complete means that it can compute everything that is computable. What is computable? Anything that can be calculated by a human with a pen and paper and some knowledge of math. YOU are turing-complete :wink:

Actually you not right. Sorry dude, but this part i already released. If you just create ez script and will check what will be, so you will see this thing.

0 - 10
1 - 20
2 - 30

→ Remove from array by index [0]

0 - 20
1 - 30

Im so lazy to make it lol but you can try to do and you will see same, so elements will shift without handmade.

I just dont know Useful Alhoritm to make Up-Shifting, like with 1 operation with Down-Shifting. I can make it i guess with 10+ things lol but i dont think this trash will looks like Optimized code. So i just thought that on Forum i will find Skilled Workshoper who can make it optimized and not so huge.

Sounds easy and interesting, pity I did not see this topic. Tomorrow I will make my code and share.

Here it is : FAMMJ
Player variable A = scrolling array
Player variable B = loop variable (for index)
Player variable C = 1rst or last value of A array (depend on wich action you’r doing)
Player variable D = Size of A array

Better solution down !

1 Like

I think I got something mixed up then sorry.

Nice. GL.

I’m none obviously, so gl finding one.

Look there is one for example. Nice.

You not none. I actually already used so much your help even with my Tic-Tac-Toe, When you helped me with arrays redefinition. I think you skilled workshoper.

Thats why i inviting you on this themes sometimes :slight_smile: I hope that you will give me nice advice based on your experience.

Im sorry that I got upset. I misunderstood what you wanted to have in this thread. So its my fault that I made the wrong thing, sorry :slight_smile:

I was wrong here too, sorry.

But you can continue work :slight_smile: Maybe you will suggest some algorithm which will allow Up-Shifting optimized like you suggested me with arrays redefinition [Set Global Variable A, Global Variable B].

Maybe it will be not 1 operation, but i really dont know how to do it on this moment.

Here is a better version : 52K3Y T9X1P
Don’t use loops so it way more faster and maybe less resource consumable.
I’ve try 100/500/1000 values in the array and it lagless up to 500 at 1000 it bug but it may work with somes wait actions (haven’t try between 500 and 1000 so i don’t know where the limit is).

Player variable A = scrolling array
Player variable B = loop variable (for A array setup)
Player variable C = 1rst or copy of A array (depend on wich action you’r doing)
Player variable D = Temp copy of A array (less 1 value)

1 Like

I actually also thought about it. So you need to use at least 2 more arrays to do this operation. Its so sad btw but ok i see it works. Thanx.

Just thinking you may not need variable D as you can store the copy of A in C and define A as the last value of A before adding C. So it may be down only to 1 variable (i don’t count B since it’s just for setup)

Edit : it works ! T9X1P

1 Like

This is the shortest way I can think of: WBR0D

Its basically:

  • create array to rotate on variable A
  • create an empty array on variable B
  • append the last element of variable A to B
  • remove the last element of variable A
  • append A to B
  • set variable A to B

Edit: I see that its exactly what Link2396 did. So dont mind me :laughing:

I think your variant i like more than variant of Link2396.

So anyway i guess you must to use some another array to switch-up, not so ez like it was with switch-down by only 1 command.

Anyway thanx. I hope it will be Useful.