September 27, 2021, 07:42:47

Author Topic: Player Swapping?  (Read 254 times)

Offline Hotshot

  • Jr. Member
  • **
  • Posts: 49
Player Swapping?
« on: June 19, 2021, 12:37:11 »

I am using Dim Arrays and if I selected the player number 1 and want to swap to Number 12.

How would I swap Arrays when I selected the mouse down?

I had good look at Help where the commands lists is and there is No Swap Commands!

for example

First 11 players

1 GK  David Lee
2
.
.
.
.
.
.
.
.
.
.
12 GK  James Heywood(Second goalkeeper got better skills)

So would you move the mouse down to 12 and select him to swap number 1 to make James to be number 1 Keeper!


Offline Derron

  • Hero Member
  • *****
  • Posts: 3651
Re: Player Swapping?
« Reply #1 on: June 19, 2021, 12:53:46 »
I am not sure what you mean:

array/dim with x entries.
either change the objects (if possible)

or restructure to not have a dim "team" with the people assigned to it ... but have a
team array only containing ids of person.
Then it is only a matter of switching the numbers

the "team dim" is then just a lookup for you to know what person to retrieve from a "person dim".


bye
Ron

Offline Midimaster

  • Sr. Member
  • ****
  • Posts: 363
    • Midimaster Music Education Software
Re: Player Swapping?
« Reply #2 on: June 19, 2021, 14:21:13 »
If this is only a array of strings or types you could do it with a third variable:

Code: [Select]
locPlayer$ = Player[12]
Player[12] = Player[1]
Player[1] = locPlayer

If you want more detailed information you need to send more code, that we can see, how you defined the array.
See my current project on PlayStore: 20Tracks-Audio-Player https://play.google.com/store/apps/details?id=midimaster.twentytrackd

Offline col

  • Hero Member
  • *****
  • Posts: 597
Re: Player Swapping?
« Reply #3 on: June 19, 2021, 17:35:39 »
Quote
... and there is No Swap Commands

As Midimaster suggests.
'Swap functions' usually involve a temporary:

Tmp = 1stElement
1stElement = 2ndElement
2ndElement = Tmp

It's very easy to do this in your own code.

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal