Fix nil error on tool_capabilities

This commit is contained in:
SmallJoker 2015-09-13 18:38:53 +02:00
parent afb52ba3b4
commit 145ca1c61d
1 changed files with 30 additions and 26 deletions

View File

@ -116,8 +116,12 @@ function boost_cart.cart:on_punch(puncher, time_from_last_punch, tool_capabiliti
return
end
time_from_last_punch = math.min(time_from_last_punch, tool_capabilities.full_punch_interval)
local f = 3 * (time_from_last_punch / tool_capabilities.full_punch_interval)
local punch_interval = 1
if tool_capabilities and tool_capabilities.full_punch_interval then
punch_interval = tool_capabilities.full_punch_interval
end
time_from_last_punch = math.min(time_from_last_punch or punch_interval, punch_interval)
local f = 3 * (time_from_last_punch / punch_interval)
self.velocity = vector.multiply(cart_dir, f)
self.old_pos = nil