 Rem File: Cmd100.bas
 Rem Sub: Press.Object
 Rem $Include: 'dndbbs.inc'
 On Error Goto Main.Error
 If Chained<>-2 Then
    Color 15,0
    Print "DNDBBS Command 100 -- Press.Object."
    Color 7,0
    End
 Endif
 Call Press.Object
Main.Resume:
 Chain DND.Path+"DNDBBS.EXE"
 End
Main.Error:
 Resume Main.Resume

Sub Press.Object
 On Local Error Goto Error.Trap33
 Call Check.Room.Items
 If Temp7!>=SFalse Then
    Strng="You can't press that!"
    Call IO.O
    Exit Sub
 Endif
 Select Case ObjectRecord.SwitchType
 Case 1
    Strng2=ObjectRecord.PortalPassword
    Strng2=Rtrim$(Strng2)
    If Len(Strng2) Then
       Strng="Enter portal password: "
       Call IO.I
       Out2=Ucase$(Out2)
       Out2=Rtrim$(Out2)
       Out2=Ltrim$(Out2)
       Call Crypto(Strng2)
       Strng2=Rtrim$(Strng2)
       If Strng2<>Out2 Then
          Strng="Incorrect portal password.."
          Call IO.O
          Exit Sub
       Endif
    Endif
    Pass.Door=False
    Next.Room=ObjectRecord.SwitchRoom
    Strng=Rtrim$(ObjectRecord.ShortDesc)
    Var=True
    If Strng=String$(40,0) Then
       Var=False
    Endif
    If Strng=String$(80,0) Then
       Var=False
    Endif
    If Var Then
       Strng=Rtrim$(Strng)
       If Strng<>Nul Then
          Call Convert.ANSI(True,VarQ,VarR)
          Graphics.On=True
          Call IO.O
          Graphics.On=False
       Endif
    Endif
    If ObjectRecord.Trap Then
       Call Traps
       If New.Room Then
          Exit Sub
       Endif
    Endif
    Gosub Pressed
    Action.Recurse=0
    Call Enter.Room
 Case 2
    Out2=ObjectRecord.ShortName
    Out2=Rtrim$(Out2)
    Out2=Lcase$(Out2)
    Strng="You just pressed a "+Out2+"!"
    Call IO.O
    If ObjectRecord.SwitchLight Then
       Strng="A light just went out!"
       ObjectRecord.SwitchLight=False
    Else
       Strng="A light just went on!"
       ObjectRecord.SwitchLight=True
    Endif
    Call IO.O
    Temp7!=Abs(Temp7!)
    Call Write.Record(ObjectFile,Temp7!)
    Gosub Pressed
 Case 3
    Var!=ObjectRecord.SwitchLockRoom
    If Var!>SFalse And Var!<=Lof(ObjectFile)/ObjectRecLen Then
       Call Read.Record(ObjectFile,Var!)
       Select Case ObjectRecord.DoorLock
       Case 1
          ObjectRecord.DoorLock=2
          ObjectRecord.Closed=True
          Out2=ObjectRecord.ShortName
          Out2=Rtrim$(Out2)
          Out2=Lcase$(Out2)
          Strng="You hear a "+Out2+" lock."
          Call IO.O
          Call Write.Record(ObjectFile,Var!)
          Gosub Pressed
          Exit Sub
       Case 2
          ObjectRecord.DoorLock=1
          ObjectRecord.Closed=True
          Out2=ObjectRecord.ShortName
          Out2=Rtrim$(Out2)
          Out2=Lcase$(Out2)
          Strng="You hear a "+Out2+" unlock."
          Call IO.O
          Call Write.Record(ObjectFile,Var!)
          Gosub Pressed
          Exit Sub
       Case Else
          Strng="Nothing happens."
          Call IO.O
          Exit Sub
       End Select
    Endif
    Strng="You can't use that switch."
    Call IO.O
 Case Else
    Strng="You can't press that!"
    Call IO.O
 End Select
 Exit Sub
Pressed:
 If Node>False Then
    Out2=UserRecord.CodeName
    Out2=Rtrim$(Out2)
    Out2=Lcase$(Out2)
    Out2=Out2+" just pressed a "
    Strng=ObjectRecord.ShortName
    Strng=Rtrim$(Strng)
    Strng=Lcase$(Strng)
    Out2=Out2+Strng+"."
    Call Send.Mess(8,SFalse,Room,Out2)
 Endif
 Return
Error.Resume33:
 Exit Sub
Error.Trap33:
 Resume Error.Resume33
End Sub
