Skip to content
This repository has been archived by the owner on Dec 14, 2019. It is now read-only.

Commit

Permalink
Fix panic of sheep
Browse files Browse the repository at this point in the history
  • Loading branch information
BlockMen committed May 15, 2014
1 parent 3992e63 commit b449a66
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion init.lua
Expand Up @@ -10,7 +10,7 @@ creatures.ANIM_RUN = 6
-- Drop items (when not killed by player) only if items get removed
creatures.drop_on_death = false
local remove_items = minetest.setting_get("remove_items")
if minetest.get_modpath("builtin_item") ~= nil and remove_items ~= nil and remove_items > 0 then
if minetest.get_modpath("builtin_item") ~= nil and remove_items ~= nil and tonumber(remove_items) > 0 then
creatures.drop_on_death = true
end

Expand Down
9 changes: 5 additions & 4 deletions sheep.lua
Expand Up @@ -132,7 +132,8 @@ end

SHEEP_DEF.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
if not self.can_punch then return end


self.feeder = ""
--SET RUN state (panic)
self.state = 4
self.timer = 0
Expand Down Expand Up @@ -255,12 +256,12 @@ SHEEP_DEF.on_step = function(self, dtime)
elseif self.state == 4 and self.timer > 1.5 then
self.state = 2
self.timer = 0
else
self.timer = 0
elseif self.state == 5 then
local new = math.random(1,3)
if self.state == 3 then new = 1 end
if self.feeder ~= "" then new = 5 end
self.state = new
self.timer = 0
--s_update_visuals_def(self)
end

Expand Down Expand Up @@ -366,7 +367,7 @@ SHEEP_DEF.on_step = function(self, dtime)

-- EATING
if self.state == 3 then--and not self.has_wool then
self.object:setvelocity({x=0,y=self.object:getvelocity().y,z=0})
self.object:setvelocity({x=0,y=-20,z=0})
local p = {x=current_pos.x,y=current_pos.y-1,z=current_pos.z}
local n = minetest.get_node(p) or nil
if n and n.name and n.name == "default:dirt_with_grass" then
Expand Down

0 comments on commit b449a66

Please sign in to comment.