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

Sub Light.Object
 On Local Error Goto ErrTrap14
 Gosub Get.Config
 If Normal.User Then
    If Option1 Then
       If UserRecord.Level<Option1 Then
          Strng="You can't! Level is too low!"
          Call IO.O
          Exit Sub
       Endif
    Endif
 Endif
 Call Check.User.Items
 If Temp7!<=SFalse Then
    Strng="You can't light that!"
    Call IO.O
    Exit Sub
 Endif
 If TreasureRecord.LightType=False Then
    If (TreasureRecord.Edible And 4)=4 Then
       Strng="You can't light that!"
    Else
       Strng="That's not a light!"
    Endif
    Call IO.O
    Exit Sub
 Endif
 If MessWorkRecord6.Charges=False Then
    If (TreasureRecord.Edible And 4)=4 Then
       Strng="You can't, it's been smoked!"
    Else
       Strng="You can't, it's not fueled!"
    Endif
    Call IO.O
    Exit Sub
 Endif
 If MessWorkRecord6.Charges<False Then
    Strng="It's already lit!"
    Call IO.O
    Exit Sub
 Endif
 MessWorkRecord6.Charges=-MessWorkRecord6.Charges
 Call Write.Record(MessWorkFile6,Temp5!)

 Out2=Rtrim$(TreasureRecord.Prefix1)
 Out3=Lcase$(Rtrim$(TreasureRecord.ShortName))
 Strng="You light the "+Out2+Out3
 Call Convert.ANSI(True,VarQ,VarR)
 Carriage.Return=True
 Graphics.On=True
 Call IO.O
 Graphics.On=False
 Graphics.Off=True
 Strng="!"
 Call IO.O

 Var=Abs(MessWorkRecord6.Charges)
 Select Case Var
 Case 1
    Strng="It now has one charge."
 Case 2 To 10
    Strng="It now has "+Rtrim$(Numeral(Var))+" charges."
 Case Else
    Strng="It now has "+Form$(Cdbl(Var))+" charges."
 End Select
 Call IO.O
 If Node>False Then
    Out2=UserRecord.CodeName
    Out2=Rtrim$(Out2)
    Out2=Lcase$(Out2)
    Out2=Out2+" lights a "+Out3+"."
    Call Send.Mess(8,SFalse,Room,Out2)
 Endif
 Exit Sub
Get.Config:
 VarX=0
 Option1=0
 Do
    VarX=VarX+1
    If VarX>Options.Lines Then
       Goto Next.Read
       Exit Do
    Endif
    Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
    If Ucase$(Var$)="[CMD075]" Then
       Do
          VarX=VarX+1
          If VarX>Options.Lines Then
             Goto Next.Read
             Return
          Endif
          Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
          If Ucase$(Var$)="[END]" Then
             Goto Next.Read
             Return
          Endif
          Var=Instr(Var$,"=")
          If Var Then
             Var2$=Ltrim$(Rtrim$(Left$(Var$,Var-1)))
             Var3$=Ltrim$(Rtrim$(Mid$(Var$,Var+1)))
             Gosub Parse.Options
          Endif
       Loop
    Endif
 Loop
 Return
Next.Read:
 Close #TempFile1
 Filename$=DND.Path+"CMD075.CFG"
 If Dir$(Filename$)="" Then
    Return
 Endif
 Open Filename$ For Input As #TempFile1
 Do
    If Eof(TempFile1) Then
       Exit Do
    Endif
    Line Input #TempFile1, Var$
    Var$=Ltrim$(Rtrim$(Var$))
    If Left$(Var$,1)<>";" Then
       VarX$=UserRecord.CodeName
       VarX$=Rtrim$(VarX$)
       VarX$=Ucase$(VarX$)
       If Ucase$(Var$)="["+VarX$+"]" Then
          VarZ=0
          Option1=0
          Do
             If Eof(TempFile1) Then
                Exit Do
             Endif
             Line Input #TempFile1, Var$
             If Ucase$(Var$)="[END]" Then
                Return
             Endif
             Var=Instr(Var$,"=")
             If Var Then
                Var2$=Ltrim$(Rtrim$(Left$(Var$,Var-1)))
                Var3$=Ltrim$(Rtrim$(Mid$(Var$,Var+1)))
                Gosub Parse.Options
             Endif
          Loop
       Endif
    Endif
 Loop
 Return
Parse.Options:
 Select Case Lcase$(Var2$)
 Case "level.restrict"
    If Int(Val(Var3$)+.5)>0 And Int(Val(Var3$)+.5)<=32767 Then
       Option1=Int(Val(Var3$)+.5)
    Endif
 End Select
 Return
ErrResume14:
 Exit Sub
ErrTrap14:
 Resume ErrResume14
End Sub
