-1
function newpos(xScale, xOffset, yScale, yOFfset)
    print(f.Position)
end

local f = {}
f.Position = 1
f.Size = newpos(1, 0, 1, 0)
f.Filled = true
f.Visible = true

how do i get the f table from newpos?

vozoid
  • 1
  • 2
    You have to pass it in as a parameter. – Lasse V. Karlsen Jan 03 '22 at 08:39
  • 3
    I can't make sense of your question. what's a calling variable? why is f being index in newpos? it is a nil value. you cannot index a nil value. please explain what you are trying to achieve. as you're currently asking about a http://xyproblem.info – Piglet Jan 03 '22 at 08:42
  • 2
    You can move the line `local f = {}` above the `newpos` definition. – Egor Skriptunoff Jan 03 '22 at 09:00

1 Answers1

0

how do i get the f table from newpos

If you want to get a table from a function that function needs to return that table.

Let's say you want to create a table that represents a 2d point:

function newpos(x, y)
  local p = {
    x = x,
    y = y,
  }
  return p
end

Then you can do something like

local origin = newpos(0, 0)
print(origin.x, origin.y)
Piglet
  • 27,501
  • 3
  • 20
  • 43