summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHume2 <teratux.mail@gmail.com>2018-09-07 18:29:59 +0200
committerHume2 <teratux.mail@gmail.com>2018-09-07 18:36:20 +0200
commitcce6dac74f1736bd1f1d830192632e8bbd616c62 (patch)
treebb5dc5a7f43a1d06f071b30a1fd3485ac3e2b24c
parent95403b81b087d9666a4d914ba889f8c04af6ef56 (diff)
Slow down on bike-unfriendly blocks like dirt and sand
-rw-r--r--init.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/init.lua b/init.lua
index 90a9a2b..77d327d 100644
--- a/init.lua
+++ b/init.lua
@@ -8,6 +8,12 @@ local function is_water(pos)
end
+local function is_bike_friendly(pos)
+ local nn = minetest.get_node(pos).name
+ return minetest.get_item_group(nn, "crumbly") == 0 or minetest.get_item_group(nn, "bike_friendly") ~= 0
+end
+
+
local function get_sign(i)
if i == 0 then
return 0
@@ -197,6 +203,9 @@ function bike.on_step(self, dtime)
if is_water(p) then
self.v = self.v / 1.3
end
+ if not is_bike_friendly({x=p.x, y=p.y-0.355, z=p.z}) then
+ self.v = self.v / 1.05
+ end
local new_velo
new_velo = get_velocity(self.v, self.object:get_yaw(), self.object:get_velocity().y)