#How to make dynamically generated widgets in lua?

1 messages · Page 1 of 1 (latest)

rare jungle
#

Hello, I was wondering how someone can for example make x amount of widgets of for example a text or image.
Is there any way to achieve that? Because i currently only had to do with moving / editing widgets written in a json.
Would be great to know as this is a current problem im on rn.

rare jungle
#

found it out, i will post the createcode for this thing:

-- Function to create widgets
function createWidgets(parentName, numWidgets)
  -- Loop to create the specified number of widgets
  for i = 1, numWidgets do
      -- Create a label element and set its text
      local labelName = parentName .. ".label" .. i
      widget.addChild(parentName, {
          type = "label",
          value = "      TestModule " .. i,
          zlevel = 4,
          fontSize = 15,
          position = {0, 30*-i}
      }, labelName)
  end
end