Notifications
Clear all

[Closed] Event Callback Mechanism

Hey gays!
I need to do some event before saving the file

I try this:

callbacks.removeScripts id:#testCallback
CallBacks.AddScript #filePreSave "event()" id:#testCallback

It works, but not as well as I would like.
I need it to work when I save the file myself
and don’t need to work when autosave (autoback)
is there a way to fix this?

4 Replies

try using

#filePreSaveProcess: #(integer, string)

Sent before the save process has started.
Calling callbacks.notificationParam() returns a 2 element array:
Element 1 is 

 1 if doing a normal file save, 
 2 if doing an Edit>Hold
 3 if doing an Autobackup

Element 2 is the scene file name being saved.

I saw it, but I don’t get, how it can be used

something like this ?

(
	fn PreSaveHandler param = if param[1] == 1 do
	(
		savefileName = param[2];
		-- do what ever here
	)
	
	callbacks.removeScripts id:#testCallback
	CallBacks.AddScript #filePreSaveProcess "PreSaveHandler(callbacks.notificationParam())" id:#testCallback
	
)

Yes great, it works.
Thanks!