Swap 2 objects in a larger code-chain?

Get help using Construct 2

Post » Sun Jan 29, 2017 11:46 am

Hello,

I work on a 2 player game and when I have a character finished for Player 1, I have to copy/paste the string of that Character and just replace the objects (P1model with P2model, P1bullets with P2bullets etc)
But I can't replace a thing, when both, the Player 1 and Player 2 objects are inside the string.

E.g. When hit player 2, reduce P1Stats.Damage from P2Stats.Health. (P1Stats is just an invisible object to safe information like damage, speed, health etc. so I can change it easily later)

Now when I replace P1Stats with P2Stats, there will be obviously only P2Stats left inside the string so I cannot just replace the missing P2Stats.
I kind of "solved" it by making an placeholderStats object so I can replace them first with it, and then with the actual object but isn't there an easier solution?
Last edited by 13spongg13 on Sun Jan 29, 2017 1:14 pm, edited 1 time in total.
B
13
S
2
Posts: 80
Reputation: 821

Post » Sun Jan 29, 2017 12:04 pm

That looks like a decent solution. That's what they thought us in basic programming for singular strings or quantities.
However it sounds like your ideal place holder would be a 2-dimensional array given that there are many quantities for player 1 and 2 (I'm guessing life, mana, spd...)

Array[0][x][x] can hold values for Player 1
Array[1][x][x] can hold values for Player 2 or something like that.
Image Image Image
B
31
S
11
G
27
Posts: 748
Reputation: 17,093

Post » Sun Jan 29, 2017 1:13 pm

@MPPlantOfficial
Thank you for your answer! I am going to inform me a bit more about arrays ^^
B
13
S
2
Posts: 80
Reputation: 821


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 48 guests