[Closed] Error in script on max start
I have a script (attached). I keep it in scripts/startup. but whenever I started max this script crashes with this:
however if I reload script with Ctrl+E it works fine. script:
_startup_rofl.ms (1.4 KB)
please tell me how to fix this?
try this
--clearlistener ()
try (destroydialog rofK) catch()
fn enable_event = (callbacks.addScript #selectionSetChanged "check_selection()" id:#m3dLearnEvent)
fn disable_event = (callbacks.addScript #selectionSetChanged "check_selection()" id:#m3dLearnEvent)
fn check_selection = (
selArray = (selection as array)
this_sel_count = selArray.count
if this_sel_count == 1 then (
::rofK.scnhndlr.enabled = true
::rofK.objClass.enabled = true
for i = 1 to selArray.count do ::rofK.objClass.text = ("< " + (classOf (selArray[i])) as string + " >")
)
if this_sel_count < 1 then (
::rofK.scnhndlr.enabled = false
::rofK.objClass.enabled = false
::rofK.objClass.text = "< nothing selected >"
)
if this_sel_count > 1 then (
::rofK.scnhndlr.enabled = true
::rofK.objClass.enabled = true
::rofK.objClass.text = ("<" + this_sel_count as string + " selected>")
)
else(print "something else happened")
)
rollout rofK "Help Tools" (
-- HELP BUTTONS START --(
group "Objects" (
label objClass "<nothing selected>" align:#center
button scnhndlr "Center Pivot" across:2 width:98 height:16 align:#left
)
--on imScripts pressed do ()
/* OPEN/CLOSE EVENTS */
on rofK close do (
disable_event()
)
on rofK open do (
check_selection()
enable_event()
)
)
createDialog rofK 124 68 style:#(#style_sysmenu,#style_toolwindow)
edit: sorry i’m not sure it will work because it looks like i havent unregistered the callback, in fact disable_event is wrong
wow, this works! not sure, why do you think disable_event is wrong?
also what this about ::? I’ve never heard of it
fn disable_event = (callbacks.addScript #selectionSetChanged "check_selection()" id:#m3dLearnEvent)
should be
fn disable_event = (callbacks.removescripts #selectionSetChanged id:#m3dLearnEvent)
i guess the :: is because you didn’t declared the rollout before the function is called.
i use the :: to call a function from a filein .ms so i tought is a kind of a “lookaround for this parameter” feature.
not sure but it seems like it worked…
let me know if you find something about it!
it seems like it is working. thank you very much.
I didn’t know about this :: anything before. in fact this my first attempt to make script properties manipulations at startup. thanks again