diff --git a/scripts/api/audiosample.lua b/scripts/api/audiosample.lua index 6e6fb0e..a357e5b 100644 --- a/scripts/api/audiosample.lua +++ b/scripts/api/audiosample.lua @@ -7,7 +7,6 @@ local exclusiveAudioSample = nil ---@field path string ---@field exclusive boolean ---@field loop boolean ----@field playing boolean local AudioSample = { __name = "AudioSample" } @@ -26,24 +25,22 @@ function AudioSample.new(params) end function AudioSample:play() - if not self.playing then + if not game.IsSamplePlaying(self.path) then if self.exclusive then if exclusiveAudioSample and self ~= exclusiveAudioSample then exclusiveAudioSample:stop() end exclusiveAudioSample = self end - self.playing = true game.PlaySample(self.path) end end function AudioSample:stop() - if self.playing then + if game.IsSamplePlaying(self.path) then if self.exclusive and self == exclusiveAudioSample then exclusiveAudioSample = nil end - self.playing = false game.StopSample(self.path) end end diff --git a/scripts/api/image.lua b/scripts/api/image.lua index 6fe6531..1b092b0 100644 --- a/scripts/api/image.lua +++ b/scripts/api/image.lua @@ -33,8 +33,10 @@ local Image = { }; ---Image constructor ---@param imagePath string # The path to the skin image to load +---@param noFallback? boolean # If loading fails it displays a missing image asset instead, default false ---@return Image function Image.new(imagePath, noFallback) + noFallback = noFallback or false local handle = gfx.CreateSkinImage(imagePath or '', 0); if (not handle) then game.Log('Failed to load image "' .. imagePath .. '"', game.LOGGER_ERROR); @@ -119,13 +121,9 @@ function Image:render(params) local b = 255; if (params.color) then - r = params.color[1]; - g = params.color[2]; - b = params.color[3]; + r, g, b = table.unpack(params.color) elseif (self.color) then - r = self.color[1]; - g = self.color[2]; - b = self.color[3]; + r, g, b = table.unpack(self.color) end local a = params.alpha or self.alpha or 1; diff --git a/scripts/api/page/page.lua b/scripts/api/page/page.lua index 2917082..03483ee 100644 --- a/scripts/api/page/page.lua +++ b/scripts/api/page/page.lua @@ -59,9 +59,12 @@ function Page:handleKnobInput(knob, delta) end ---@param button integer function Page:handleMouseInput(x, y, button) end +---Event callback on page initialization function Page:onInit() end -function Page:onInvalidation() end +---Event callback on page invalidation +---@param reason? any # reason for the invalidation +function Page:onInvalidation(reason) end ---@param deltaTime number # frametime in seconds function Page:drawBackground(deltaTime) end