Quantcast
Channel: Daz Script Developer Discussion - Daz 3D Forums
Viewing all articles
Browse latest Browse all 1036

Anybody have an App.saveStateScript example?

$
0
0

I can successfully trigger a script on this callback, but I can't seem to add any code to the state script because the type passed into the callback is a QVariant rather than a DzScript. The documentation is not helpful.

Here I set up the callback:

var sScript = "support/esemwy/testCallback.dsa";

var oCallBackMgr = App.getCallBackMgr();
var oCallBack = oCallBackMgr.createCallBack( "saveStateScript Callback", sScript, false );

oCallBack.setConnection( App, "saveStateScript(DzScript&)" );

Here is the callback script that fires when Studio exits:

var oSender = CallBack.getSender();
var sMessage = String( "Sender Class: %1\n" +
		 "Sender Name: %2\n\n" +
		 "CallBack Args: %3" )
		 .arg( oSender.className() )
		 .arg( oSender.name )
		 .arg( CallBack.getArgCount() );

var nArgs = CallBack.getArgCount();
if( nArgs > 0 )
{
   for( var i = 0; i < nArgs; i += 1 )
   {
	  sMessage += String( "\nArg %1 : %2" ).arg( i ).arg( CallBack.getArg( i ) );
   }
}
// The following code won't work because the arg is not a DzScript
// var oScript = CallBack.getArg(0);
// oScript.addCode("App.debug(\"HERE IS A MESSAGE\");");

sMessage += String("\n===\n%1\n===").arg(DzScript(CallBack.getArg(0)).getCode());
MessageBox.information( sMessage, CallBack.className(), "&OK" );

The callback runs without problem unless I actually try to do something to the state script.

Any hints? Alternatively, is there another way to run a script when Studio starts?

Thanks


Viewing all articles
Browse latest Browse all 1036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>