Rewrite purring to be usable outside of snore
This commit is contained in:
parent
74506315b5
commit
56a46ae567
27
script.lua
27
script.lua
@ -370,6 +370,21 @@ function setArmor(state)
|
|||||||
sharedconfig.save("armor_enabled", state)
|
sharedconfig.save("armor_enabled", state)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
do
|
||||||
|
local purr_sound
|
||||||
|
|
||||||
|
---@param state boolean
|
||||||
|
function purr(state)
|
||||||
|
if state and not purr_sound then
|
||||||
|
purr_sound=sound_settings(sounds["entity.cat.purr"]):loop(true):play()
|
||||||
|
elseif not state then
|
||||||
|
purr_sound:stop()
|
||||||
|
purr_sound=nil
|
||||||
|
end
|
||||||
|
return purr_sound
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local snore
|
local snore
|
||||||
do
|
do
|
||||||
local snores={sounds["sounds.snore-1"], sounds["sounds.snore-2"], sounds["sounds.snore-3"]}
|
local snores={sounds["sounds.snore-1"], sounds["sounds.snore-2"], sounds["sounds.snore-3"]}
|
||||||
@ -383,16 +398,8 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function snore_purr()
|
local function snore_purr()
|
||||||
if not is_snoring then
|
purr(true)
|
||||||
is_snoring=true
|
statemonitor.register("snore", state_not_sleeping, function() purr(false) end, 5, true)
|
||||||
local purr_sound=sound_settings(sounds["entity.cat.purr"]):loop(true):play()
|
|
||||||
local function stop_playback()
|
|
||||||
purr_sound:stop()
|
|
||||||
is_snoring=false
|
|
||||||
end
|
|
||||||
statemonitor.register("snore", state_not_sleeping, stop_playback, 5, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function snore_augh()
|
local function snore_augh()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user