mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-07-21 17:40:29 +02:00
Compare commits
24 Commits
5fb7b91db0
...
master
Author | SHA1 | Date | |
---|---|---|---|
ae21b80f08 | |||
84377ee259 | |||
5077217497 | |||
bae9cb12e2 | |||
126e5afc24 | |||
112c512c6e | |||
0f5b0e382d | |||
5ed3a34cf3 | |||
f44441c580 | |||
2cf43ffc4e | |||
0d6b794fa0 | |||
42da759407 | |||
c0c4c3ea48 | |||
f5817061ce | |||
43ad058efa | |||
b977431e21 | |||
68b25c9d08 | |||
24adcae920 | |||
16a04547ab | |||
3a7b1bbfe6 | |||
01a60d9a55 | |||
99f4fc1768 | |||
027620bfa3 | |||
854834f04e |
17
api.txt
17
api.txt
@ -50,7 +50,7 @@ functions needed for the mob to work properly which contains the following:
|
||||
set to 0 for jumping mobs only.
|
||||
'randomly_turn' if set to false then mob will not turn to face player or
|
||||
randomly turn while walking or standing.
|
||||
'jump' when true allows your mob to jump updwards.
|
||||
'jump' when true allows your mob to jump updwards[DEPRECATED].
|
||||
'jump_height' holds the height your mob can jump, 0 to disable jumping.
|
||||
'can_leap' when true obstacles like fences or pits wont stop a mob
|
||||
from trying to jump out.
|
||||
@ -92,7 +92,7 @@ functions needed for the mob to work properly which contains the following:
|
||||
When set to 16 then only natural light will kill mob.
|
||||
'suffocation' when > 0 mobs will suffocate inside solid blocks and will be
|
||||
hurt by the value given every second (0 to disable).
|
||||
'floats' when set to 1 mob will float in water, 0 has them sink.
|
||||
'floats' when True mob will float in water, otherwise they sink.
|
||||
'follow' mobs follow player when holding any of the items which appear
|
||||
on this table, the same items can be fed to a mob to tame or
|
||||
breed e.g. {"farming:wheat", "default:apple", "group:fish"}
|
||||
@ -102,7 +102,8 @@ functions needed for the mob to work properly which contains the following:
|
||||
'docile_by_day' when true has mobs wandering around during daylight
|
||||
hours and only attacking player at night or when
|
||||
provoked.
|
||||
'attack_chance' 0 to 100 chance the mob will attack (default is 5).
|
||||
'attack_chance' 0 to 100 chance the mob will attack (default is 5),
|
||||
set to 100 so that mob needs to be provoked to attack.
|
||||
'attack_patience' Time in seconds before mob gives up attacking if
|
||||
player isn't seen (Defaults to 11).
|
||||
'attack_monsters' when true mob will attack monsters.
|
||||
@ -230,8 +231,6 @@ functions needed for the mob to work properly which contains the following:
|
||||
'rotate' custom model rotation, 0 = front, 90 = side, 180 = back,
|
||||
270 = other side.
|
||||
'glow' has mob glow without light source, 0 to 15 or nil to disable
|
||||
'double_melee_attack' when true has the api choose between 'punch' and
|
||||
'punch2' animations. [DEPRECATED]
|
||||
|
||||
'animation' holds a table containing animation names and settings for use with
|
||||
mesh models:
|
||||
@ -315,15 +314,15 @@ Pickup Items
|
||||
|
||||
'pick_up' table of itemstrings the mob will pick up.
|
||||
'on_pick_up' function that will be called on item pickup - arguments are
|
||||
(self, itemstring) and can return nil or a a modified itemstack e.g.
|
||||
(self, itemtable) and can return nil or a a modified itemstack e.g.
|
||||
|
||||
on_pick_up = function(self, itemstring)
|
||||
on_pick_up = function(self, itemtable)
|
||||
|
||||
local istack = ItemStack(entity.itemstring)
|
||||
local istack = ItemStack(itemtable.itemstring)
|
||||
|
||||
print("-- took", istack:get_name())
|
||||
|
||||
istack:take_item(1)
|
||||
istack:take_item()
|
||||
|
||||
return istack
|
||||
end,
|
||||
|
41
compatibility.lua
Normal file
41
compatibility.lua
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
-- called after mob registration to check for older settings
|
||||
|
||||
function mobs.compatibility_check(self)
|
||||
|
||||
-- simple mobs rotation setting
|
||||
if self.drawtype == "side" then self.rotate = math.rad(90) end
|
||||
|
||||
-- replace floats var from number to bool
|
||||
if self.floats == 1 then self.floats = true
|
||||
elseif self.floats == 0 then self.floats = false end
|
||||
end
|
||||
|
||||
-- deprecated functions
|
||||
|
||||
function mobs:yaw(entity, yaw, delay)
|
||||
entity:set_yaw(yaw, delay)
|
||||
end
|
||||
|
||||
function mobs:set_animation(entity, anim)
|
||||
entity:set_animation(anim)
|
||||
end
|
||||
|
||||
function mobs:line_of_sight(entity, pos1, pos2)
|
||||
return entity:line_of_sight(pos1, pos2)
|
||||
end
|
||||
|
||||
function mobs:yaw_to_pos(entity, target, rot)
|
||||
return entity:yaw_to_pos(target, rot)
|
||||
end
|
||||
|
||||
function mobs:register_spawn(name, nodes, max_light, min_light, chance,
|
||||
active_object_count, max_height, day_toggle)
|
||||
|
||||
mobs:spawn_specific(name, nodes, {"air"}, min_light, max_light, 30,
|
||||
chance, active_object_count, -31000, max_height, day_toggle)
|
||||
end
|
||||
|
||||
function mobs:explosion(pos, radius)
|
||||
mobs:boom({sounds = {explode = "tnt_explode"}}, pos, radius, radius, "mobs_tnt_smoke.png")
|
||||
end
|
141
crafts.lua
141
crafts.lua
@ -1,8 +1,8 @@
|
||||
|
||||
local S = minetest.get_translator("mobs")
|
||||
local FS = function(...) return minetest.formspec_escape(S(...)) end
|
||||
local mc2 = minetest.get_modpath("mcl_core")
|
||||
local mod_def = minetest.get_modpath("default")
|
||||
local S = core.get_translator("mobs")
|
||||
local FS = function(...) return core.formspec_escape(S(...)) end
|
||||
local mc2 = core.get_modpath("mcl_core")
|
||||
local mod_def = core.get_modpath("default")
|
||||
|
||||
-- determine which sounds to use, default or mcl_sounds
|
||||
|
||||
@ -25,21 +25,11 @@ sound_helper("node_sound_water_defaults")
|
||||
sound_helper("node_sound_snow_defaults")
|
||||
sound_helper("node_sound_glass_defaults")
|
||||
|
||||
-- mob repellent node
|
||||
|
||||
minetest.register_node("mobs:mob_repellent", {
|
||||
description = S("Mob Repellent"),
|
||||
tiles = {"mobs_repellent.png"},
|
||||
is_ground_content = false,
|
||||
groups = {handy = 1, cracky = 3},
|
||||
sounds = mobs.node_sound_stone_defaults()
|
||||
})
|
||||
|
||||
-- helper function to add {eatable} group to food items
|
||||
|
||||
function mobs.add_eatable(item, hp)
|
||||
|
||||
local def = minetest.registered_items[item]
|
||||
local def = core.registered_items[item]
|
||||
|
||||
if def then
|
||||
|
||||
@ -47,7 +37,7 @@ function mobs.add_eatable(item, hp)
|
||||
|
||||
groups.eatable = hp ; groups.flammable = 2
|
||||
|
||||
minetest.override_item(item, {groups = groups})
|
||||
core.override_item(item, {groups = groups})
|
||||
end
|
||||
end
|
||||
|
||||
@ -56,6 +46,7 @@ end
|
||||
local items = {
|
||||
paper = mc2 and "mcl_core:paper" or "default:paper",
|
||||
dye_black = mc2 and "mcl_dye:black" or "dye:black",
|
||||
dye_red = mc2 and "mcl_dye:red" or "dye:red",
|
||||
string = mc2 and "mcl_mobitems:string" or "farming:string",
|
||||
stick = mc2 and "mcl_core:stick" or "default:stick",
|
||||
diamond = mc2 and "mcl_core:diamond" or "default:diamond",
|
||||
@ -68,17 +59,18 @@ local items = {
|
||||
fence_wood = mc2 and "group:fence_wood" or "default:fence_wood",
|
||||
meat_raw = mc2 and "mcl_mobitems:beef" or "group:food_meat_raw",
|
||||
meat_cooked = mc2 and "mcl_mobitems:cooked_beef" or "group:food_meat",
|
||||
obsidian = mc2 and "mcl_core:obsidian" or "default:obsidian"
|
||||
}
|
||||
|
||||
-- name tag
|
||||
|
||||
minetest.register_craftitem("mobs:nametag", {
|
||||
core.register_craftitem("mobs:nametag", {
|
||||
description = S("Name Tag") .. " " .. S("\nRight-click Mobs Redo mob to apply"),
|
||||
inventory_image = "mobs_nametag.png",
|
||||
groups = {flammable = 2, nametag = 1}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
core.register_craft({
|
||||
output = "mobs:nametag",
|
||||
recipe = {
|
||||
{ items.paper, items.dye_black, items.string }
|
||||
@ -87,7 +79,7 @@ minetest.register_craft({
|
||||
|
||||
-- leather
|
||||
|
||||
minetest.register_craftitem("mobs:leather", {
|
||||
core.register_craftitem("mobs:leather", {
|
||||
description = S("Leather"),
|
||||
inventory_image = "mobs_leather.png",
|
||||
groups = {flammable = 2, leather = 1}
|
||||
@ -95,10 +87,10 @@ minetest.register_craftitem("mobs:leather", {
|
||||
|
||||
-- raw meat
|
||||
|
||||
minetest.register_craftitem("mobs:meat_raw", {
|
||||
core.register_craftitem("mobs:meat_raw", {
|
||||
description = S("Raw Meat"),
|
||||
inventory_image = "mobs_meat_raw.png",
|
||||
on_use = minetest.item_eat(3),
|
||||
on_use = core.item_eat(3),
|
||||
groups = {food_meat_raw = 1}
|
||||
})
|
||||
|
||||
@ -106,16 +98,16 @@ mobs.add_eatable("mobs:meat_raw", 3)
|
||||
|
||||
-- cooked meat
|
||||
|
||||
minetest.register_craftitem("mobs:meat", {
|
||||
core.register_craftitem("mobs:meat", {
|
||||
description = S("Meat"),
|
||||
inventory_image = "mobs_meat.png",
|
||||
on_use = minetest.item_eat(8),
|
||||
on_use = core.item_eat(8),
|
||||
groups = {food_meat = 1}
|
||||
})
|
||||
|
||||
mobs.add_eatable("mobs:meat", 8)
|
||||
|
||||
minetest.register_craft({
|
||||
core.register_craft({
|
||||
type = "cooking",
|
||||
output = "mobs:meat",
|
||||
recipe = "mobs:meat_raw",
|
||||
@ -124,13 +116,13 @@ minetest.register_craft({
|
||||
|
||||
-- lasso
|
||||
|
||||
minetest.register_tool("mobs:lasso", {
|
||||
core.register_tool("mobs:lasso", {
|
||||
description = S("Lasso (right-click animal to put in inventory)"),
|
||||
inventory_image = "mobs_magic_lasso.png",
|
||||
groups = {flammable = 2}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
core.register_craft({
|
||||
output = "mobs:lasso",
|
||||
recipe = {
|
||||
{ items.string, "", items.string},
|
||||
@ -139,17 +131,17 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_alias("mobs:magic_lasso", "mobs:lasso")
|
||||
core.register_alias("mobs:magic_lasso", "mobs:lasso")
|
||||
|
||||
-- net
|
||||
|
||||
minetest.register_tool("mobs:net", {
|
||||
core.register_tool("mobs:net", {
|
||||
description = S("Net (right-click animal to put in inventory)"),
|
||||
inventory_image = "mobs_net.png",
|
||||
groups = {flammable = 2}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
core.register_craft({
|
||||
output = "mobs:net",
|
||||
recipe = {
|
||||
{ items.stick, "", items.stick },
|
||||
@ -160,13 +152,13 @@ minetest.register_craft({
|
||||
|
||||
-- shears (right click to shear animal)
|
||||
|
||||
minetest.register_tool("mobs:shears", {
|
||||
core.register_tool("mobs:shears", {
|
||||
description = S("Steel Shears (right-click to shear)"),
|
||||
inventory_image = "mobs_shears.png",
|
||||
groups = {flammable = 2}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
core.register_craft({
|
||||
output = "mobs:shears",
|
||||
recipe = {
|
||||
{ "", items.steel_ingot, "" },
|
||||
@ -176,13 +168,13 @@ minetest.register_craft({
|
||||
|
||||
-- protection rune
|
||||
|
||||
minetest.register_craftitem("mobs:protector", {
|
||||
core.register_craftitem("mobs:protector", {
|
||||
description = S("Mob Protection Rune"),
|
||||
inventory_image = "mobs_protector.png",
|
||||
groups = {flammable = 2}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
core.register_craft({
|
||||
output = "mobs:protector",
|
||||
recipe = {
|
||||
{ items.stone, items.stone, items.stone },
|
||||
@ -193,13 +185,13 @@ minetest.register_craft({
|
||||
|
||||
-- protection rune (level 2)
|
||||
|
||||
minetest.register_craftitem("mobs:protector2", {
|
||||
core.register_craftitem("mobs:protector2", {
|
||||
description = S("Mob Protection Rune (Level 2)"),
|
||||
inventory_image = "mobs_protector2.png",
|
||||
groups = {flammable = 2}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
core.register_craft({
|
||||
output = "mobs:protector2",
|
||||
recipe = {
|
||||
{ "mobs:protector", items.mese_crystal, "mobs:protector" },
|
||||
@ -208,15 +200,34 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
-- mob repellent node
|
||||
|
||||
core.register_node("mobs:mob_repellent", {
|
||||
description = S("Mob Repellent (Stops mobs spawning within 16 block radius)"),
|
||||
tiles = {"mobs_repellent.png"},
|
||||
is_ground_content = false,
|
||||
groups = {handy = 1, cracky = 3},
|
||||
sounds = mobs.node_sound_stone_defaults()
|
||||
})
|
||||
|
||||
core.register_craft({
|
||||
output = "mobs:mob_repellent",
|
||||
recipe = {
|
||||
{ items.obsidian, items.dye_red, items.obsidian },
|
||||
{ items.obsidian, "mobs:protector", items.obsidian },
|
||||
{ items.obsidian, items.obsidian, items.obsidian }
|
||||
}
|
||||
})
|
||||
|
||||
-- saddle
|
||||
|
||||
minetest.register_craftitem("mobs:saddle", {
|
||||
core.register_craftitem("mobs:saddle", {
|
||||
description = S("Saddle"),
|
||||
inventory_image = "mobs_saddle.png",
|
||||
groups = {flammable = 2, saddle = 1}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
core.register_craft({
|
||||
output = "mobs:saddle",
|
||||
recipe = {
|
||||
{"group:leather", "group:leather", "group:leather"},
|
||||
@ -244,7 +255,7 @@ end
|
||||
|
||||
-- mob fence top (has enlarged collisionbox to stop mobs getting over)
|
||||
|
||||
minetest.register_node("mobs:fence_top", {
|
||||
core.register_node("mobs:fence_top", {
|
||||
description = S("Mob Fence Top"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {"default_wood.png"},
|
||||
@ -257,7 +268,7 @@ minetest.register_node("mobs:fence_top", {
|
||||
selection_box = {type = "fixed", fixed = {-0.4, -1.5, -0.4, 0.4, 0, 0.4}}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
core.register_craft({
|
||||
output = "mobs:fence_top 12",
|
||||
recipe = {
|
||||
{"group:wood", "group:wood", "group:wood"},
|
||||
@ -267,13 +278,13 @@ minetest.register_craft({
|
||||
|
||||
-- items that can be used as fuel
|
||||
|
||||
minetest.register_craft({type = "fuel", recipe = "mobs:nametag", burntime = 3})
|
||||
minetest.register_craft({type = "fuel", recipe = "mobs:lasso", burntime = 7})
|
||||
minetest.register_craft({type = "fuel", recipe = "mobs:net", burntime = 8})
|
||||
minetest.register_craft({type = "fuel", recipe = "mobs:leather", burntime = 4})
|
||||
minetest.register_craft({type = "fuel", recipe = "mobs:saddle", burntime = 7})
|
||||
minetest.register_craft({type = "fuel", recipe = "mobs:fence_wood", burntime = 7})
|
||||
minetest.register_craft({type = "fuel", recipe = "mobs:fence_top", burntime = 2})
|
||||
core.register_craft({type = "fuel", recipe = "mobs:nametag", burntime = 3})
|
||||
core.register_craft({type = "fuel", recipe = "mobs:lasso", burntime = 7})
|
||||
core.register_craft({type = "fuel", recipe = "mobs:net", burntime = 8})
|
||||
core.register_craft({type = "fuel", recipe = "mobs:leather", burntime = 4})
|
||||
core.register_craft({type = "fuel", recipe = "mobs:saddle", burntime = 7})
|
||||
core.register_craft({type = "fuel", recipe = "mobs:fence_wood", burntime = 7})
|
||||
core.register_craft({type = "fuel", recipe = "mobs:fence_top", burntime = 2})
|
||||
|
||||
|
||||
-- this tool spawns same mob and adds owner, protected, nametag info
|
||||
@ -282,7 +293,7 @@ minetest.register_craft({type = "fuel", recipe = "mobs:fence_top", burntime = 2}
|
||||
|
||||
local tex_obj
|
||||
|
||||
minetest.register_tool(":mobs:mob_reset_stick", {
|
||||
core.register_tool(":mobs:mob_reset_stick", {
|
||||
description = S("Mob Reset Stick"),
|
||||
inventory_image = "default_stick.png^[colorize:#ff000050",
|
||||
stack_max = 1,
|
||||
@ -300,7 +311,7 @@ minetest.register_tool(":mobs:mob_reset_stick", {
|
||||
if obj and not sneak then
|
||||
|
||||
local self = obj:get_luaentity()
|
||||
local obj2 = minetest.add_entity(obj:get_pos(), self.name)
|
||||
local obj2 = core.add_entity(obj:get_pos(), self.name)
|
||||
|
||||
if obj2 then
|
||||
|
||||
@ -336,7 +347,7 @@ minetest.register_tool(":mobs:mob_reset_stick", {
|
||||
|
||||
local name = user:get_player_name()
|
||||
|
||||
minetest.show_formspec(name, "mobs_texture", "size[8,4]"
|
||||
core.show_formspec(name, "mobs_texture", "size[8,4]"
|
||||
.. "field[0.5,1;7.5,0;name;"
|
||||
.. FS("Enter texture:") .. ";" .. bt .. "]"
|
||||
.. "button_exit[2.5,3.5;3,1;mob_texture_change;"
|
||||
@ -345,7 +356,7 @@ minetest.register_tool(":mobs:mob_reset_stick", {
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
core.register_on_player_receive_fields(function(player, formname, fields)
|
||||
|
||||
-- right-clicked with nametag and name entered?
|
||||
if formname == "mobs_texture" and fields.name and fields.name ~= "" then
|
||||
@ -375,22 +386,22 @@ end)
|
||||
|
||||
-- Meat Block
|
||||
|
||||
minetest.register_node("mobs:meatblock", {
|
||||
core.register_node("mobs:meatblock", {
|
||||
description = S("Meat Block"),
|
||||
tiles = {"mobs_meat_top.png", "mobs_meat_bottom.png", "mobs_meat_side.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy = 1, oddly_breakable_by_hand = 1, axey = 1, handy = 1},
|
||||
is_ground_content = false,
|
||||
sounds = mobs.node_sound_dirt_defaults(),
|
||||
on_place = minetest.rotate_node,
|
||||
on_use = minetest.item_eat(20),
|
||||
on_place = core.rotate_node,
|
||||
on_use = core.item_eat(20),
|
||||
_mcl_hardness = 0.8,
|
||||
_mcl_blast_resistance = 1
|
||||
})
|
||||
|
||||
mobs.add_eatable("mobs:meatblock", 20)
|
||||
|
||||
minetest.register_craft({
|
||||
core.register_craft({
|
||||
output = "mobs:meatblock",
|
||||
recipe = {
|
||||
{ items.meat_cooked, items.meat_cooked, items.meat_cooked },
|
||||
@ -401,22 +412,22 @@ minetest.register_craft({
|
||||
|
||||
-- Meat Block (raw)
|
||||
|
||||
minetest.register_node("mobs:meatblock_raw", {
|
||||
core.register_node("mobs:meatblock_raw", {
|
||||
description = S("Raw Meat Block"),
|
||||
tiles = {"mobs_meat_raw_top.png", "mobs_meat_raw_bottom.png", "mobs_meat_raw_side.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy = 1, oddly_breakable_by_hand = 1, axey = 1, handy = 1},
|
||||
is_ground_content = false,
|
||||
sounds = mobs.node_sound_dirt_defaults(),
|
||||
on_place = minetest.rotate_node,
|
||||
on_use = minetest.item_eat(20),
|
||||
on_place = core.rotate_node,
|
||||
on_use = core.item_eat(20),
|
||||
_mcl_hardness = 0.8,
|
||||
_mcl_blast_resistance = 1
|
||||
})
|
||||
|
||||
mobs.add_eatable("mobs:meatblock_raw", 20)
|
||||
|
||||
minetest.register_craft({
|
||||
core.register_craft({
|
||||
output = "mobs:meatblock_raw",
|
||||
recipe = {
|
||||
{ items.meat_raw, items.meat_raw, items.meat_raw },
|
||||
@ -425,7 +436,7 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
core.register_craft({
|
||||
type = "cooking",
|
||||
output = "mobs:meatblock",
|
||||
recipe = "mobs:meatblock_raw",
|
||||
@ -434,9 +445,9 @@ minetest.register_craft({
|
||||
|
||||
-- hearing vines (if mesecons active it acts like blinkyplant)
|
||||
|
||||
local mod_mese = minetest.get_modpath("mesecons")
|
||||
local mod_mese = core.get_modpath("mesecons")
|
||||
|
||||
minetest.register_node("mobs:hearing_vines", {
|
||||
core.register_node("mobs:hearing_vines", {
|
||||
description = S("Hearing Vines"),
|
||||
drawtype = "firelike",
|
||||
waving = 1,
|
||||
@ -454,12 +465,12 @@ minetest.register_node("mobs:hearing_vines", {
|
||||
},
|
||||
on_sound = function(pos, def)
|
||||
if def.loudness > 0.5 then
|
||||
minetest.set_node(pos, {name = "mobs:hearing_vines_active"})
|
||||
core.set_node(pos, {name = "mobs:hearing_vines_active"})
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("mobs:hearing_vines_active", {
|
||||
core.register_node("mobs:hearing_vines_active", {
|
||||
description = S("Active Hearing Vines"),
|
||||
drawtype = "firelike",
|
||||
waving = 1,
|
||||
@ -479,11 +490,11 @@ minetest.register_node("mobs:hearing_vines_active", {
|
||||
type = "fixed", fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, -0.25, 6 / 16},
|
||||
},
|
||||
on_construct = function(pos)
|
||||
minetest.get_node_timer(pos):start(1)
|
||||
core.get_node_timer(pos):start(1)
|
||||
if mod_mese then mesecon.receptor_on(pos) end
|
||||
end,
|
||||
on_timer = function(pos)
|
||||
minetest.set_node(pos, {name = "mobs:hearing_vines"})
|
||||
core.set_node(pos, {name = "mobs:hearing_vines"})
|
||||
if mod_mese then mesecon.receptor_off(pos) end
|
||||
end
|
||||
})
|
||||
|
10
init.lua
10
init.lua
@ -1,16 +1,16 @@
|
||||
|
||||
local S = minetest.get_translator("mobs")
|
||||
local S = core.get_translator("mobs")
|
||||
|
||||
-- peaceful player privilege
|
||||
|
||||
minetest.register_privilege("peaceful_player", {
|
||||
core.register_privilege("peaceful_player", {
|
||||
description = "Prevents Mobs Redo mobs from attacking player",
|
||||
give_to_singleplayer = false
|
||||
})
|
||||
|
||||
-- fallback node
|
||||
|
||||
minetest.register_node("mobs:fallback_node", {
|
||||
core.register_node("mobs:fallback_node", {
|
||||
description = S("Fallback Node"),
|
||||
tiles = {"mobs_fallback.png"},
|
||||
is_ground_content = false,
|
||||
@ -19,7 +19,7 @@ minetest.register_node("mobs:fallback_node", {
|
||||
})
|
||||
|
||||
|
||||
local path = minetest.get_modpath("mobs")
|
||||
local path = core.get_modpath("mobs")
|
||||
|
||||
dofile(path .. "/api.lua") -- mob API
|
||||
|
||||
@ -31,7 +31,7 @@ dofile(path .. "/spawner.lua") -- mob spawner
|
||||
|
||||
-- Lucky Blocks
|
||||
|
||||
if minetest.get_modpath("lucky_block") then
|
||||
if core.get_modpath("lucky_block") then
|
||||
dofile(path .. "/lucky_block.lua")
|
||||
end
|
||||
|
||||
|
@ -20,6 +20,10 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
Textures borrowed from minetest_game (CC BY-SA 3.0):
|
||||
mobs_tnt_smoke.png
|
||||
mobs_bubble_particle.png
|
||||
mobs_heart_particle.png
|
||||
|
||||
Textures under CC0 license by TenPlus1
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
local S = minetest.get_translator("mobs")
|
||||
local S = core.get_translator("mobs")
|
||||
|
||||
-- add lucky blocks
|
||||
|
||||
@ -21,7 +21,7 @@ lucky_block:add_blocks({
|
||||
|
||||
-- pint sized rune, use on tamed mob to shrink to half-size
|
||||
|
||||
minetest.register_craftitem(":mobs:pint_sized_rune", {
|
||||
core.register_craftitem(":mobs:pint_sized_rune", {
|
||||
description = S("Pint Sized Rune"),
|
||||
inventory_image = "mobs_pint_sized_rune.png",
|
||||
groups = {flammable = 2},
|
||||
@ -39,17 +39,17 @@ minetest.register_craftitem(":mobs:pint_sized_rune", {
|
||||
local self = pointed_thing.ref:get_luaentity()
|
||||
|
||||
if not self._cmi_is_mob then
|
||||
minetest.chat_send_player(name, S("Not a Mobs Redo mob!"))
|
||||
core.chat_send_player(name, S("Not a Mobs Redo mob!"))
|
||||
return
|
||||
end
|
||||
|
||||
if not self.tamed then
|
||||
minetest.chat_send_player(name, S("Not tamed!"))
|
||||
core.chat_send_player(name, S("Not tamed!"))
|
||||
return
|
||||
end
|
||||
|
||||
if self.pint_size_potion then
|
||||
minetest.chat_send_player(name, S("Potion already applied!"))
|
||||
core.chat_send_player(name, S("Potion already applied!"))
|
||||
return
|
||||
end
|
||||
|
||||
@ -92,7 +92,7 @@ minetest.register_craftitem(":mobs:pint_sized_rune", {
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
core.register_craft({
|
||||
output = "lucky_block:pint_sized_rune",
|
||||
recipe = {{"lucky_block:pint_sized_potion", "mobs:protector"}}
|
||||
})
|
||||
|
30
mount.lua
30
mount.lua
@ -1,11 +1,11 @@
|
||||
|
||||
-- lib_mount by Blert2112 (edited by TenPlus1)
|
||||
|
||||
local is_mc2 = minetest.get_modpath("mcl_mobs") -- MineClone2 check
|
||||
local is_mc2 = core.get_modpath("mcl_mobs") -- MineClone2 check
|
||||
|
||||
-- one of these is needed to ride mobs, otherwise no riding for you
|
||||
|
||||
if not minetest.get_modpath("player_api") and not is_mc2 then
|
||||
if not core.get_modpath("player_api") and not is_mc2 then
|
||||
|
||||
function mobs.attach() end
|
||||
function mobs.detach() end
|
||||
@ -28,7 +28,7 @@ local function node_is(entity)
|
||||
|
||||
if entity.standing_on == "air" then return "air" end
|
||||
|
||||
local def = minetest.registered_nodes[entity.standing_on]
|
||||
local def = core.registered_nodes[entity.standing_on]
|
||||
|
||||
if def.groups.lava then return "lava" end
|
||||
if def.groups.liquid then return "liquid" end
|
||||
@ -90,15 +90,15 @@ end
|
||||
|
||||
-- detach player on leaving
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
core.register_on_leaveplayer(function(player)
|
||||
force_detach(player)
|
||||
end)
|
||||
|
||||
-- detatch all players on shutdown
|
||||
|
||||
minetest.register_on_shutdown(function()
|
||||
core.register_on_shutdown(function()
|
||||
|
||||
local players = minetest.get_connected_players()
|
||||
local players = core.get_connected_players()
|
||||
|
||||
for i = 1, #players do
|
||||
force_detach(players[i])
|
||||
@ -107,7 +107,7 @@ end)
|
||||
|
||||
-- detatch player when dead
|
||||
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
core.register_on_dieplayer(function(player)
|
||||
force_detach(player)
|
||||
return true
|
||||
end)
|
||||
@ -125,11 +125,11 @@ local function find_free_pos(pos)
|
||||
for _, c in pairs(check) do
|
||||
|
||||
local npos = {x = pos.x + c.x, y = pos.y + c.y, z = pos.z + c.z}
|
||||
local node = minetest.get_node_or_nil(npos)
|
||||
local node = core.get_node_or_nil(npos)
|
||||
|
||||
if node and node.name then
|
||||
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
local def = core.registered_nodes[node.name]
|
||||
|
||||
if def and not def.walkable and def.liquidtype == "none" then
|
||||
return npos
|
||||
@ -144,7 +144,7 @@ end
|
||||
|
||||
local function is_player(player)
|
||||
|
||||
if player and type(player) == "userdata" and minetest.is_player(player) then
|
||||
if player and type(player) == "userdata" and core.is_player(player) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
@ -184,7 +184,7 @@ function mobs.attach(entity, player)
|
||||
visual_size = {x = entity.driver_scale.x, y = entity.driver_scale.y}
|
||||
})
|
||||
|
||||
minetest.after(0.2, function()
|
||||
core.after(0.2, function()
|
||||
|
||||
if is_player(player) then
|
||||
|
||||
@ -205,7 +205,7 @@ function mobs.detach(player)
|
||||
|
||||
force_detach(player)
|
||||
|
||||
minetest.after(0.1, function()
|
||||
core.after(0.1, function()
|
||||
|
||||
if player and player:is_player() then
|
||||
|
||||
@ -299,7 +299,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
||||
|
||||
if velo.y == 0
|
||||
and entity.standing_on ~= "air" and entity.standing_on ~= "ignore"
|
||||
and minetest.get_item_group(entity.standing_on, "liquid") == 0 then
|
||||
and core.get_item_group(entity.standing_on, "liquid") == 0 then
|
||||
velo.y = velo.y + entity.jump_height
|
||||
acce_y = acce_y + (acce_y * 3) + 1
|
||||
end
|
||||
@ -391,7 +391,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
||||
new_acce.y = 0
|
||||
p.y = p.y + 1
|
||||
|
||||
if minetest.get_item_group(entity.standing_in, "liquid") ~= 0 then
|
||||
if core.get_item_group(entity.standing_in, "liquid") ~= 0 then
|
||||
|
||||
if velo.y >= 5 then
|
||||
velo.y = 5
|
||||
@ -458,7 +458,7 @@ function mobs.fly(entity, _, speed, shoots, arrow, moving_anim, stand_anim)
|
||||
if ctrl.LMB and ctrl.sneak and shoots then
|
||||
|
||||
local pos = entity.object:get_pos()
|
||||
local obj = minetest.add_entity({
|
||||
local obj = core.add_entity({
|
||||
x = pos.x + 0 + dir.x * 2.5,
|
||||
y = pos.y + 1.5 + dir.y,
|
||||
z = pos.z + 0 + dir.z * 2.5}, arrow)
|
||||
|
42
spawner.lua
42
spawner.lua
@ -1,12 +1,12 @@
|
||||
|
||||
local S = minetest.get_translator("mobs")
|
||||
local max_per_block = tonumber(minetest.settings:get("max_objects_per_block") or 99)
|
||||
local S = core.get_translator("mobs")
|
||||
local max_per_block = tonumber(core.settings:get("max_objects_per_block") or 99)
|
||||
|
||||
-- helper functions
|
||||
|
||||
local function is_player(player)
|
||||
|
||||
if player and type(player) == "userdata" and minetest.is_player(player) then
|
||||
if player and type(player) == "userdata" and core.is_player(player) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
@ -26,7 +26,7 @@ end
|
||||
|
||||
local spawner_default = "mobs_animal:pumba 10 15 0 0 0"
|
||||
|
||||
minetest.register_node("mobs:spawner", {
|
||||
core.register_node("mobs:spawner", {
|
||||
tiles = {"mob_spawner.png"},
|
||||
drawtype = "glasslike",
|
||||
paramtype = "light",
|
||||
@ -40,7 +40,7 @@ minetest.register_node("mobs:spawner", {
|
||||
|
||||
on_construct = function(pos)
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
|
||||
-- setup formspec
|
||||
local head = S("(mob name) (min light) (max light) (amount)"
|
||||
@ -48,7 +48,7 @@ minetest.register_node("mobs:spawner", {
|
||||
|
||||
-- text entry formspec
|
||||
meta:set_string("formspec", "size[10,3.5]"
|
||||
.. "label[0.15,0.5;" .. minetest.formspec_escape(head) .. "]"
|
||||
.. "label[0.15,0.5;" .. core.formspec_escape(head) .. "]"
|
||||
.. "field[1,2.5;8.5,0.8;text;" .. S("Command:")
|
||||
.. ";${command}]")
|
||||
|
||||
@ -58,19 +58,19 @@ minetest.register_node("mobs:spawner", {
|
||||
|
||||
on_right_click = function(pos, placer)
|
||||
|
||||
if minetest.is_protected(pos, placer:get_player_name()) then return end
|
||||
if core.is_protected(pos, placer:get_player_name()) then return end
|
||||
end,
|
||||
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
|
||||
if not fields.text or fields.text == "" then return end
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local comm = fields.text:split(" ")
|
||||
local name = sender:get_player_name()
|
||||
|
||||
if minetest.is_protected(pos, name) then
|
||||
minetest.record_protection_violation(pos, name)
|
||||
if core.is_protected(pos, name) then
|
||||
core.record_protection_violation(pos, name)
|
||||
return
|
||||
end
|
||||
|
||||
@ -88,8 +88,8 @@ minetest.register_node("mobs:spawner", {
|
||||
meta:set_string("command", fields.text)
|
||||
meta:set_string("infotext", S("Spawner Active (@1)", mob))
|
||||
else
|
||||
minetest.chat_send_player(name, S("Mob Spawner settings failed!"))
|
||||
minetest.chat_send_player(name,
|
||||
core.chat_send_player(name, S("Mob Spawner settings failed!"))
|
||||
core.chat_send_player(name,
|
||||
S("Syntax: “name min_light[0-14] max_light[0-14] "
|
||||
.. "max_mobs_in_area[0 to disable] player_distance[1-20] "
|
||||
.. "y_offset[-10 to 10]”"))
|
||||
@ -99,7 +99,7 @@ minetest.register_node("mobs:spawner", {
|
||||
|
||||
-- spawner abm
|
||||
|
||||
minetest.register_abm({
|
||||
core.register_abm({
|
||||
label = "Mob spawner node",
|
||||
nodenames = {"mobs:spawner"},
|
||||
interval = 10,
|
||||
@ -112,7 +112,7 @@ minetest.register_abm({
|
||||
if active_object_count_wider >= max_per_block then return end
|
||||
|
||||
-- get meta and command
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local comm = meta:get_string("command"):split(" ")
|
||||
|
||||
-- get settings from command
|
||||
@ -133,7 +133,7 @@ minetest.register_abm({
|
||||
end
|
||||
|
||||
-- check objects inside 9x9 area around spawner
|
||||
local objs = minetest.get_objects_inside_radius(pos, 9)
|
||||
local objs = core.get_objects_inside_radius(pos, 9)
|
||||
local count = 0
|
||||
local ent
|
||||
|
||||
@ -152,7 +152,7 @@ minetest.register_abm({
|
||||
if pla > 0 then
|
||||
|
||||
local in_range, player
|
||||
local players = minetest.get_connected_players()
|
||||
local players = core.get_connected_players()
|
||||
|
||||
for i = 1, #players do
|
||||
|
||||
@ -171,12 +171,12 @@ minetest.register_abm({
|
||||
end
|
||||
|
||||
-- set medium mob usually spawns in (defaults to air)
|
||||
local reg = minetest.registered_entities[mob].fly_in
|
||||
local reg = core.registered_entities[mob].fly_in
|
||||
|
||||
if not reg or type(reg) == "string" then reg = {(reg or "air")} end
|
||||
|
||||
-- find air blocks within 5 nodes of spawner
|
||||
local air = minetest.find_nodes_in_area(
|
||||
local air = core.find_nodes_in_area(
|
||||
{x = pos.x - 5, y = pos.y + yof, z = pos.z - 5},
|
||||
{x = pos.x + 5, y = pos.y + yof, z = pos.z + 5}, reg)
|
||||
|
||||
@ -184,13 +184,13 @@ minetest.register_abm({
|
||||
if air and #air > 0 then
|
||||
|
||||
local pos2 = air[math.random(#air)]
|
||||
local lig = minetest.get_node_light(pos2) or 0
|
||||
local lig = core.get_node_light(pos2) or 0
|
||||
|
||||
pos2.y = pos2.y + 0.5
|
||||
|
||||
-- only if light levels are within range
|
||||
if lig >= mlig and lig <= xlig and minetest.registered_entities[mob] then
|
||||
minetest.add_entity(pos2, mob)
|
||||
if lig >= mlig and lig <= xlig and core.registered_entities[mob] then
|
||||
core.add_entity(pos2, mob)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
BIN
textures/mobs_bubble_particle.png
Normal file
BIN
textures/mobs_bubble_particle.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 331 B |
BIN
textures/mobs_fire_particle.png
Normal file
BIN
textures/mobs_fire_particle.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 343 B |
BIN
textures/mobs_heart_particle.png
Normal file
BIN
textures/mobs_heart_particle.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 279 B |
Before Width: | Height: | Size: 202 B After Width: | Height: | Size: 202 B |
Reference in New Issue
Block a user