Skip to content

Commit

Permalink
Start-OBSEffect - Fixing -LoopCount (Fixes #133)
Browse files Browse the repository at this point in the history
  • Loading branch information
James Brundage committed Jul 7, 2023
1 parent 4bae611 commit 1bf110b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Commands/Effects/Start-OBSEffect.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ function Start-OBSEffect

if ($loop -or $Bounce) {
$obsEffect | Add-Member -MemberType NoteProperty Mode "$(if ($Bounce) {"Bounce"})$(if ($loop) {"Loop"})" -Force
if (-not $LoopCount) {
$obsEffect | Add-Member -MemberType NoteProperty LoopCount -1 -Force
}
} else {
$obsEffect | Add-Member -MemberType NoteProperty Mode "Once" -Force
}
Expand Down
7 changes: 4 additions & 3 deletions Types/OBS.PowerShell.Effect/Start.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ if ($this.Messages) {

$null = New-Event -SourceIdentifier "OBS.PowerShell.Effect.Ended" -MessageData $event.MessageData
$effectInfo = $event.MessageData
if ($effectInfo.LoopCount) {
if ($effectInfo.LoopCount -is [int] -and $effectInfo.LoopCount -ge 1) {
$effectInfo.LoopCount = $effectInfo.LoopCount - 1
}

Expand All @@ -94,8 +94,9 @@ if ($this.Messages) {
$effectInfo.Reversed = -not $effectInfo.Reversed
$effectInfo.Start()
} elseif ($effectInfo.Mode -match 'Loop') {
if (($null -eq $effectInfo.LoopCount) -or
$effectInfo.LoopCount) {
if ($effectInfo.LoopCount -is [int] -and $effectInfo.LoopCount -ge 1) {
$effectInfo.Start()
} elseif ($effectInfo.LoopCount -isnot [int] -or $effectInfo.LoopCount -lt 0) {
$effectInfo.Start()
}
} elseif ($effectInfo.Mode -match 'Bounce') {
Expand Down

0 comments on commit 1bf110b

Please sign in to comment.