Cat petting and purring
This commit is contained in:
parent
d76bb5136f
commit
6225ce8752
7
TODO
7
TODO
@ -1,3 +1,6 @@
|
||||
Cat lifecycle:
|
||||
- Cats can be petted
|
||||
- Petting cats after long enough around another cat may eject a prill
|
||||
- Petting cats after long enough around another cat may eject a prill
|
||||
- Cat behaviors
|
||||
- Push item stacks off nearby ledges?
|
||||
- Sometimes randomly give you some junk as a present?
|
||||
- Dig up nearby plants?
|
1
init.lua
1
init.lua
@ -11,3 +11,4 @@ include("node")
|
||||
include("item")
|
||||
include("ore")
|
||||
include("craft")
|
||||
include("pet")
|
||||
|
4
node.lua
4
node.lua
@ -53,8 +53,8 @@ reg(7, "#c0a080", "#806020") -- light brown
|
||||
nodecore.register_ambiance({
|
||||
label = modname .. " ambiance",
|
||||
nodenames = {"group:" .. modname .. "_cat"},
|
||||
interval = 1,
|
||||
chance = 10,
|
||||
interval = 5,
|
||||
chance = 5,
|
||||
sound_name = modname .. "_mew",
|
||||
sound_gain = 0.5
|
||||
})
|
||||
|
71
pet.lua
Normal file
71
pet.lua
Normal file
@ -0,0 +1,71 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local math, minetest, nodecore, pairs, vector
|
||||
= math, minetest, nodecore, pairs, vector
|
||||
local math_random
|
||||
= math.random
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
local purrtimes = {
|
||||
1.676,
|
||||
1.617,
|
||||
1.642,
|
||||
1.655
|
||||
}
|
||||
|
||||
local hashpos = minetest.hash_node_position
|
||||
local purring = {}
|
||||
|
||||
local purrgain = 0.15
|
||||
|
||||
local function purr(pos)
|
||||
purring[hashpos(pos)] = true
|
||||
local id = math_random(1, #purrtimes)
|
||||
local fade = math_random(1, 10) == 1
|
||||
if not fade then
|
||||
local nearby
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
if not nearby then
|
||||
local ppos = player:get_pos()
|
||||
local diff = vector.subtract(pos, ppos)
|
||||
local dsqr = vector.dot(diff, diff)
|
||||
nearby = nearby or dsqr < 25
|
||||
end
|
||||
end
|
||||
fade = not nearby
|
||||
end
|
||||
local sh = nodecore.sound_play("nc_cats_purr_" .. id, {
|
||||
pos = pos,
|
||||
gain = purrgain,
|
||||
not_ephemeral = fade
|
||||
})
|
||||
if fade then
|
||||
minetest.sound_fade(sh, -purrgain / purrtimes[id], 0)
|
||||
return minetest.after(purrtimes[id], function()
|
||||
purring[hashpos(pos)] = nil
|
||||
end)
|
||||
else
|
||||
nodecore.dnt_set(pos, modname .. ":purr", purrtimes[id])
|
||||
end
|
||||
end
|
||||
|
||||
nodecore.register_dnt({
|
||||
name = modname .. ":purr",
|
||||
nodenames = {"group:" .. modname .. "_cat"},
|
||||
action = purr
|
||||
})
|
||||
|
||||
nodecore.register_craft({
|
||||
label = "pet cat",
|
||||
action = "pummel",
|
||||
toolgroups = {thumpy = 1},
|
||||
indexkeys = {"group:" .. modname .. "_cat"},
|
||||
check = function(pos)
|
||||
return not purring[hashpos(pos)]
|
||||
end,
|
||||
nodes = {
|
||||
{match = {groups = {[modname .. "_cat"] = true}}}
|
||||
},
|
||||
after = purr
|
||||
})
|
BIN
sounds/nc_cats_purr_1.0.ogg
Normal file
BIN
sounds/nc_cats_purr_1.0.ogg
Normal file
Binary file not shown.
BIN
sounds/nc_cats_purr_2.0.ogg
Normal file
BIN
sounds/nc_cats_purr_2.0.ogg
Normal file
Binary file not shown.
BIN
sounds/nc_cats_purr_3.0.ogg
Normal file
BIN
sounds/nc_cats_purr_3.0.ogg
Normal file
Binary file not shown.
BIN
sounds/nc_cats_purr_4.0.ogg
Normal file
BIN
sounds/nc_cats_purr_4.0.ogg
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user