Board Thread:Lua Help/@comment-24473195-20140814161206/@comment-24473195-20140820120229

I managed to get it working in a somewhat hacky manner: function p.getFrame(bParent) local oFrame = mw.getCurrentFrame if bParent and oFrame~=nil and oFrame:getParent then oFrame = mw.getCurrentFrame:getParent end return oFrame end

--Get Parent of calling page/parent. This requires (Extension:Variables) function p.getVar(sVariable,bParent) if not(sVariable) then return end local oFrame=p.getFrame(bParent) local sVar if (oFrame~=nil) then sVar = tostring( mw.getCurrentFrame:preprocess('')) end return sVar end

--Define variable of calling page/parent. (Extension:Variables) function p.defineVar(sVariable, sNewValue, bParent) if not(sVariable) and not(sNewValue) then return end local oFrame=p.getFrame(bParent) if (oFrame~=nil) then oFrame:preprocess('') end end

Basically, I check whether you want the value from the current frame or a parent frame, and then return the appropriate variable. This is useful for when you want to retrieve a frame from a general template/or from the page calling the template.

Also you can change the variables using the frame, by sending a variable as a parameter,e.g. :

{{#invoke:example|functionname|{{{10|{{#var:variablename}}}} That fixed the problem for me. You still require the variables extension though.