Jump to content

[quick tip] How to avoid code duplication in Recipe constructor


U.N.Owen
 Share

Recommended Posts

Maybe this code will be usefull for someone:

local function AddModRecipe(...)
	if table.getn(arg) > 4 and GLOBAL.CAPY_DLC and GLOBAL.IsDLCEnabled(GLOBAL.CAPY_DLC) then
		table.insert(arg, 5, GLOBAL.RECIPE_GAME_TYPE.COMMON)
	end
	
	return GLOBAL.Recipe(GLOBAL.unpack(arg))
end

Note: we need use here GLOBAL.unpack instead table.unpack or unpack without prefix.

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
 Share

×
  • Create New...