HELP. Advanced instance variable help needed. [Solved]

Get help using Construct 2

Post » Sat Jan 23, 2016 10:36 pm

This looks like it could work but how do you change UIDs and will changing them effect the game?
B
14
S
2
Posts: 55
Reputation: 762

Post » Sat Jan 23, 2016 11:26 pm

You cannot change UID, that's the point. You can also pick instances by "instanceName" as I described here: how-to-quot-construct-quot-an-object-name-using-variables_t152556?start=10
Image
B
28
S
15
G
54
Posts: 854
Reputation: 31,237

Post » Sun Jan 24, 2016 12:07 am

Thanks for the help, but I'm not understanding how this will work, I've made a little demo capx with just 4 weapons but it will have all the proper features. I'll post it later and it will contain all the info needed for you to understand my side.
B
14
S
2
Posts: 55
Reputation: 762

Post » Sun Jan 24, 2016 8:35 am

drive.google.com/file/d/0B6FgXCrZ1bnZZ2k5NFdNcHJLekk/view?usp=sharing
That is the capx for my project, it has enough info on it, if anyone can solve it please tell me or better, repost it solved.

just put the http:// infront of the thing, because of my limited reputation i cant technically post them.
B
14
S
2
Posts: 55
Reputation: 762

Post » Sun Jan 24, 2016 10:28 am

Here you go https://drive.google.com/file/d/0BwT_0l ... sp=sharing

I fixed it according to your project, but imo it needs some refactoring. First of all you are using arrays but not arrays functionality, you just use them as holders for instance variables... so you could move those instance variables to guns family and use UIDs which are faster then "codes".

Anyway I've made it here based on "codes".

You also could do it differently in the way you have it but I'm not sure if you realize that you set gun_data "active" property, but you never read it... so engine had no idea which gun data you want to use. You could loop the family and check for "active" property... but picking by UID is surely better idea, and much faster.

Anyway it works, hope you understand the changes, so you could implement it in the rest of the project.

Good Luck
Image
B
28
S
15
G
54
Posts: 854
Reputation: 31,237

Post » Sun Jan 24, 2016 10:40 am

Thank you so much, IT WORKS!!!
This is going to make a huge difference to my game and i hope you realise that, hopefully, as well i will be able to better understand this and eventually help other people.
One more time, thank you.
B
14
S
2
Posts: 55
Reputation: 762

Post » Sat Jan 30, 2016 5:14 pm

currypuff wrote:Thanks but the instance variables on the weapons which I think your talking about wont work because of two reasons, instance variables reset when their object is deleted and the stats will change throughout the game.

Yea, that is why I am saying keep all of your weapon stats in JSON and stored in memory in a Hash object, then you can use:
On Created "weapon1" > Set instance var1 = Hash.At("weapon1.stat1"); Set instance var2 = Hash.At("weapon1.stat2"); ...

It looks like you got it though. :)
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,317
Reputation: 4,628

Previous

Return to How do I....?

Who is online

Users browsing this forum: zenox98 and 5 guests