Difference between revisions of "Timing change for death handler script (Dying.sc)"

From SCI Wiki
Jump to navigationJump to search
(Created page with "''Originally posted on the SCI Programming Forums by Gumby.'' I just utilized the dying.sc script for the first time and I immediately noticed ...")
 
 
Line 42: Line 42:
 
 
 
 
 
If you need more granularity than seconds, it would be simple to expose the 'cycles' property instead of the 'seconds' property in the Script class, then change the dying script to use cycles instead of seconds.
 
If you need more granularity than seconds, it would be simple to expose the 'cycles' property instead of the 'seconds' property in the Script class, then change the dying script to use cycles instead of seconds.
 +
 +
[[Category:Examples]]

Latest revision as of 21:44, 1 November 2013

Originally posted on the SCI Programming Forums by Gumby.


I just utilized the dying.sc script for the first time and I immediately noticed that there is a significant delay between calling the the script and the death 'screen' popping up.

This is by design, but I didn't like the fact that the delay length was hard-coded into script. Making a few modifications, I exposed the delay property for the script:

Code:
(instance public DyingScript of Script
	(properties
	    seconds 3	     //  Exposed this property (just by adding it here), 
        )                    //  which is inherited from the Script class & set the default to 3
	
	(method (changeState newState)
		(var mbResult, message)
		= state newState
		(if(== state 0)
			ProgramControl()
			(send gTheMusic:fade())
			(send gRoom:setScript(0))
			Load(rsSOUND 2)
			//= seconds 3     // Commented out this line, which set the delay to 3 seconds
		)(else
  			(if(== state 1)
                ...

 

So now, when I call the dying script, I can specify seconds like so:


Code:
  (send dyingScript:
       caller(802)
       seconds(1)   //  You can set this to however long you wish, based on your animation length
       register("You are dead.")
   )

  If you need more granularity than seconds, it would be simple to expose the 'cycles' property instead of the 'seconds' property in the Script class, then change the dying script to use cycles instead of seconds.