Call a method in a for loop?

I just started a new project and am using OOP this time around since I’ve pretty much only used functional programming to date and have barely messed around with OOP and I’m drawing a blank on how to call a method in a for loop?

I basically have a for loop in a module that assembles (calls all the methods) within the module when the assemble method is used but I don’t know how to call them in a for loop with “:” since it’s in a for loop? This is probably really simple idk why I can’t figure it out lol.

function input:assemble(player)
	self.player = player
	self.Sword = {{}, .35}
	
	for i,v in pairs(self) do
		if v ~= self.assemble and type(v) == "function" then
			print(i)
			self[i]() --this calls the methods but doesn't pass the "self" argument since I'm not calling the functions as a method.
		end
	end
end
1 Like

(post deleted by author)

1 Like

If you are going to reply on the dev forum you should only reply if you have a actual answer not “I don’t understand your issue bye”.

Don’t know if this will work, but you could try passing self in AS a parameter.

self[i](self)

You would just have to receive self as an argument for each method within the class.

I feel like there is a better way to do this, though. I’ll keep thinking.

3 Likes

Thanks, just figured it out in a vc call, I was drawing a blank and haven’t really used OOP much.