GSE: Sequences, Variables, Macros

GSE: Sequences, Variables, Macros

8M Downloads

[BUG] Repeat block is not inserting into the correct place

Opened this issue · 8 comments

commented

Ever since GSE 3.0 has been released, I've been trying to get repeat blocks to work. But either they don't or I just can't wrap my head around it.

Going by the block specs a Repeat block should be:

be repeated within this main block every n times

The example is multiple block macro with a Repeat block leading it. The Repeat block is supposed to be repeated every _n_th line.

Let's give this a try:

{
    ["Variables"] = {
        
    },
    ["Actions"] = {
        [1] = {
            [1] = "/say Repeat",
            ["Type"] = "Repeat",
            ["Repeat"] = "3"
        },
        [2] = {
            [1] = "/say Action 1?",
            ["Type"] = "Action"
        },
        [3] = {
            [1] = "/say Action 2",
            ["Type"] = "Action"
        },
        [4] = {
            [1] = "/say Action 3",
            ["Type"] = "Action"
        },
        [5] = {
            [1] = "/say Action 4",
            ["Type"] = "Action"
        },
        [6] = {
            [1] = "/say Action 5",
            ["Type"] = "Action"
        }
    },
    ["InbuiltVariables"] = {
        
    }
}

Going by the example this should result in the follow chat output for 8 key presses:

Repeat
Action 1
Action 2
Repeat
Action 3
Action 4
Repeat
Action 5

What I actually get is:

Repeat
Action 1
Action 2
Action 3
Action 4
Action 5
Repeat
Action 1

The same happens, if I put it into a Loop.

What am I missing? And is there any other why to define the n in the interface? Or just in Raw Edit?

commented

you should be getting this based off your example.

Repeat (action 1)
Action 2
Action 3
Action 4
Repeat (action 1)
Action 5
Action 6

Looks like its out by one from what you are getting

commented

I need to walk away a bit - is it ok if i fix this in the morning my time? (About 12 hours)

commented

Looks like its out by one from what you are getting

Ah, it doesn't count the Repeat block itself for the n? So the Repeat value defines the number of key presses before it gets repeated?

I need to walk away a bit - is it ok if i fix this in the morning my time? (About 12 hours)

Absolutely! I'm just still exploring!

commented

Got it - the math is wrong hence why its not going where it should.

if you run the following at https://www.lua.org/cgi-bin/demo what you should get back is a, b, f, c, d, f, e


local inserts = {{"f", 2, 2}}


for k,v in ipairs(inserts) do

  local insertcount = math.ceil((#returnActions - v[3]) / v[3])
  local insertStart = v[2]
  local numactions = #returnActions

  for i=1, v[2] do
    local insertpos 
    if i > 1 then 
      insertpos = insertStart  + 1
    else
      insertpos = insertStart  +  i * insertcount + 1
    end
    table.insert(returnActions, insertpos , v[1])
  end
end

for k,v in ipairs(returnActions) do
  print(k,v)
end
commented

now to get it to work in GSE

commented

Its in the latest alpha. Have a couple of other things to release then it will be in 3.0.15

commented
commented

It still doesn't seem to be working for me.

Here is a sample macro:

{
    ["Variables"] = {
        
    },
    ["Actions"] = {
        [1] = {
            [1] = "/say Repeat",
            ["Interval"] = 3,
            ["Type"] = "Repeat"
        },
        [2] = {
            [1] = "/say Action 1",
            ["Type"] = "Action"
        },
        [3] = {
            [1] = "/say Action 2",
            ["Type"] = "Action"
        },
        [4] = {
            [1] = "/say Action 3",
            ["Type"] = "Action"
        },
        [5] = {
            [1] = "/say Action 4",
            ["Type"] = "Action"
        },
        [6] = {
            [1] = "/say Action 5",
            ["Type"] = "Action"
        },
        [7] = {
            [1] = "/say Action 6",
            ["Type"] = "Action"
        }
    },
    ["InbuiltVariables"] = {
        
    }
}

It's compiled template:

Step 1
/say Action 1

Step 2
/say Action 2

Step 3
/say Action 3

Step 4
/say Action 4

Step 5
/say Action 5

Step 6
/say Action 6

And output for ten manual key presses:

Action 1
Action 2
Action 3
Action 4
Action 5
Action 6
Action 1
Action 2
Action 3

The Repeat block never gets called.