Using Variables inside of Variables

0 favourites
  • 3 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I'm wondering if there is a way to simplify tons of code by using multiple variables within a single variable. ie:

    Global Variable - Weapon (text) = "Shotgun"

    Global Variable - WeaponDamage (number) = 5

    On bullet collision, set damage to int(str(Weapon)&"Damage").

    Something like this could allow you to have 1 event for damage if you have multiple weapons that each have their own damage parameters.

    However, it's not working for me, but is this something that could potentially work?

  • Place them in an array

    array = DamTable (weapon1 ) (weapon2 ) (weapon3 )

    then you set weapon to appropriate value when equipped ( i.e. if shotgun is equipped and shotgun is weapon2 then set weapon=1

    then the on bullet collison=

    set damage to DamTable(weapon)

    you could also keep track of weaponx names in the array via:,1)="Assault Rifle",1)="Shotgun",1)="Knife"

    This would also reflect addressing the damage as it would go from to,0) etc

    otherwise I don't believe you can use variables such as, shotgun.damage etc

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Kosiam - ah, of course! I can't believe I didn't think of that. Thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)