1 --this controls how the mob saves and loads it's internal data
3 --save (happens when the mob despawns/server/singleplayer game shuts down)
4 exploder.get_staticdata = function(self)
5 return minetest.serialize({
9 hostile = self.hostile,
10 hostile_timer = self.hostile_timer,
11 death_animation_timer = self.death_animation_timer,
16 --load the mob's data when brough back into the world
17 exploder.on_activate = function(self, staticdata, dtime_s)
18 self.object:set_armor_groups({immortal = 1})
19 --self.object:set_velocity({x = math.random(-5,5), y = 5, z = math.random(-5,5)})
20 self.object:set_acceleration({x = 0, y = -9.81, z = 0})
21 if string.sub(staticdata, 1, string.len("return")) == "return" then
22 local data = minetest.deserialize(staticdata)
23 if data and type(data) == "table" then
24 --self.range = data.range
26 self.hunger = data.hunger
27 self.hostile = data.hostile
28 self.hostile_timer = data.hostile_timer
29 self.death_animation_timer = data.death_animation_timer
35 self.object:set_animation({x=0,y=5}, 30, 0, true)
36 self.object:set_hp(self.hp)
37 self.direction = vector.new(math.random()*math.random(-1,1),0,math.random()*math.random(-1,1))
41 local head = minetest.add_entity(self.object:get_pos(), "mob:head")
44 self.child:get_luaentity().parent = self.object
45 self.child:set_attach(self.object, "", self.head_mount, vector.new(0,0,0))
46 self.head_rotation = vector.new(0,0,0)
47 self.child:set_animation({x=90,y=90}, 15, 0, true)
51 self.object:set_armor_groups({immortal = 1})
52 --self.object:set_yaw(math.pi*math.random(-1,1)*math.random())
56 --this is the info on the mob
57 exploder.debug_nametag = function(self,dtime)
58 --we're doing this to the child because the nametage breaks the
59 --animation on the mob's body
61 --we add in items we want to see in this list
62 local debug_items = {"hostile_timer","hostile"}
64 for _,item in pairs(debug_items) do
65 if self[item] ~= nil then
66 text = text..item..": "..tostring(self[item]).."\n"
69 self.child:set_nametag_attributes({