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 slime.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 slime.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=0}, 1, 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))
40 self.object:set_armor_groups({immortal = 1})
41 --self.object:set_yaw(math.pi*math.random(-1,1)*math.random())
45 --this is the info on the mob
46 slime.debug_nametag = function(self,dtime)
47 --we add in items we want to see in this list
48 local debug_items = {"hostile_timer","hostile"}
50 for _,item in pairs(debug_items) do
51 if self[item] ~= nil then
52 text = text..item..": "..tostring(self[item]).."\n"
55 self.child:set_nametag_attributes({