codah's Recent Forum Activity

  • Hope this helps.

    edit: also had the same thought re containers while doing this.. might be preferable

  • Ah.. I was going to ask if you want a 'random one' or a 'random 1'

    You could loop through the array, and when you have a '1' you add the array index to a temporary array. Then use the above method on that array to get an index into the first array.

    [attachment=0:4gespslk][/attachment:4gespslk]

  • See the first answer above.

  • Right you are, was going from (bad) memory sorry :/

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I did scan the add-ons but I'll have another look. Thanks again

  • Browser object can do this.

  • I appreciate all your effort.. looks like I'm out of luck. I just wanted to grab some weather information and display the temperature :/ Do you know of any way to FTP a file into a C2 app?

  • Is this what you mean?

    https://www.dropbox.com/s/u9sqydw35hmoo ... .capx?dl=0

    I couldn't upload an attachment for some reason..

  • Go here and search for 'menu'.

  • Personally I hate populating arrays one at a time like that. Also is the id just +1 from the array index at all times? I'd make a function to initialize in a cleaner way.

    Start of layout

    function call "initGun" (1, 10, 400, 1)

    function call "initGun" (2, 5, 400, 1)

    function call "initGun" (3, 40, 300, 3)

    function call "initGun" (4, 100, 200, 10)

    On function "initGun"

    GunArray Set value at (function.param(0)-1, GUN_ID) to function.param(0)

    GunArray Set value at (function.param(0)-1, DAMAGE) to function.param(1)

    GunArray Set value at (function.param(0)-1, SPEED) to function.param(2)

    GunArray Set value at (function.param(0)-1, FIRE_RATE) to function.param(3)

    And you can also make a comment by adding another parameter that you don't use. ex:

    Start of layout

    function call "initGun" (1, 10, 400, 1, "pistol")

    function call "initGun" (2, 5, 400, 1, "rifle")

    function call "initGun" (3, 40, 300, 3, "shotgun")

    function call "initGun" (4, 100, 200, 10, "pea shooter")

    If I had an immense amount of guns I'd go a step further and add a txt file to the project that I'd load and with ajax and parse the data from it with tokenat().

    agreed but I thought that's another converstation

  • Paradox and edwardr

    if I had 4 columns of a "Gun" array: gunID, damage, speed, firerate

    Global constant number GUN_ID = 0

    Global constant number DAMAGE = 1

    Global constant number SPEED = 2

    Global constant number FIRE_RATE = 3

    so it reads:

    GunArray Set value at (0,GUN_ID) to 1

    GunArray Set value at (0,DAMAGE) to 10

    GunArray Set value at (0,SPEED) to 400

    GunArray Set value at (0,FIRE_RATE) to 1

    GunArray Set value at (1,GUN_ID) to 2

    GunArray Set value at (1,DAMAGE) to 5

    GunArray Set value at (1,SPEED) to 400

    GunArray Set value at (1,FIRE_RATE) to 1

    GunArray Set value at (2,GUN_ID) to 3

    GunArray Set value at (2,DAMAGE) to 40

    GunArray Set value at (2,SPEED) to 300

    GunArray Set value at (2,FIRE_RATE) to 3

    GunArray Set value at (3,GUN_ID) to 4

    GunArray Set value at (3,DAMAGE) to 100

    GunArray Set value at (3,SPEED) to 200

    GunArray Set value at (3,FIRE_RATE) to 10

    ahhhhh I feel better..

    I consider this best practice, it can be called 'self-documenting code' BTW it's the rows not the columns, and of course you can also do it for the columns (i.e. PISTOL=0, SHOTGUN=1, RIFLE=2 etc). So,

    GunArray Set value at (PISTOL, GUN_ID) to 1

    GunArray Set value at (PISTOL, DAMAGE) to 10

    GunArray Set value at (PISTOL, SPEED) to 400

    GunArray Set value at (PISTOL, FIRE_RATE) to 1

    and you can use these everywhere, not just when initialising the array. Also not meaning to be pedantic but, #defines for constants in C++? ... hmm don't do it

    [quote:3qjjiam2] and I make them all caps as well.

    edit: just remembered, C2 forces constant variables uppercase

  • The c2.addon file is designed specifically to make it super easy. All you have to do is drag and drop the file onto the Construct 2 window (so, have it running), and C2 does the rest. No creating folders or anything.

codah's avatar

codah

Member since 30 May, 2014

Twitter
codah has 1 followers

Trophy Case

  • 10-Year Club
  • Email Verified

Progress

11/44
How to earn trophies