For loop not completely working?

0 favourites
  • 4 posts
From the Asset Store
For Adventure, Action, Heroes, Sci-fi and Action-RPG games.
  • Hi guys, I've got the following event sheet:

    However, only the first two text fields get set, but the buttons do show and when clicked do what they should do. The following JSON code is behind LIST:

    {"c2array":true,"size":[4,3,1],"data":[[["2kt2JbodBptBZCuPxKDKGQ"],["3434"],[1]],[["Mx+ENw3RXZfdfDCyM6P8kQ"],["Tariq is xx"],[1]],[["RC9SJZNPUYNon8nUi-6BRA"],["Of nee, Tariq is xx'],[1]],[["bdmbGBb5xxKeOJzjhFyuiA"],["Verhaal12345"],[1]]]}[/code:xu8btf12]
    
    Does anybody see what the problem is?
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I wasn't going to log on, but your did 4 horrible things here.

    1. Don't clone or duplicate objects as your doing.

    Instead create 1 Object, give them a custom variable name/id.

    Sprite1,2,3,4,5 is bad

    Text 1,2,3,4,5 is bad

    instead

    Sprite.id = 1, Sprite.id = 2, Sprite.id = 3, Sprite.id = 4, Sprite.id = 5

    same with text you have

    2. You don't list all valid numbers.

    You use curStory to check against for the IF statements, yet we don't know where curStorys starts.

    AND

    Button Loop starts at 1, but we have no idea what numberStory last number.

    3. If your not using the LoopIndex("Button") to get your number

    Do you really need a loop?

    4. If Number story which set's the loop count is related to your Array. Your Array Width is only 4. If your loop is based on Array Width then the loop only last's to a count of 4. If your loop count is for then CurStory will only ever be starting value of curStory + 4.

    5. Did I say 4? I meant 5.

    We are here to help, however the website is supposed to family friendly. And while I know the word "gay" can be jolly, such as "a gay old time" to mean a happy jolly time. The current slang and the context of use can be derogatory.

    Instead you should destroy what you have and make it over all better.

    Assign the variables to the objects instead of duplicating objects. This means you only need to include it in the list once.

    For Loop Button 4 to 8

    --//Event to build SOL would be

    --Text.id = loopindex("Button")

    --Sprite.id=loopindex("Button")

    --// actions would be

    Sprite.visible set true

    Text.visible set true

    Text..text = titlevalue

  • What is the starting value for curStory? and starting value for storyTitle? and value of numberStory?

    if curStory starts at 1, and numberStory is 5, then the first 2 times through the loop nothing will happen because curStory would be 2, then 3 - and you don't start setting the text fields until it gets to 4.

    Also, it looks like you are trying to set up a menu of 5 titles, but your json array only has data for 4. And since the loop may not be doing anything the first two times it runs, then after that it may be setting text fields on the 3rd and 4th times through - and then running out of data in the array...

    but I would need to see a little more code to know for sure...

    (well, I see jayderyu beat me to it, lol)

  • I wasn't going to log on, but your did 4 horrible things here.

    1. Don't clone or duplicate objects as your doing.

    Instead create 1 Object, give them a custom variable name/id.

    Sprite1,2,3,4,5 is bad

    Text 1,2,3,4,5 is bad

    instead

    Sprite.id = 1, Sprite.id = 2, Sprite.id = 3, Sprite.id = 4, Sprite.id = 5

    same with text you have

    2. You don't list all valid numbers.

    You use curStory to check against for the IF statements, yet we don't know where curStorys starts.

    AND

    Button Loop starts at 1, but we have no idea what numberStory last number.

    3. If your not using the LoopIndex("Button") to get your number

    Do you really need a loop?

    4. If Number story which set's the loop count is related to your Array. Your Array Width is only 4. If your loop is based on Array Width then the loop only last's to a count of 4. If your loop count is for then CurStory will only ever be starting value of curStory + 4.

    5. Did I say 4? I meant 5.

    We are here to help, however the website is supposed to family friendly. And while I know the word "gay" can be jolly, such as "a gay old time" to mean a happy jolly time. The current slang and the context of use can be derogatory.

    Instead you should destroy what you have and make it over all better.

    Assign the variables to the objects instead of duplicating objects. This means you only need to include it in the list once.

    For Loop Button 4 to 8

    --//Event to build SOL would be

    --Text.id = loopindex("Button")

    --Sprite.id=loopindex("Button")

    --// actions would be

    Sprite.visible set true

    Text.visible set true

    Text..text = titlevalue

    Woops, I did not even realize that I went overboard with the JSON, I edited that out.

    Thanks alot, this has pushed me into the right direction I'll be more careful next time with supplied data and make sure to include more (detailed) info :p

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