How to add to a function

i wonder if i am able to add to a function (append)
like this

function functorun()
     print("waffle fries")
end
addtofunc print"regular fries"

since i got a stackoverflow trying to do this

			local a = function(hit)
				lfunc()
				module.translate(line)
			end
			lfunc = a
			functions["touched"] = a

i was just wondering how i might be able to do that but not get a stack over flow?
edit: it is runing in a for loop for each line

You can define a new function that starts by calling the first.

You can’t redefine the function to call itself, that will lead to an infinite loop like you experienced.

If you give more details about why you want to do this we can come up with a better solution.

what do you mean by " define a new function that starts by calling the first." example?
since i have no idea what you’re talking about and how to recreate it

I’m not entirely sure what you’re trying to achieve but I assume it’s something similar to the following.

local function doFunction(functionValue, ...)
	functionValue(...)
end

doFunction(print, "Hello", "world!") --Hello world!

Like

function functorun()
  print("waffle fries")
end
function extendedfunc()
  functorun()
  print("regular fries")
end

Then call extendedfunc()

1 Like