From cce6dac74f1736bd1f1d830192632e8bbd616c62 Mon Sep 17 00:00:00 2001 From: Hume2 Date: Fri, 7 Sep 2018 18:29:59 +0200 Subject: Slow down on bike-unfriendly blocks like dirt and sand --- init.lua | 9 +++++++++ 1 file changed, 9 insertions(+) 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) -- cgit v1.2.3