This commit is contained in:
runs 2020-03-29 14:36:38 +02:00
parent 381337dd07
commit 3009c1555a
12 changed files with 38 additions and 17 deletions

19
.luacheckrc Normal file
View File

@ -0,0 +1,19 @@
unused_args = false
allow_defined_top = true
globals = {
"minetest",
"mobkit"
}
read_globals = {
string = {fields = {"split"}},
table = {fields = {"copy", "getn"}},
-- Builtin
"vector", "ItemStack",
"dump", "DIR_DELIM", "VoxelArea", "Settings",
-- MTG
"default", "sfinv", "creative",
}

View File

@ -13,10 +13,10 @@ minetest.register_chatcommand("clear_mobs", {
return return
end end
for _, obj in ipairs(minetest.get_objects_inside_radius(player_pos, 100)) do for _, obj in ipairs(minetest.get_objects_inside_radius(player_pos, 100)) do
ent_name = obj:get_entity_name() local ent_name = obj:get_entity_name()
if not(obj:is_player()) and minetest.registered_entities[ent_name] then if not(obj:is_player()) and minetest.registered_entities[ent_name] then
colon_pos = string.find(ent_name, ':') local colon_pos = string.find(ent_name, ':')
ent_modname = string.sub(ent_name, 1, colon_pos-1) local ent_modname = string.sub(ent_name, 1, colon_pos-1)
local ent = obj:get_luaentity() local ent = obj:get_luaentity()
if ent_modname == modname and ent.type and not(ent.tamed) then if ent_modname == modname and ent.type and not(ent.tamed) then
mokapi.remove_mob(ent) mokapi.remove_mob(ent)

View File

@ -4,6 +4,7 @@ function mokapi.feed(self, clicker, feed_rate, msg_full_health, sound_type)
local wielded_item_name = wielded_item:get_name() local wielded_item_name = wielded_item:get_name()
if mokapi.item_in_itemlist(wielded_item_name, self.follow) then -- Can eat/tame with item in hand if mokapi.item_in_itemlist(wielded_item_name, self.follow) then -- Can eat/tame with item in hand
fed = true fed = true
local creative_mode = minetest.settings:get_bool("creative_mode")
if creative_mode == false then -- if not in creative, take item if creative_mode == false then -- if not in creative, take item
wielded_item:take_item() wielded_item:take_item()
clicker:set_wielded_item(wielded_item) clicker:set_wielded_item(wielded_item)
@ -17,7 +18,7 @@ function mokapi.feed(self, clicker, feed_rate, msg_full_health, sound_type)
end end
end end
self.food_count = mobkit.remember(self, "food_count", self.food_count + 1) --increase the food count self.food_count = mobkit.remember(self, "food_count", self.food_count + 1) --increase the food count
if sound_name then if sound_type then
mobkit.make_sound(self, sound_type) mobkit.make_sound(self, sound_type)
end end
end end

View File

@ -25,7 +25,7 @@ petz.lay_egg = function(self)
end end
--Extract Egg from a Nest --Extract Egg from a Nest
petz.extract_egg_from_nest = function(self, pos, player, egg_type) petz.extract_egg_from_nest = function(pos, player, egg_type)
local inv = player:get_inventory() local inv = player:get_inventory()
if inv:room_for_item("main", egg_type) then if inv:room_for_item("main", egg_type) then
inv:add_item("main", egg_type) --add the egg to the player's inventory inv:add_item("main", egg_type) --add the egg to the player's inventory

View File

@ -277,7 +277,7 @@ petz.create_detached_saddlebag_inventory = function(name)
local saddlebag_inventory = minetest.create_detached_inventory(name, { local saddlebag_inventory = minetest.create_detached_inventory(name, {
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player) allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
local stack = inv:get_stack(from_list, from_index) local stack = inv:get_stack(from_list, from_index)
return allow_put(pos, to_list, to_index, stack, player) return allow_put(inv, from_list, from_index, stack, player)
end, end,
allow_put = function(inv, listname, index, stack, player) allow_put = function(inv, listname, index, stack, player)
return stack:get_count() return stack:get_count()

View File

@ -40,6 +40,7 @@ end
-- --
function petz.on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir) function petz.on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir)
local pos = self.object:get_pos() --pos of the petz
if mobkit.is_alive(self) then if mobkit.is_alive(self) then
if self.is_mountable and puncher == self.driver then --Do not punch when you mount on it if self.is_mountable and puncher == self.driver then --Do not punch when you mount on it
return return

View File

@ -501,7 +501,7 @@ function mobkit.hq_approach_torch(self, prty, tpos)
local distance = vector.distance(pos, tpos) local distance = vector.distance(pos, tpos)
if distance < self.view_range and (distance >= self.view_range) then if distance < self.view_range and (distance >= self.view_range) then
if mobkit.is_queue_empty_low(self) then if mobkit.is_queue_empty_low(self) then
mobkit.lq_followliquidair(self, target) --mobkit.lq_followliquidair(self, target)
end end
elseif distance >= self.view_range then elseif distance >= self.view_range then
petz.ownthing(self) petz.ownthing(self)
@ -554,7 +554,6 @@ function mobkit.lq_dumbfly(self, speed_factor)
if timer < 0 then if timer < 0 then
--minetest.chat_send_player("singleplayer", tostring(timer)) --minetest.chat_send_player("singleplayer", tostring(timer))
local velocity local velocity
local mob = self.object
mobkit.animate(self, 'fly') mobkit.animate(self, 'fly')
local random_num = math.random(1, 5) local random_num = math.random(1, 5)
local yaw = self.object:get_yaw() local yaw = self.object:get_yaw()
@ -926,7 +925,7 @@ function mobkit.lq_approach_behive(self)
return true return true
end end
local pos = self.object:get_pos() local pos = self.object:get_pos()
local y_distance = tpos.y - pos.y --local y_distance = tpos.y - pos.y
if mobkit.drive_to_pos(self, tpos, 1.5, 6.28, (self.view_range / 4) ) then if mobkit.drive_to_pos(self, tpos, 1.5, 6.28, (self.view_range / 4) ) then
mobkit.clear_queue_high(self) mobkit.clear_queue_high(self)
return true return true

View File

@ -547,7 +547,7 @@ function petz.semiaquatic_brain(self)
if self.warn_attack == true then --attack player if self.warn_attack == true then --attack player
mobkit.clear_queue_high(self) -- abandon whatever they've been doing mobkit.clear_queue_high(self) -- abandon whatever they've been doing
if petz.isinliquid(self) then if petz.isinliquid(self) then
mobkit.hq_aqua_attack(self, 10, puncher, 6) -- get revenge mobkit.hq_aqua_attack(self, 10, player, 6) -- get revenge
else else
mobkit.hq_hunt(self, 10, player) mobkit.hq_hunt(self, 10, player)
end end

View File

@ -193,7 +193,7 @@ minetest.register_node("petz:fishtank", {
param2 = 50, param2 = 50,
sunlight_propagates = true, sunlight_propagates = true,
use_texture_alpha = true, use_texture_alpha = true,
light_source = LIGHT_MAX - 1, light_source = default.LIGHT_MAX - 1,
sounds = default.node_sound_glass_defaults(), sounds = default.node_sound_glass_defaults(),
selection_box = { selection_box = {
type = "fixed", type = "fixed",
@ -376,7 +376,7 @@ minetest.register_node("petz:bottle_moth", {
param2 = 50, param2 = 50,
sunlight_propagates = true, sunlight_propagates = true,
use_texture_alpha = true, use_texture_alpha = true,
light_source = LIGHT_MAX - 1, light_source = default.LIGHT_MAX - 1,
sounds = default.node_sound_glass_defaults(), sounds = default.node_sound_glass_defaults(),
selection_box = { selection_box = {
type = "fixed", type = "fixed",

View File

@ -394,7 +394,7 @@ minetest.register_chatcommand("howl", {
return false, "Error: You are not a werewolf." return false, "Error: You are not a werewolf."
end end
else else
return false, player_name .." ".."not online!" return false, name .." ".."not online!"
end end
end, end,
}) })
@ -512,6 +512,7 @@ petz:register_egg("petz:werewolf", S("Werewolf"), "petz_spawnegg_werewolf.png",
--hbhunger support --hbhunger support
if minetest.get_modpath("hbhunger") ~= nil then if minetest.get_modpath("hbhunger") ~= nil then
local org_eat = core.do_item_eat
core.do_item_eat = function(hp_change, replace_with_item, itemstack, user, pointed_thing) core.do_item_eat = function(hp_change, replace_with_item, itemstack, user, pointed_thing)
local old_itemstack = itemstack local old_itemstack = itemstack
if not(petz.is_werewolf(user)) or not(minetest.get_item_group(itemstack:get_name(), "food_meat_raw") == 0) then if not(petz.is_werewolf(user)) or not(minetest.get_item_group(itemstack:get_name(), "food_meat_raw") == 0) then

View File

@ -147,7 +147,7 @@ minetest.register_node("petz:ducky_nest_egg", {
fixed= {-0.25, -0.75, -0.25, 0.25, -0.25, 0.25}, fixed= {-0.25, -0.75, -0.25, 0.25, -0.25, 0.25},
}, },
on_rightclick = function(pos, node, player, itemstack, pointed_thing) on_rightclick = function(pos, node, player, itemstack, pointed_thing)
petz.extract_egg_from_nest(self, pos, player, "petz:ducky_egg") --extract the egg petz.extract_egg_from_nest(pos, player, "petz:ducky_egg") --extract the egg
end, end,
}) })
@ -171,7 +171,7 @@ minetest.register_node("petz:chicken_nest_egg", {
fixed= {-0.25, -0.75, -0.25, 0.25, -0.25, 0.25}, fixed= {-0.25, -0.75, -0.25, 0.25, -0.25, 0.25},
}, },
on_rightclick = function(pos, node, player, itemstack, pointed_thing) on_rightclick = function(pos, node, player, itemstack, pointed_thing)
petz.extract_egg_from_nest(self, pos, player, "petz:chicken_egg") --extract the egg petz.extract_egg_from_nest(pos, player, "petz:chicken_egg") --extract the egg
end, end,
}) })
@ -664,7 +664,7 @@ minetest.register_node("petz:honey_block", {
param2 = 50, param2 = 50,
sunlight_propagates = true, sunlight_propagates = true,
use_texture_alpha = true, use_texture_alpha = true,
light_source = LIGHT_MAX - 1, light_source = default.LIGHT_MAX - 1,
sounds = default.node_sound_glass_defaults(), sounds = default.node_sound_glass_defaults(),
}) })

View File

@ -5,7 +5,7 @@ minetest.register_node("petz:parchment", {
inventory_image = "petz_parchment.png", inventory_image = "petz_parchment.png",
tiles = {"petz_transparency.png"}, tiles = {"petz_transparency.png"},
groups = {snappy=1, bendy=2, cracky=1}, groups = {snappy=1, bendy=2, cracky=1},
sounds = default_stone_sounds, sounds = default.node_sound_stone_defaults(),
paramtype = "light", paramtype = "light",
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {