home *** CD-ROM | disk | FTP | other *** search
/ The Best of Windows 95.com 1996 September / WIN95_09962.iso / vrml / MWE105.ZIP / JExamples / VaultScript.java < prev   
Text File  |  1996-02-18  |  1KB  |  46 lines

  1. import vrml.*;
  2. import vrml.fields.*;
  3. import vrml.fields.constfields.*;
  4. import vrml.exceptions.*;
  5.  
  6. class VaultScript extends Script {
  7.  
  8.     // Declare fields
  9.     private SFBool currentlyOpen;
  10.     private SFString correctCombination;
  11.  
  12.     // Declare eventOuts
  13.     private SFBool openVault;
  14.     
  15.     // Initialize fields and eventOuts    
  16.     public VaultScript() throws InvalidFieldException, InvalidEventOutException {
  17.         try {
  18.             currentlyOpen = (SFBool) getField("currentlyOpen");
  19.             correctCombination = (SFString) getField("correctCombination");
  20.             openVault = (SFBool) getEventOut("openVault");
  21.         }
  22.         catch (InvalidFieldException f) {
  23.             throw f;
  24.         }
  25.         catch (InvalidEventOutException e) {
  26.             throw e;
  27.         }
  28.     }
  29.     
  30.     public void eventsProcessed() {
  31.     }
  32.  
  33.     public void vaultClosed(ConstSFBool value, SFTime ts) {
  34.         currentlyOpen.setValue(false);
  35.     }
  36.  
  37.     public void combinationEntered(ConstSFString combo, SFTime ts) {
  38.         if (currentlyOpen.getValue() == false &&
  39.         combo.getValue() == correctCombination.getValue()) {
  40.             currentlyOpen.setValue(true);
  41.             openVault.setValue(true);
  42.         }
  43.     }
  44. }
  45.  
  46.