Notifications
Clear all

[Closed] Getting parameters from simplemod and saving with file?

I’ve got a scripted simplemod class that I’m using to provide parameters to my exporter script, and Bobo has helped me immensely with getting through a few roadblocks, including determining where the modifiers are which originally was pretty much all I needed…but I’ve combined several into one, with a series of checkbox parameters for the values.

Here’s my simplemod:


plugin SimpleMod XPlaneObj8Mesh
name:"X-Plane Mesh Params" 
classID:#(0x6503c0ba, 0x2f4d4c06) 
version:1
(
	parameters main rollout:XPlaneObj8MeshParams
	(
		ATTR_cockpit	type:#boolean	ui:boxATTR_Cockpit
		ATTR_hard	type:#boolean ui:boxATTR_Hard
		ATTR_cull	type:#boolean ui:boxATTR_Cull
		ATTR_blend	type:#boolean	ui:boxATTR_Blend
		ATTR_depth	type:#boolean	ui:boxATTR_Depth
	)
	rollout XPlaneObj8MeshParamsInfo "X-Plane Mesh" width:162 height:319
	(
	label lab1 "Designates object"
	label lab2 "with misc X-Plane"
	label lab3 "Obj Attributes"
	)
	rollout XPlaneObj8MeshParams "Mesh Attributes" width:162 height:319
	(
		checkbox boxATTR_Cockpit "Cockpit" height:15
		checkbox boxATTR_Hard "Hard" height:15
		checkbox boxATTR_Cull "Cull" height:15
		checkbox boxATTR_Blend "Blend" height:15
		checkbox boxATTR_Depth "Depth Check" height:15
	)
	on map i p do
	(
		-- We do nothing here
	)
)

This basically allows me to tell the exporter which attributes to apply to the the geometry I’m currently evaluating.

I was using a function call that Bobo gave me that would return true if a modifier existed:


fn hasModifier theObj theModClass =
(
(for m in theObj.modifiers where classof m == theModClass collect m).count > 0 
)

and it worked beautifully…but what I need to do is get the parameters from the modifier no matter where in the stack of modifiers it was applied (by name maybe?)…

I tried using this code


if hasModifier allObj[i] XPlaneObj8Mesh then
(
	MeshMod = allObj[i].modifiers["XPlaneObj8Mesh"]
	if MeshMod.ATTR_cockpit == true then ATTR_cockpit = true
	if MeshMod.ATTR_hard == true then ATTR_hard = true
	if MeshMod.ATTR_cull == true then ATTR_cull = true
	if MeshMod.ATTR_blend == true then ATTR_blend = true
	if MeshMod.ATTR_depth == true then ATTR_depth = true
)


But it doesn’t work…it fails on the “if Meshmod.ATTR_cockpit == true then ATTR_cockpit = true” saying that “Unknown property: “ATTR_cockpit” in undefined”

hasmodifier is working, and its getting inside the if…setting Meshmod is NOT failing, so its passing it, but apparently its not returning anything.

Also, when I apply a modifier and set one of the checkbox…then save the file…when I load the max file back up, the modifier is still applied, but the checkbox isn’t checked…any ideas on any of these things???

Thanks!!!

3 Replies

hi,

MeshMod = allObj[i].modifiers[“XPlaneObj8Mesh”]
should be :
MeshMod = allObj[i].modifiers[“X-Plane Mesh Params”] – the name of the modifier

Also, make shure the modifier plugin is always loaded: place the Script file in the ‘scripts\startup’ folder

That worked! Thanks!

Now since I am using the actual Name of the modifier…what if there’s more than one of the same modifier applied? For example…if I have another simplemod called AnimRotate, which specifies the parameters for the sim to rotate the geometry with a specific dataref from the sim…in the case of a flight stick, I would need to apply two rotates…one for the pitch action of the flight stick and one for the roll action…so there would be a modifier for x rotation and a modifier for y rotation, and I’d need to be able to call them separately…is that possible?