Rewrote the function comments to be more in line with go.dev/doc/comments

This commit is contained in:
2026-07-06 23:13:43 +01:00
parent f1728c11da
commit 047deb65e7
+31 -79
View File
@@ -1,5 +1,4 @@
// Package bngsdk defines an API to interact with the BeamNG outgauge data in
// Go
// Package bngsdk defines an API to interact with the BeamNG outgauge data in Go
package bngsdk
import (
@@ -117,80 +116,59 @@ func Init(ip string, port int) (BeamNGSDK, error) {
// ShowLights - functions to check if a given dash light is on [START]
// ShiftLight returns:
// true if the shift light is on
// false if the shift light is off
// ShiftLight reports whether the shift light is on
func (sdk *BeamNGSDK) ShiftLight() bool {
return sdk.Data.ShowLights&DL_SHIFT != 0
}
// HighBeam returns:
// true if the high beams are on
// false if the high beams are off
// HighBeam reports whether high beams are on
func (sdk *BeamNGSDK) HighBeam() bool {
return sdk.Data.ShowLights&DL_FULLBEAM != 0
}
// Handbrake returns:
// true if the handbrake is pulled
// false if the handbrake is down
// Handbrake reports whether the handbrake is pulled
func (sdk *BeamNGSDK) Handbrake() bool {
return sdk.Data.ShowLights&DL_HANDBRAKE != 0
}
// Pitspeed returns:
// true if the pit speed limiter is on
// false if the pit speed limiter is off
// Pitspeed reports whether the pit speed limiter is engaged
//
// NOTE: this may not be used in BeamNG.drive, haven't checked yet
func (sdk *BeamNGSDK) Pitspeed() bool {
return sdk.Data.ShowLights&DL_PITSPEED != 0
}
// TractionControl returns:
// true if traction control is on
// false if traction control is off
// TractionControl reports wheter TC is engaged
func (sdk *BeamNGSDK) TractionControl() bool {
return sdk.Data.ShowLights&DL_TC != 0
}
// LeftIndicator returns:
// true if the left indicator is on
// false if the left indicator is off
// LeftIndicator reports whether the left indicator is on
func (sdk *BeamNGSDK) LeftIndicator() bool {
return sdk.Data.ShowLights&DL_SIGNAL_L != 0
}
// RightIndicator returns:
// true if the right indicator is on
// false if the right indicator is off
// RightIndicator reports wheter the right indicator is on
func (sdk *BeamNGSDK) RightIndicator() bool {
return sdk.Data.ShowLights&DL_SIGNAL_R != 0
}
// AnyIndicator returns:
// true if the any indicator is on
// false if the all indicators are off
// AnyIndicator reports whether any indicator is on
func (sdk *BeamNGSDK) AnyIndicator() bool {
return sdk.Data.ShowLights&DL_SIGNAL_ANY != 0
}
// OilLight returns
// true if the oil light is on
// false if the oil light is off
// OilLight reports whether the oil warning light is on
func (sdk *BeamNGSDK) OilLight() bool {
return sdk.Data.ShowLights&DL_OILWARN != 0
}
// BatteryLight returns
// true if the battery light is on
// false if the battery light is off
// BatteryLight reports whether the battery light is on
func (sdk *BeamNGSDK) BatteryLight() bool {
return sdk.Data.ShowLights&DL_BATTERY != 0
}
// ABS returns
// true if the ABS is engaged
// false if the ABS isn't engaged
// ABS reports whether the ABS light is on
func (sdk *BeamNGSDK) ABS() bool {
return sdk.Data.ShowLights&DL_ABS != 0
}
@@ -199,80 +177,58 @@ func (sdk *BeamNGSDK) ABS() bool {
// DashLights - functions to check if a given dash light is provided [START]
// HasShiftLight returns:
// true if its available
// false if its unavailable
// HasShiftLight reports whether a shift light is available
func (sdk *BeamNGSDK) HasShiftLight() bool {
return sdk.Data.DashLights&DL_SHIFT != 0
}
// HasHighBeamLight returns:
// true if its available
// false if its unavailable
// HasHighBeamLight reports whether a high beam light is available
func (sdk *BeamNGSDK) HasHighBeamLight() bool {
return sdk.Data.DashLights&DL_FULLBEAM != 0
}
// HasHandbrakeLight returns:
// true if its available
// false if its unavailable
// HasHandbrakeLight reports wheter a handbrake light is available
func (sdk *BeamNGSDK) HasHandbrakeLight() bool {
return sdk.Data.DashLights&DL_HANDBRAKE != 0
}
// HasPitspeed returns:
// true if its available
// false if its unavailable
// HasPitspeed reports whether a pit speed limitr is available
// NOTE: this may not be used in BeamNG.drive, haven't checked yet
func (sdk *BeamNGSDK) HasPitspeed() bool {
return sdk.Data.DashLights&DL_HANDBRAKE != 0
}
// HasTractionControlLight returns:
// true if its available
// false if its unavailable
// HasTractionControlLight reports whether a traction control light is available
func (sdk *BeamNGSDK) HasTractionControlLight() bool {
return sdk.Data.DashLights&DL_TC != 0
}
// HasLeftIndicatorLight returns:
// true if its available
// false if its unavailable
// HasLeftIndicatorLight reports whether a left indicator is available
func (sdk *BeamNGSDK) HasLeftIndicatorLight() bool {
return sdk.Data.DashLights&DL_SIGNAL_L != 0
}
// HasRightIndicatorLight returns:
// true if its available
// false if its unavailable
// HasRightIndicatorLight reports whether a right indicator is available
func (sdk *BeamNGSDK) HasRightIndicatorLight() bool {
return sdk.Data.DashLights&DL_SIGNAL_R != 0
}
// HasAnyIndicatorLight returns:
// true if its available
// false if its unavailable
// HasAnyIndicatorLight reports whether an any indicator light is available
func (sdk *BeamNGSDK) HasAnyIndicatorLight() bool {
return sdk.Data.DashLights&DL_SIGNAL_ANY != 0
}
// HasOilLight returns:
// true if its available
// false if its unavailable
// HasOilLight reports whether a oil light is available
func (sdk *BeamNGSDK) HasOilLight() bool {
return sdk.Data.DashLights&DL_OILWARN != 0
}
// HasBatteryLight returns:
// true if its available
// false if its unavailable
// HasBatteryLight reports whether a battery light is available
func (sdk *BeamNGSDK) HasBatteryLight() bool {
return sdk.Data.DashLights&DL_BATTERY != 0
}
// HasABSLight returns:
// true if its available
// false if its unavailable
// HasABSLight reports whether an ABS light is available
func (sdk *BeamNGSDK) HasABSLight() bool {
return sdk.Data.DashLights&DL_ABS != 0
}
@@ -281,25 +237,21 @@ func (sdk *BeamNGSDK) HasABSLight() bool {
// Flags - functions to check if a given flag is ON [START]
// HasTurbo returns:
// true if the car has a turbo
// false if it doesn't
// HasTurbo reports whether there's a turbo
func (sdk *BeamNGSDK) HasTurbo() bool {
return sdk.Data.Flags&OG_TURBO != 0
}
// PrefersKm returns:
// true if true
// false if false
// wow
// PrefersKm reports whether the user prefers kilometers:
// - true is prefers Km
// - false is prefers Mi
func (sdk *BeamNGSDK) PrefersKm() bool {
return sdk.Data.Flags&OG_KM != 0
}
// PrefersBAR returns:
// true if true
// false if false
// wow
// PrefersBAR reports whether the user prefers BAR:
// - true is prefers BAR
// - false is prefers PSI
func (sdk *BeamNGSDK) PrefersBAR() bool {
return sdk.Data.Flags&OG_BAR != 0
}