Compare commits

...

6 Commits

Author SHA1 Message Date
eb6c6f1fe2
add gay detector uwu 2023-06-28 01:44:13 -04:00
a8b2b841f8
use world.getTime() instead of getTimeOfDay()
getTimeOfDay() breaks if doDaylightCycle is false (i.e. testing world)
2023-06-28 01:43:19 -04:00
da20d7517b
Update nulllib 2023-06-28 01:35:32 -04:00
658f197051
Rearrange optimized checks 2023-06-28 00:56:58 -04:00
35401336d2
Prevent meowing when using commands 2023-06-28 00:56:02 -04:00
56a46ae567
Rewrite purring to be usable outside of snore 2023-06-28 00:55:26 -04:00
2 changed files with 79 additions and 20 deletions

@ -1 +1 @@
Subproject commit a65b6b323dc7c3c80f0305b28f126cd9d2b317ac
Subproject commit 33d6ecaa03a4b4b9a63474cb7f26b5b14e83956c

View File

@ -188,6 +188,9 @@ for _, v in pairs(EMISSIVES) do
v:setColor(COLORS.neutral)
end
local gay_idiot_uuid="3dad78e8-6979-404f-820e-952ce20964a0" -- boy fren
--gay_idiot_uuid="468554f1-27cd-4ea1-9308-3dd14a9b1a12" -- alt account (testing)
-- }}}
-- PartsManager rules {{{
@ -370,6 +373,21 @@ function setArmor(state)
sharedconfig.save("armor_enabled", state)
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
do
local snores={sounds["sounds.snore-1"], sounds["sounds.snore-2"], sounds["sounds.snore-3"]}
@ -383,16 +401,8 @@ do
end
local function snore_purr()
if not is_snoring then
is_snoring=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
purr(true)
statemonitor.register("snore", state_not_sleeping, function() purr(false) end, 5, true)
end
local function snore_augh()
@ -419,7 +429,8 @@ function pings.meow()
sound_settings(sounds["entity.cat.ambient"]):play()
end
events.CHAT_SEND_MESSAGE:register(function(msg)
if sharedconfig.load("is_cat") then pings.meow() end
if sharedconfig.load("is_cat") and string.match(msg, '^/') == nil then
pings.meow() end
return msg end,
"chat_meow")
@ -672,22 +683,70 @@ function hostTick()
sharedstate.set("health", player:getHealth())
end
local gay_idiot_check
do
local nearby=false
local nearby_ticks=0
function pings.set_gay_idiot_nearby(state)
if state then
pings.expr("owo")
purr(true)
else
pings.expr("neutral")
purr(false)
end
end
local function set_gay_idiot_nearby(state)
if state ~= nearby then
nearby=state
pings.set_gay_idiot_nearby(state)
end
end
---@param frequency? integer time since last check, default 1
function gay_idiot_check(frequency)
frequency=frequency or 1
nearby_ticks=nearby_ticks or 0
local gay_idiot=world.getEntity(gay_idiot_uuid)
-- if exists
if gay_idiot ~= nil then
-- if nearby then add to timer
local distance = (gay_idiot:getPos() - player:getPos()):length()
if distance <= 1 then
nearby_ticks=nearby_ticks+frequency
else
nearby_ticks=0
end
set_gay_idiot_nearby(nearby_ticks>=5*20)
end
end
end
function tick()
STATE.current.color_check=player:isInLava() ~= (player:getDimensionName()=="minecraft:the_nether")
STATE.current.color_check=player:isInLava() ~=
(player:getDimensionName()=="minecraft:the_nether")
if STATE.old.color_check~=STATE.current.color_check then
setColor()
end
-- optimization, only execute these once a second --
if world.getTimeOfDay() % 20 == 0 then
-- optimization, only execute these with certain frequency --
if world.getTime() % 5 == 0 then -- 1/4 second
if player:getPose() == "SLEEPING" then
snore()
end
if host:isHost() then gay_idiot_check(5) end
-- unneeded for now but can uncomment if needed
--if world.getTime() % 20 == 0 then -- 1 second
-- Sync state every 10 seconds
if world.getTimeOfDay() % (20*10) == 0 then
if world.getTime() % (20*10) == 0 then
sharedstate.sync()
end
--end
end
hostTick()