How can I write this logic?

3absh3absh Member Posts: 601

Constrain Self.Color.red of actor to tableCellValue(Table1, something, 1)

In Something what I need is to attach this value to:

Every 10 days row=row+1 until day 100 is reach
@day 101 the count starts over again and row = 1


I know it has something to do with ceil & Mod but I can't seem to figure it out.

Comments

  • 3absh3absh Member Posts: 601

    Ceil(daycount/10)
    will certainly give me a counter every 10 days to attach the row to, but I need a loop to start again @day 101

  • 3absh3absh Member Posts: 601

    This is what I did, I hope it works (fingers crossed)

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited March 2016

    @abuabed84 said:

    This is what I did, I hope it works (fingers crossed)

    Just test it with a substitute attribute to replace your scene attribute and modify it with the keyboard input.

  • 3absh3absh Member Posts: 601
    edited March 2016

    It didn't work, problem with a Module loop is that it restarts at zero.
    Mod(1,5)=1
    Mod(2,5)=2
    Mod(3,5)=3
    Mod(4,5)=4
    Mod(5,5)=0 (row in table starts at 1 not zero)

    So this is not working

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    @abuabed84 said:
    It didn't work, problem with a Module loop is that it starts at zero.
    Mod(1,5)=1
    Mod(2,5)=2
    Mod(3,5)=3
    Mod(4,5)=4
    Mod(5,5)=0 (row in table starts at 1 not zero)

    So this is not working

    Can you have a rule that resets the counter when ten days pass?

  • 3absh3absh Member Posts: 601

    Can you have a rule that resets the counter when ten days pass?

    Exactly, I'm thinking of wrapping the code inside a loop but I haven't figured it out yet. (actually the rest should occur at day 101)

  • MantoManto Member Posts: 796

    This should work:
    mod(floor(Day/10),10)+1

  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2016

    @abuabed84 said:
    It didn't work, problem with a Module loop is that it restarts at zero.
    Mod(1,5)=1
    Mod(2,5)=2
    Mod(3,5)=3
    Mod(4,5)=4
    Mod(5,5)=0 (row in table starts at 1 not zero)

    So this is not working

    Mod(0,5)+1 =1
    Mod(1,5)+1 =2
    Mod(2,5)+1 =3
    Mod(3,5)+1 =4
    Mod(4,5)+1 =5

    . . . . or, if the first value in the mod calculation is an attribute (let's call it X) and [i]needs[/i] to be 1,2,3,4 and 5 then . . .

    Mod(X-1,5)+1

  • 3absh3absh Member Posts: 601

    @Manto said:
    This should work:
    mod(floor(Day/10),10)+1

    It WORKED!!!

    @Manto Thank you and to all those who helped

  • 3absh3absh Member Posts: 601

    @Socks
    Yes your method is the same as @manto 's
    excellent :)

Sign In or Register to comment.