From 93e2f1997a5022667caebdb224d2af396e84a85f Mon Sep 17 00:00:00 2001 From: epCode <64379263+epCode@users.noreply.github.com> Date: Tue, 11 Oct 2022 16:36:05 -0700 Subject: [PATCH] allow a spider/skeleton jockey to be spawnable with spawn_mob command --- mods/ENTITIES/mobs_mc/skeleton+stray.lua | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/skeleton+stray.lua b/mods/ENTITIES/mobs_mc/skeleton+stray.lua index 3954edf68..eb7c67802 100644 --- a/mods/ENTITIES/mobs_mc/skeleton+stray.lua +++ b/mods/ENTITIES/mobs_mc/skeleton+stray.lua @@ -89,14 +89,18 @@ local skeleton = { }, jock = "mobs_mc:spider", on_spawn = function(self) - self.jockey = false - if math.random(100) == 1 then -- 1% like from MCwiki - self.jockey = true - local jock = minetest.add_entity(self.object:get_pos(), "mobs_mc:spider") - jock:get_luaentity().docile_by_day = false - self.object:set_attach(jock, "", vector.new(0,0,0), vector.new(0,0,0)) - end - return true + minetest.after(1,function() + if self and self.object then + if math.random(100) == 1 or self.jockey == true then -- 1% like from MCwiki + self.jockey = true + local jock = minetest.add_entity(self.object:get_pos(), "mobs_mc:spider") + jock:get_luaentity().docile_by_day = false + self.object:set_attach(jock, "", vector.new(0,0,0), vector.new(0,0,0)) + end + self.jockey = false + return true + end + end) end, on_detach=function(self, parent) self.jockey = false