Scripting API Changes of Moho 14.0

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
Stan
Posts: 199
Joined: Sun Apr 19, 2009 3:22 pm

Scripting API Changes of Moho 14.0

Post by Stan »

Hi all,

I have extracted all new API changes for Moho 14.0. The list of the features is below. All of them have been added to mohoscripting.com. Please note that I'm not a LostMarble official, and I don't have any access to any internal API resources. Everything you see below is just a list of changes manually extracted from the pkg files that come with the official Moho 14.0 release. Enjoy!

Code: Select all

Module MOHO
	New constants:
		GRADIENT_LINEAR 0
		GRADIENT_RADIAL 1
		GRADIENT_REFLECTED 2
		GRADIENT_ANGLE 3
		
		COMBO_NORMAL 0
		COMBO_ADD 1
		COMBO_SUBTRACT 2
		COMBO_INTERSECT 3
	
	New class ScriptInterfaceHelper:
		ScriptInterface MohoObject()
		
	Class ScriptInterface
		New methods:
			bool HasMaximumWarpLayers()
			bool HasMaximumSmartBones()

	Class MohoGlobals
		Removed properties:
			bool ShowDocumentTabs
			bool ConfirmRevertDocument
			
	Class MohoLayer
		Method QualityFlags() now returns uint32 instead of int32
		Method SetQualityFlags:
			The flags argument's type changed from int32 to uint32
			New argument:
				bool recursive = false
		Added methods:
			void CopyTransform(MohoLayer* fromLayer)
		Renamed methods:
			SetDistortionMeshLayer is now SetWarpLayer
			GetDistortionMeshLayer is now GetWarpLayer
			
	Class MeshLayer
		New methods:
			void PauseContinuousTriangulation(bool b)
			bool IsWarpLayerCandidate(bool curverOnly = false)
			void MarkAsWarpLayer(bool b, MohoLayer *target)
			bool IsWarpLayer()
			void MarkAsCurver(bool b)
			bool IsCurver()
		
		Renamed methods:
			SetNeedsWarpMeshUpdate is now SetNeedsWarpLayerUpdate
			UpdateWarpMesh is now UpdateWarpLayer
		New property:
			bool fSquashableCurveDeformer

	Class BoneLayer
		New properties:
			AnimVal	fGravityDirection
			AnimVal	fGravityStrength
			
	Class MohoDoc
		New method:
			M_Style *AddStyle(const char *styleName)		
		New arguments:
			Methods PrepUndo
				bool willOnlyAddPoints = false

	Class M_Curve
		New method:
			void DeleteCurvatureKey(int32 id, int32 when)
			
	Class M_Style
		New methods:
			void SetGradient(int32 gradientType, bool allowTransparency = false)
			void SetGradientColor(real position, rgb_color color)
		New properties:
			real fBrushSizeVariationAmp
			real fBrushSizeVariationScale
			int32 fBrushRandomInterval

	Class MohoView
		New arguments:
			Method FloodSelect:
				int32 curveEndExtensionDistance = 20
				bool useShapeStrokes = false
				int32 expansionOnStrokes = 0

	Class M_Shape
		New methods:
			bool ContainsCurve(int32 curveID)
			void SelectAllPoints()
			bool AllPointsSelected()
			LM_BBox	ShapeBounds()
			LM_BBox	EdgeBounds(int32 edgeID)
			bool	IsInCluster()
			M_Shape	*BottomOfCluster()
			M_Shape	*NextInCluster()
			M_Shape	*PreviousInCluster()
			M_Shape	*TopOfCluster()
		New properties:
			int32 fComboMode
			AnimVal fComboBlend

	Class M_Mesh
		New methods:
			int32 CombineShapes(M_Shape *shape1, M_Shape *shape2, int32 comboMode, real blendFactor, bool keepOriginals);
			int32 BakeCombinedShapes(M_Shape* shape, bool keepOriginals)
			void EnableCleanup(bool on, bool guaranteedClean = false);	
		New arguments:
			Method DeletePoint:
				bool preserveHandles = true
			Method PrepFixedHandles:
				int32 frame
			Method PreserveHandlePositions
				int32 frame
			
	Class M_Bone
		New methods:
			bool AreDynamicsActive();
			real AngleWeight();
			void SetAngleWeight(real w);
			real PosWeight();
			void SetPosWeight(real w);
			real ScaleWeight();
			void SetScaleWeight(real w);
		New arguments:
			Method DisplayWidth:
				real displayScale
		New properties:
			int32 fAngleControlDelay
			int32 fPosControlDelay
			int32 fScaleControlDelay
			bool fAngleDynamics;
			bool fPosDynamics;
			bool fScaleDynamics;
			real fPosTorqueForce;
			real fPosSpringForce;
			real fPosDampingForce;
			real fScaleTorqueForce;
			real fScaleSpringForce;
			real fScaleDampingForce;
		Renamed properties:
			fTorqueForce is now fAngleTorqueForce
			fSpringForce is now fAngleSpringForce
			fDampingForce is now fAngleDampingForce
		
