Skip to content

Commit 1bf110b

Browse files
author
James Brundage
committed
Start-OBSEffect - Fixing -LoopCount (Fixes #133)
1 parent 4bae611 commit 1bf110b

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

Commands/Effects/Start-OBSEffect.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ function Start-OBSEffect
104104

105105
if ($loop -or $Bounce) {
106106
$obsEffect | Add-Member -MemberType NoteProperty Mode "$(if ($Bounce) {"Bounce"})$(if ($loop) {"Loop"})" -Force
107+
if (-not $LoopCount) {
108+
$obsEffect | Add-Member -MemberType NoteProperty LoopCount -1 -Force
109+
}
107110
} else {
108111
$obsEffect | Add-Member -MemberType NoteProperty Mode "Once" -Force
109112
}

Types/OBS.PowerShell.Effect/Start.ps1

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ if ($this.Messages) {
8484

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

@@ -94,8 +94,9 @@ if ($this.Messages) {
9494
$effectInfo.Reversed = -not $effectInfo.Reversed
9595
$effectInfo.Start()
9696
} elseif ($effectInfo.Mode -match 'Loop') {
97-
if (($null -eq $effectInfo.LoopCount) -or
98-
$effectInfo.LoopCount) {
97+
if ($effectInfo.LoopCount -is [int] -and $effectInfo.LoopCount -ge 1) {
98+
$effectInfo.Start()
99+
} elseif ($effectInfo.LoopCount -isnot [int] -or $effectInfo.LoopCount -lt 0) {
99100
$effectInfo.Start()
100101
}
101102
} elseif ($effectInfo.Mode -match 'Bounce') {

0 commit comments

Comments
 (0)