Callbacks error

Whenever I test my code I generally do it in the listener window. The Callback I created works fine when executed from there, but when implemented into my script it gives me a "Call needs function or class, got: undefined"

I defined my function... :/ Why is it not seeing it?
I believe this has something to do with globals and placement (scope) of the code but that stuff blows my mind. lol Been sorta self teaching myself through the maxscript help and scouring forums for help... super slow learning process.

Any help would be greatly appreciated :)

macroScript Bigley_Test
category:"Bigley"
toolTip:""
(
	global MainDialog
	global rloutOtherRollouts
 
	if MainDialog == undefined do(
		MainDialog = newrolloutfloater "Main Dialog" 232 806 
	)
 
	if MainDialog !=undefined do
	(
		closerolloutfloater MainDialog
		MainDialog = newrolloutfloater "Main Dialog" 232 806
	)
 
	rollout rloutOtherRollouts "Other Rollouts"
	( -- Other Rollouts
	)
 
	fn MainDialog_Refresh =
	(
		closerolloutfloater MainDialog
		macros.run "Bigley" "Bigley_Test"
	)
 
	callbacks.addscript #selectionSetChanged "MainDialog_Refresh()" id:#MainDialogCallbacks
	-- callbacks.removeScripts #selectionSetChanged id:#MainDialogCallbacks
 
	addrollout rloutOtherRollouts MainDialog
 
)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jeremiah_bigley's picture

Fantastic! Sorry for the

Fantastic! Sorry for the delayed response. Been super busy at work so I haven't been able to get back to the script. Everything seems to be working awesomely though! You rock man!

:DDDDD

Anubis's picture

yes, you get it rigth

Your function should be visible in the global scope.For example, as your rloutOtherRollouts is already defined as global, you can put your function inside that rollout and then register it using the full path - rloutOtherRollouts.MainDialog_Refresh, ie something like this:

macroScript Bigley_Test 
category:"Bigley" toolTip:"" 
(
	global MainDialog, rloutOtherRollouts
 
	if MainDialog == undefined then
	(
		rollout rloutOtherRollouts "Other Rollouts"
		(
			fn MainDialog_Refresh =
			(
				closerolloutfloater MainDialog
				macros.run "Bigley" "Bigley_Test"
			)
 
			on rloutOtherRollouts open do
			(
				callbacks.addScript #selectionSetChanged \
				"rloutOtherRollouts.MainDialog_Refresh()" \
				id:#MainDialogCallbacks
			)
 
			on rloutOtherRollouts close do
			(
				callbacks.removeScripts \
				#selectionSetChanged id:#MainDialogCallbacks
			)
		)
 
		MainDialog = newRolloutFloater "Main Dialog" 232 806
		addRollout rloutOtherRollouts MainDialog	
	) 
	else
	(
		if MainDialog.open then
			rloutOtherRollouts.MainDialog_Refresh()
		else
		(
			MainDialog = newRolloutFloater "Main Dialog" 232 806
			addRollout rloutOtherRollouts MainDialog
		)
	)
)

my recent MAXScripts RSS (archive here)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.