Module LM		
	Class BBox
		New methods:
			bool Contains(const LM_BBox& box);
			bool Intersects(const LM_BBox& box);

Module LM.GUI
	New constants:
		UNIT_NONE 0
		UNIT_PERCENT 1
		UNIT_PIXELS 2
		UNIT_DEGREES 3
		UNIT_FPS 4
		UNIT_MULT 5
		UNIT_FRAMES 6
		
	Class LM_Graphics_OpenGL_Fixed
		Renamed methods:
			OpenGLMode is now GPUMode
	
	Class LM_TextControl
		New methods:
			void SetUnits(int32 unitType);
			void SetPercentageMode(bool percentageMode);
			void SetMaxDecimalPlaces(int32 n);
	
	Class LM_AngleWidget
		New method:
			void AllowWrapAround(bool b)
	
	Class LM_LayoutView
		new comment:
			Method AddPadding: Pass a value of 0 for flexible padding that will expand to fit available space.
________________________________________________________________________
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
User avatar
hayasidist
Posts: 3526
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Scripting API Changes of Moho 14.0

Post by hayasidist »

Also note that Moho 14 uses Lua 5.4 not 5.2 -- see the Introduction page under the sub-heading "Lua Versions" for more information and how to make scripts compatible with both versions (this is not always necessary if your script doesn't use stuff such as some math.xxx() and bit-wise operations).

Channel codes have also changed, and the site now shows the current (and past) values -- but if you've only ever used the identifiers (i.e. you've avoided explicitly coding the numbers) you won't notice the difference.

I'll check the other "constants" and will update in the near future if there are any significant changes.
User avatar
meix
Posts: 13
Joined: Thu Oct 30, 2008 2:29 pm
Location: Estonia
Contact:

Re: Scripting API Changes of Moho 14.0

Post by meix »

Yes, great update but MeshLayer's vector noise interval seems to be left out once again :)

Image
User avatar
hayasidist
Posts: 3526
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Scripting API Changes of Moho 14.0

Post by hayasidist »

meix wrote: Fri Oct 27, 2023 8:30 am Yes, great update but MeshLayer's vector noise interval seems to be left out once again :)
request logged!
SuadAnny
Posts: 2
Joined: Tue Nov 29, 2022 10:46 am

Re: Scripting API Changes of Moho 14.0

Post by SuadAnny »

It's always a bit of a dance when they update the Lua version, isn't it? Good to know about the compatibility tweaks, especially if you're diving into some math-heavy stuff. And those channel code changes sound like they could trip up some folks, but it's cool that the site's keeping track of it all. On a somewhat unrelated note, I've been tinkering with niche marketplace development lately, and let me tell you, it's been quite the journey. Balancing user experience with functionality while catering to a specific audience can be tricky, but oh-so-rewarding when you get it right. Anyone else here dabbling in niche markets?
Post Reply