Add compat for old "wrong" : notation
This commit is contained in:
parent
e82c318f0c
commit
bbba7cee41
|
@ -46,8 +46,6 @@ local disable_blood = minetest.settings:get_bool("mobs_disable_blood")
|
||||||
local mobs_drop_items = minetest.settings:get_bool("mobs_drop_items") ~= false
|
local mobs_drop_items = minetest.settings:get_bool("mobs_drop_items") ~= false
|
||||||
local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false
|
local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false
|
||||||
local spawn_protected = minetest.settings:get_bool("mobs_spawn_protected") ~= false
|
local spawn_protected = minetest.settings:get_bool("mobs_spawn_protected") ~= false
|
||||||
local player_transfer_distance = tonumber(minetest.settings:get("player_transfer_distance")) or 128
|
|
||||||
if player_transfer_distance == 0 then player_transfer_distance = math.huge end
|
|
||||||
local remove_far = true
|
local remove_far = true
|
||||||
local difficulty = tonumber(minetest.settings:get("mob_difficulty")) or 1.0
|
local difficulty = tonumber(minetest.settings:get("mob_difficulty")) or 1.0
|
||||||
local show_health = false
|
local show_health = false
|
||||||
|
@ -659,7 +657,7 @@ local breed = function(self)
|
||||||
self.animation = nil
|
self.animation = nil
|
||||||
local anim = self._current_animation
|
local anim = self._current_animation
|
||||||
self._current_animation = nil -- Mobs Redo does nothing otherwise
|
self._current_animation = nil -- Mobs Redo does nothing otherwise
|
||||||
mcl_mobs.self:set_animation( anim)
|
self:set_animation(anim)
|
||||||
end
|
end
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
|
||||||
|
-- this is to make the register_mob and register egg functions commonly used by mods not break
|
||||||
|
-- when they use the weird old : notation AND self as first argument
|
||||||
|
local oldregmob = mcl_mobs.register_mob
|
||||||
|
function mcl_mobs.register_mob(self,name,def)
|
||||||
|
if type(self) == "string" then
|
||||||
|
def = name
|
||||||
|
name = self
|
||||||
|
end
|
||||||
|
return oldregmob(name,def)
|
||||||
|
end
|
||||||
|
local oldregegg = mcl_mobs.register_egg
|
||||||
|
function mcl_mobs.register_egg(self, mob, desc, background_color, overlay_color, addegg, no_creative)
|
||||||
|
if type(self) == "string" then
|
||||||
|
no_creative = addegg
|
||||||
|
addegg = overlay_color
|
||||||
|
overlay_color = background_color
|
||||||
|
background_color = desc
|
||||||
|
desc = mob
|
||||||
|
mob = self
|
||||||
|
end
|
||||||
|
return oldregegg(mob, desc, background_color, overlay_color, addegg, no_creative)
|
||||||
|
end
|
||||||
|
|
||||||
|
local oldregarrow = mcl_mobs.register_mob
|
||||||
|
function mcl_mobs.register_mob(self,name,def)
|
||||||
|
if type(self) == "string" then
|
||||||
|
def = name
|
||||||
|
name = self
|
||||||
|
end
|
||||||
|
return oldregarrow(name,def)
|
||||||
|
end
|
|
@ -2,6 +2,10 @@ local math, vector, minetest, mcl_mobs = math, vector, minetest, mcl_mobs
|
||||||
local mob_class = mcl_mobs.mob_class
|
local mob_class = mcl_mobs.mob_class
|
||||||
local active_particlespawners = {}
|
local active_particlespawners = {}
|
||||||
local DEFAULT_FALL_SPEED = -9.81*1.5
|
local DEFAULT_FALL_SPEED = -9.81*1.5
|
||||||
|
|
||||||
|
local player_transfer_distance = tonumber(minetest.settings:get("player_transfer_distance")) or 128
|
||||||
|
if player_transfer_distance == 0 then player_transfer_distance = math.huge end
|
||||||
|
|
||||||
-- play sound
|
-- play sound
|
||||||
function mob_class:mob_sound(soundname, is_opinion, fixed_pitch)
|
function mob_class:mob_sound(soundname, is_opinion, fixed_pitch)
|
||||||
|
|
||||||
|
@ -264,5 +268,5 @@ end
|
||||||
|
|
||||||
-- above function exported for mount.lua
|
-- above function exported for mount.lua
|
||||||
function mcl_mobs:set_animation(self, anim)
|
function mcl_mobs:set_animation(self, anim)
|
||||||
set_animation(self, anim)
|
self:set_animation(anim)
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,3 +19,5 @@ dofile(path .. "/mount.lua")
|
||||||
|
|
||||||
-- Mob Items
|
-- Mob Items
|
||||||
dofile(path .. "/crafts.lua")
|
dofile(path .. "/crafts.lua")
|
||||||
|
|
||||||
|
dofile(path .. "/compat.lua")
|
||||||
|
|
|
@ -497,7 +497,7 @@ mcl_mobs.register_mob("mobs_mc:enderman", {
|
||||||
self.base_texture = create_enderman_textures(block_type, self._taken_node)
|
self.base_texture = create_enderman_textures(block_type, self._taken_node)
|
||||||
self.object:set_properties({ textures = self.base_texture })
|
self.object:set_properties({ textures = self.base_texture })
|
||||||
self.animation = select_enderman_animation("block")
|
self.animation = select_enderman_animation("block")
|
||||||
mcl_mobs:set_animation(self, self.animation.current)
|
self:set_animation(self.animation.current)
|
||||||
if def.sounds and def.sounds.dug then
|
if def.sounds and def.sounds.dug then
|
||||||
minetest.sound_play(def.sounds.dug, {pos = take_pos, max_hear_distance = 16}, true)
|
minetest.sound_play(def.sounds.dug, {pos = take_pos, max_hear_distance = 16}, true)
|
||||||
end
|
end
|
||||||
|
@ -520,7 +520,7 @@ mcl_mobs.register_mob("mobs_mc:enderman", {
|
||||||
local def = minetest.registered_nodes[self._taken_node]
|
local def = minetest.registered_nodes[self._taken_node]
|
||||||
-- Update animation accordingly (removes visible block)
|
-- Update animation accordingly (removes visible block)
|
||||||
self.animation = select_enderman_animation("normal")
|
self.animation = select_enderman_animation("normal")
|
||||||
mcl_mobs:set_animation(self, self.animation.current)
|
self:set_animation(self.animation.current)
|
||||||
if def.sounds and def.sounds.place then
|
if def.sounds and def.sounds.place then
|
||||||
minetest.sound_play(def.sounds.place, {pos = place_pos, max_hear_distance = 16}, true)
|
minetest.sound_play(def.sounds.place, {pos = place_pos, max_hear_distance = 16}, true)
|
||||||
end
|
end
|
||||||
|
|
|
@ -87,7 +87,7 @@ local function perch(self,player)
|
||||||
local shoulder = get_shoulder(player)
|
local shoulder = get_shoulder(player)
|
||||||
if not shoulder then return true end
|
if not shoulder then return true end
|
||||||
self.object:set_attach(player,"",shoulder,vector.new(0,0,0),true)
|
self.object:set_attach(player,"",shoulder,vector.new(0,0,0),true)
|
||||||
mcl_mobs:set_animation(self, "stand")
|
self:set_animation("stand")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ end
|
||||||
local function reset_animation(self, animation)
|
local function reset_animation(self, animation)
|
||||||
if not self.object:get_pos() or self._current_animation ~= animation then return end
|
if not self.object:get_pos() or self._current_animation ~= animation then return end
|
||||||
self._current_animation = "stand_reload" -- Mobs Redo won't set the animation unless we do this
|
self._current_animation = "stand_reload" -- Mobs Redo won't set the animation unless we do this
|
||||||
mcl_mobs:set_animation(self, animation)
|
self:set_animation(animation)
|
||||||
end
|
end
|
||||||
|
|
||||||
pillager = {
|
pillager = {
|
||||||
|
@ -96,25 +96,25 @@ pillager = {
|
||||||
self.object:set_properties(props)
|
self.object:set_properties(props)
|
||||||
local old_anim = self._current_animation
|
local old_anim = self._current_animation
|
||||||
if old_anim == "run" or old_anim == "walk" then
|
if old_anim == "run" or old_anim == "walk" then
|
||||||
mcl_mobs:set_animation(self, "reload_run")
|
self:set_animation("reload_run")
|
||||||
end
|
end
|
||||||
if old_anim == "stand" then
|
if old_anim == "stand" then
|
||||||
mcl_mobs:set_animation(self, "reload_stand")
|
self:set_animation("reload_stand")
|
||||||
end
|
end
|
||||||
self._current_animation = old_anim -- Mobs Redo will imediately reset the animation otherwise
|
self._current_animation = old_anim -- Mobs Redo will imediately reset the animation otherwise
|
||||||
minetest.after(1, reload, self)
|
minetest.after(1, reload, self)
|
||||||
minetest.after(2, reset_animation, self, old_anim)
|
minetest.after(2, reset_animation, self, old_anim)
|
||||||
|
|
||||||
-- 2-4 damage per arrow
|
-- 2-4 damage per arrow
|
||||||
local dmg = math.max(4, math.random(2, 8))
|
local dmg = math.max(4, math.random(2, 8))
|
||||||
mcl_bows_s.shoot_arrow_crossbow("mcl_bows:arrow", pos, dir, self.object:get_yaw(), self.object, nil, dmg)
|
mcl_bows_s.shoot_arrow_crossbow("mcl_bows:arrow", pos, dir, self.object:get_yaw(), self.object, nil, dmg)
|
||||||
|
|
||||||
-- While we are at it, change the sounds since there is no way to do this in Mobs Redo
|
-- While we are at it, change the sounds since there is no way to do this in Mobs Redo
|
||||||
if self.sounds and self.sounds.random then
|
if self.sounds and self.sounds.random then
|
||||||
self.sounds = table.copy(self.sounds)
|
self.sounds = table.copy(self.sounds)
|
||||||
self.sounds.random = "mobs_mc_pillager_grunt" .. math.random(2)
|
self.sounds.random = "mobs_mc_pillager_grunt" .. math.random(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Randomize reload time
|
-- Randomize reload time
|
||||||
self.shoot_interval = math.random(3, 4)
|
self.shoot_interval = math.random(3, 4)
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -83,10 +83,10 @@ mcl_mobs.register_mob("mobs_mc:shulker", {
|
||||||
end
|
end
|
||||||
if self.state == "walk" or self.state == "stand" then
|
if self.state == "walk" or self.state == "stand" then
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
mcl_mobs:set_animation(self, "stand")
|
self:set_animation("stand")
|
||||||
end
|
end
|
||||||
if self.state == "attack" then
|
if self.state == "attack" then
|
||||||
mcl_mobs:set_animation(self, "punch")
|
self:set_animation("punch")
|
||||||
end
|
end
|
||||||
self.path.way = false
|
self.path.way = false
|
||||||
self.look_at_players = false
|
self.look_at_players = false
|
||||||
|
@ -134,7 +134,7 @@ mcl_mobs.register_mob("mobs_mc:shulker", {
|
||||||
for n=1, math.min(8, #nodes) do
|
for n=1, math.min(8, #nodes) do
|
||||||
local r = pr:next(1, #nodes)
|
local r = pr:next(1, #nodes)
|
||||||
local nodepos = nodes[r]
|
local nodepos = nodes[r]
|
||||||
local tg = vector.offset(nodepos,0,1,0)
|
local tg = vector.offset(nodepos,0,0.5,0)
|
||||||
if check_spot(tg) then
|
if check_spot(tg) then
|
||||||
self.object:set_pos(tg)
|
self.object:set_pos(tg)
|
||||||
node_ok = true
|
node_ok = true
|
||||||
|
|
|
@ -71,7 +71,7 @@ local wolf = {
|
||||||
ent = dog:get_luaentity()
|
ent = dog:get_luaentity()
|
||||||
ent.owner = clicker:get_player_name()
|
ent.owner = clicker:get_player_name()
|
||||||
ent.tamed = true
|
ent.tamed = true
|
||||||
mcl_mobs:set_animation(ent, "sit")
|
ent:set_animation("sit")
|
||||||
ent.walk_chance = 0
|
ent.walk_chance = 0
|
||||||
ent.jump = false
|
ent.jump = false
|
||||||
ent.health = self.health
|
ent.health = self.health
|
||||||
|
@ -209,7 +209,7 @@ dog.on_rightclick = function(self, clicker)
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
self.walk_chance = default_walk_chance
|
self.walk_chance = default_walk_chance
|
||||||
self.jump = true
|
self.jump = true
|
||||||
mcl_mobs:set_animation(self, "stand")
|
self:set_animation("stand")
|
||||||
-- TODO: Add sitting model
|
-- TODO: Add sitting model
|
||||||
else
|
else
|
||||||
particle = "mobs_mc_wolf_icon_sit.png"
|
particle = "mobs_mc_wolf_icon_sit.png"
|
||||||
|
@ -217,7 +217,7 @@ dog.on_rightclick = function(self, clicker)
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
self.walk_chance = 0
|
self.walk_chance = 0
|
||||||
self.jump = false
|
self.jump = false
|
||||||
mcl_mobs:set_animation(self, "sit")
|
self:set_animation("sit")
|
||||||
end
|
end
|
||||||
-- Display icon to show current order (sit or roam)
|
-- Display icon to show current order (sit or roam)
|
||||||
minetest.add_particle({
|
minetest.add_particle({
|
||||||
|
|
Loading…
Reference in New Issue