Jump to content

How properly change function from component?

Recommended Posts

I can't understand what am I doing wrong.  :frown-new:

AddComponentPostInit("instrument",function(inst)	local old_play = inst.Play	function inst:Play(musician,...)		old_play(self,musician,...)	endend)

​This code makes Pan Flute unbreakable. And character say "I can't do that" while using it. However this code do nothing.

Edited by Maris
Link to comment
Share on other sites

Also I tried this:

AddComponentPostInit("instrument",function(inst)	local old_play = inst.Play	inst.Play = function(self,musician,...)		old_play(self,musician,...)	endend)

​and this:

local instr = require "components/instrument"local old_play = instr.Playfunction instr:Play(musician,...)	old_play(self,musician)end

​But it doesn't work properly.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...