Loading

SCPLib Message.GetBoolDat

  1. function _SCPLib_Message::GetBoolData(index)
  2. // Get bool data at the index position in Data. If Data doesn't exist or the
  3. // index is invalid, null is returned. If data exist, but is not of the type
  4. // integer, null will be returned. Yes, it is not a typo. Bools are transmitted
  5. // as integers, however this function does check that the received integer is
  6. // 0 or 1, otherwise null is returned as well.
  7. // @param index position in the Data array to grab
  8. // @return Data[index] if it exist and is of the type integer and is 0 or 1, otherwise null
  9. {
  10.     if (this.Data != null &&
  11.             this.Data.len() > index &&
  12.             typeof(this.Data[index]) == "integer" &&
  13.             (this.Data[index] == 0 || this.Data[index] == 1))
  14.     {
  15.         return this.Data[index] == 1;
  16.     }
  17.  
  18.     return null;
  19. }

Comments