Loop inside loop - Load/Save, Timers, Rules

arltmiralarltmiral Member, PRO Posts: 11
edited May 2012 in Working with GS (Mac)
Hey folks.

I save data via "save attribute". My keys are built from two ids. One for the topic and one for the number of entries. This looks something like:

Timer
Every 0 seconds
- Rule
- Attribute: $k < 20
-
-- Save Attribute
-- $text to $i .. $k
-
- Change Attribute
- $k = $k+1

So all my data will be stored in keys like 50, 52, 53 up to 519 ($i = 5 in this example).


But now i'm having problems loading the data. I simply can't figure out how to set up a loop within a loop.
I thought about using two variables to search through all the rows (topics) and columns (entries).

I tried it with two Every-Timers and two Attribute-Rules: didn't work.
I tried it with an Every-Timer within a For-Timer and two Attribute-Rules: didn't work as well.


Any ideas?








Best Answer

  • arltmiralarltmiral Posts: 11
    Accepted Answer
    Maybe I don't understand what you are doing but I'm not sure how tables will help in this case, you will still need to loop to scan the table rows and columns.
    You're right. I'm just hoping that GS will come up with some database/tables related solutions.
    Any ideas how to do a loop-within-a-loop in GS?

Answers

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    Writeable tables are due this week, it will be a ton easier to do what you are doing.
  • arltmiralarltmiral Member, PRO Posts: 11
    Yeah I know ... writable tables would be a dream.

    I would be uber happy if GS will release it this week. Have been working on work arounds last days.
  • EatingMyHatEatingMyHat Member Posts: 1,246
    Maybe I don't understand what you are doing but I'm not sure how tables will help in this case, you will still need to loop to scan the table rows and columns.
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    Loops are a lot easier with tables because you can increment the row value without worrying about constructing an attribute.

    I have 1 actor going to one of 26 random locations based on what level we are playing with a single rule.

  • EatingMyHatEatingMyHat Member Posts: 1,246
    @jonmulcahy I agree that saving the data in a table will be much better for him, but if he does not know where the data is and have to scan the entire scope, his problem is the loop and not the table.

    @arltmiral to do a matrix loop you will need to do the following


    self.i = 1
    self.j = 1

    If self.i <= self.MaxRows (for tables there is a function for that)
    ---Every x seconds
    ---check value (table or saved attribute...)
    ---self.j = self.j + 1
    ---if self.j > self.Maxcolumns (for tables there is a function for that)
    ------self.j = 1
    ------self.i = self.i + 1

    Haven't tested it, but conceptually it should work :)
  • arltmiralarltmiral Member, PRO Posts: 11
    Well I know how it should work. (At least via using code). But I can't figure out how to perform this in GS. Looks like something gets mixed up with the timers.
Sign In or Register to comment.