How do I

0 favourites
  • 6 posts
From the Asset Store
Air War 1941
$5.60 USD
60% off
Full game Construct 2 and Construct 3 to post on Google Play
  • hi there ive got a problem which is annoying lol.

    im new to arrays but i thought id start using them in my project as its important to learn arrays. so i started off with something simple which follows.

    on object clicked - push "Barracks" on x axis (((array)))

    set value at (array.curx , 1) to globalvarible * 120 (((360)))

    so this adds an array of Barracks,360

    which works out perfect, so the next bit of code i want to happen is every 1 second subtract 1 from the 360 until it reaches 0 so i used code

    for each x element

    every 1 second - set value at (array.curx , 1) to array.curvalue - 1

    timer = true

    the reason ive done the code like this is i plan to add several more items to the array each with its own timer in Y, so i constantly want it to subract 1 from each Y until it hits 0 but the code just sets the array to (barracks,barracks) so im not sure what im doing wrong. i hope this makes sense.

    im sorry havent provided a .capx file as its a secret project also a screenshot would be hard as the codes are all under seperate categorys on different pages which would mean alot of copy and pasting

  • can anyone enlighten me please. i think the problem is with this code set value at (array.curx , 1) to array.curvalue - 1

  • It is viewed unfavorably for you to bump your own topic within 24 hours.

    If your project is secret/complicated, at least you could make a new project isolating the issue you are having trouble with. You would be able to get help quicker and more accurate assistance.

    But from what I can see, the problem is:

    every 1 second - set value at (array.curx , 1) to array.curvalue - 1

    This should be array.at(array.curx, 1). See if that works?

  • for each x element

    every 1 second - set value at (array.curx , 1) to array.curvalue - 1

    timer = true

    Value at(a,b) implicates that this is a 2D array. With index a on the X axis. And index b on the Y Axis.

    For each element x ... runs trough all indexes on the X-axis. Meaning the array.curvalue contains a value stored on the X Axis (only).

    So, yes, you store on each each index 1 on the Y axis ... for each index on the X axis .. the value that is stored on that X axis.

    Rather.

    I like to recommend a global variable to remember what the Y axis is meant to be.

    Say Global variable 'Counter_Y' (number) = 1

    Every 1 second

    System ... For "index_X" .. from 0 .. to array.width - 1

    ______Array ... set value at (loopindex("index_X" , Counter_Y) to Array.At(loopindex("index_X" , Counter_Y) - 1

  • hey thanks alot for the replies. did i mention im new to arrays? but to explain the array better im trying to have the array have research names on x axis and the timer until its research on the x axis below it so y1. then the plan is when it hits 0 ill use if array contains 0 put cur x into another array with all research items. also im trying to do it in an odd way as you might be researching loads of different things at the same time with different times.

    p.s i dont usually bump but this problem has been giving me a headache all day

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • oosyrag i worked out what you ment and it worked. i thank you kind sir .

    ok so i was wrong i got the next one working but now it doesnt count down both of the arrays just the first one thats added any ideas?

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