LaurenceBedford's Recent Forum Activity

  • Ok, forget about ternary operator. With the goalkeeper, 3-4-3 formation:

    > For "n"=0 to 10
    
    If loopindex=0 : Array set "GK" at X=loopindex, Y=..
    
    Else If loopindex<4 : Array set "DF" at X=loopindex, Y=..
    
    Else If loopindex<8 : Array set "MD" at X=loopindex, Y=..
    
    Else : Array set "AT" at X=loopindex, Y=..
    
    

    dop2000

    I still cant get this working Please could you provide a .c3p file

  • You are probably overwriting the name, check your code.

    3-4-3 is first 3 players are "DF", next 4 players are "MD", and next 3 players are "AT", right?

    So if you are looping from index 0 to 9, loopindex<3 are "DF". You can use a short version of if-then-else for this, it's called ternary operator:

    loopindex<3 ? "DF" : "something else"

    And then nest another ternary operator inside:

    (loopindex<3 ? "DF" : (loopindex<7 ? "MD" : "AT"))

    dop2000

    Sorry I am still confused what would it be for the others and how would I keep the player with GK position at the top?

  • dop2000

    heres the link to the .c3p file I have

    dropbox.com/s/1rkpq15y5su094z/New%20project%20%281%29.c3p

    I changed Y to 1 to make it transfer the player names - But I still can't get as player with GK staying at the top whilst the formation is changed

  • dop2000

    The player names get lost in the transfer aswell how do I fix this:

    Also how did you know for the 3-4-3 its:

    (loopindex<3?"DF":loopindex<7?"MD":"AT")

    How do I work that out for the others?

    Also the player with GK is supposed to be at the top except it puts the player with the DF at the top how can I start the DF players from the 2nd position?

  • Ok, I tried it. But it doesn't sort the array of players, it simply assigns different positions to the first 11 players. So player #4 for example, can be DF in formation 5-3-2. But the same player #4 will become MD in formation 3-4-3. The remaining 7 players are not used at all.

    If this is what you want, then it's very easy. For formation 5-3-2:

    > Repeat 10 times: 
    Array set (loopindex<5?"DF":loopindex<8?"MD":"AT") at x=loopindex, y=1
    

    dop2000

    Thank you

    - how would I do this for the other formations?

  • You should've given all these additional details from the beginning.. Yeah, my method will not work.

    So if there are 18 players in the array, and you want to make the formation 5-3-2, what should happen? First 5 DF players move to the top of the array, and the reserve DF players (if there are any) should stay in the end of the array? Or you need to remove all reserve players, only leaving 10 people in the array?

    I think it would be easier to copy records to another array.

    Or even easier if you had sprite instances instead of the array. 18 instances, you pick all DF, mark first 5 of them as selected for the game. Then pick all MD players, select 3 of them, then pick AT player, select 2 of them.

    dop2000

    here is a demo a colleague provided:

    Fill out the first name surname and email with random stuff it doesn't matter

    Then go to the squad screen

    and you should see the formations box

    This is what I'm trying to recreate. With the formation changes. Does this explain?

  • Sparsha

    When will extended and pro version be released - Also do you have a working example for creating an account and logging in with this?

  • Here you go:

    https://www.dropbox.com/s/bseax8wgh8yc95t/Array2DSort.c3p?dl=0

    dop2000

    Thanks for the response -

    How would I do this is if I had 18 players in the array and I only wanted to play 10 so I only arrange 10? And the rest of the players are sub and not in the team. 11 players are on but the GK alway stays at the top. How would I do this?

    With the formations: -- there would be a button where these can be changed

    4-4-2

    4-3-3

    3-4-3

    5-3-2

  • Hi Guys I have an array that contains football players name and position like this:

    Player name,Player Position

    Here is an example of one of the lines in the array:

    TestName,DF

    etc and I have 3 positions DF, MD and AT

    Each player will have one of those values

    How do I sort the array so that when the player chooses to sort the team into the formation for example

    5-3-2

    the first part 5 is DF

    the second part 3 is MD

    and the third part 2 is AT

    So it looks like this:

    DF,DF,DF,DF,MD,MD,MD,AT,AT

    How would I sort the array so that the 5 players with DF value are at the top then the 3 players with MD value are in the middle and the 2 players with AT value are at the bottom?

  • In runtime you can move data from one array to another, by copying from cell to cell - "Array2 Set value at (X,Y) to Array1.at(X,Y)". Do this in a loop, if you need to copy the entire row or column.

    But it is not possible to modify JSON files in the project, so you will not be able to save modified arrays in the same JSON files. You can write them to Local Storage or some cloud storage.

    Ok thank you!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You want to transfer it in the editor? Simply select the cells you want to transfer, press Ctrl-C, open another file, place cursor where you want to insert these cells, press Ctrl-V.

    Have you ever used Excel? It's very similar.

    dop2000

    No How do I transfer using events?

  • In the editor? Simply rename the files, or copy-paste the content. Or do you mean something else?

    dop2000

    What I mean is I have files like this:

    They have a structure like this:

    How would I transfer a player from one to another?

LaurenceBedford's avatar

LaurenceBedford

Member since 3 Feb, 2017

Twitter
LaurenceBedford has 2 followers

Trophy Case

  • 7-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • x3
    Coach One of your tutorials has over 1,000 readers
  • RTFM Read the fabulous manual
  • Email Verified

Progress

12/44
How to earn trophies