Jump to content

Override existing functions


Sorata_Kanda

Recommended Posts

Hey everyone,

I'm wondering if you're able to override existing functions. I can image that doing on OOP side, but I don't know if it's possible to do so on a normal function.

For example:

function _setElementData( player, key, value ) -- Wrapper
  return setElementData( player, key, value, false )
end

Element.setData = _setElementData -- OOP
-- But why to do it on setElementData? Just simply setElementData = _setElementData?

Thanks in advance!

Link to comment
  • Discord Moderators

You can:

local _setElementData = setElementData -- Store the function in a var
function setElementData( player, key, value ) -- Wrapper
  return _setElementData( player, key, value, false ) -- call the old function
end
Element.setData = setElementData -- OOP

 

Link to comment

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...