From 7914ee6a113b996e6edd40bc2ecb1cb017d288ea Mon Sep 17 00:00:00 2001 From: Alexsandro Percy Date: Wed, 19 Jan 2022 10:12:48 -0300 Subject: [PATCH] name changed to avoid collision with another mod --- automobiles/automobiles_control.lua | 105 ------------------ automobiles/automobiles_custom_physics.lua | 66 ----------- {automobiles => automobiles_lib}/control.lua | 8 +- .../custom_physics.lua | 2 +- .../fuel_management.lua | 8 +- .../ground_detection.lua | 32 +++--- {automobiles => automobiles_lib}/init.lua | 40 +++---- {automobiles => automobiles_lib}/mod.conf | 2 +- .../models/automobiles_pivot_mesh.b3d | Bin .../models/automobiles_pointer.b3d | Bin .../textures/automobiles_alpha.png | Bin .../textures/automobiles_black.png | Bin .../textures/automobiles_glass.png | Bin .../textures/automobiles_grey.png | Bin .../textures/automobiles_metal.png | Bin .../textures/automobiles_metal2.png | Bin .../textures/automobiles_painting.png | Bin .../textures/automobiles_red.png | Bin .../textures/automobiles_target.png | Bin .../textures/automobiles_white.png | Bin .../textures/automobiles_wood.png | Bin .../textures/automobiles_wood2.png | Bin automobiles_roadster/init.lua | 10 +- automobiles_roadster/mod.conf | 2 +- automobiles_roadster/roadster_crafts.lua | 2 +- automobiles_roadster/roadster_entities.lua | 44 ++++---- automobiles_roadster/roadster_forms.lua | 4 +- modpack.conf | 2 +- 28 files changed, 78 insertions(+), 249 deletions(-) delete mode 100644 automobiles/automobiles_control.lua delete mode 100644 automobiles/automobiles_custom_physics.lua rename {automobiles => automobiles_lib}/control.lua (92%) rename {automobiles => automobiles_lib}/custom_physics.lua (97%) rename {automobiles => automobiles_lib}/fuel_management.lua (79%) rename {automobiles => automobiles_lib}/ground_detection.lua (71%) rename {automobiles => automobiles_lib}/init.lua (83%) rename {automobiles => automobiles_lib}/mod.conf (50%) rename {automobiles => automobiles_lib}/models/automobiles_pivot_mesh.b3d (100%) rename {automobiles => automobiles_lib}/models/automobiles_pointer.b3d (100%) rename {automobiles => automobiles_lib}/textures/automobiles_alpha.png (100%) rename {automobiles => automobiles_lib}/textures/automobiles_black.png (100%) rename {automobiles => automobiles_lib}/textures/automobiles_glass.png (100%) rename {automobiles => automobiles_lib}/textures/automobiles_grey.png (100%) rename {automobiles => automobiles_lib}/textures/automobiles_metal.png (100%) rename {automobiles => automobiles_lib}/textures/automobiles_metal2.png (100%) rename {automobiles => automobiles_lib}/textures/automobiles_painting.png (100%) rename {automobiles => automobiles_lib}/textures/automobiles_red.png (100%) rename {automobiles => automobiles_lib}/textures/automobiles_target.png (100%) rename {automobiles => automobiles_lib}/textures/automobiles_white.png (100%) rename {automobiles => automobiles_lib}/textures/automobiles_wood.png (100%) rename {automobiles => automobiles_lib}/textures/automobiles_wood2.png (100%) diff --git a/automobiles/automobiles_control.lua b/automobiles/automobiles_control.lua deleted file mode 100644 index 2e9c91a..0000000 --- a/automobiles/automobiles_control.lua +++ /dev/null @@ -1,105 +0,0 @@ ---global constants - -automobiles.vector_up = vector.new(0, 1, 0) - -function automobiles.check_road_is_ok(obj, max_acc_factor) - local pos_below = obj:get_pos() - pos_below.y = pos_below.y - 0.1 - local node_below = minetest.get_node(pos_below).name - --minetest.chat_send_all(node_below) - local nodedef = minetest.registered_nodes[node_below] - if nodedef.liquidtype == "none" then - local slow_nodes = { - ['default:ice '] = 0.01, - ['default:cave_ice'] = 0.01, - } - local acc = slow_nodes[node_below] - if acc == nil then acc = max_acc_factor end - return acc - else - return 0 - end -end - -function automobiles.control(self, dtime, hull_direction, longit_speed, longit_drag, later_drag, accel, max_acc_factor, max_speed, steering_limit, steering_speed) - self._last_time_command = self._last_time_command + dtime - if self._last_time_command > 1 then self._last_time_command = 1 end - - local player = minetest.get_player_by_name(self.driver_name) - local retval_accel = accel; - local stop = false - - -- player control - if player then - local ctrl = player:get_player_control() - - local acc = 0 - - if longit_speed < roadster.max_speed and ctrl.up then - --get acceleration factor - acc = automobiles.check_road_is_ok(self.object, max_acc_factor) - --minetest.chat_send_all('engineacc: '.. engineacc) - if acc > 1 and acc < max_acc_factor and longit_speed > 0 then - --improper road will reduce speed - acc = -1 - end - end - - --reversing - if ctrl.sneak and longit_speed <= 1.0 and longit_speed > -1.0 then - acc = -1 - end - - --break - if ctrl.down then - - --total stop - --wheel break - if longit_speed > 0 then - acc = -5 - if (longit_speed + acc) < 0 then - acc = longit_speed * -1 - end - end - if longit_speed < 0 then - acc = 5 - if (longit_speed + acc) > 0 then - acc = longit_speed * -1 - end - end - if abs(longit_speed) < 0.2 then - stop = true - end - end - - if acc then retval_accel=vector.add(accel,vector.multiply(hull_direction,acc)) end - - -- steering - if ctrl.right then - self._steering_angle = math.max(self._steering_angle-steering_speed*dtime,-steering_limit) - elseif ctrl.left then - self._steering_angle = math.min(self._steering_angle+steering_speed*dtime,steering_limit) - else - --center steering - if longit_speed > 0 then - local factor = 1 - if self._steering_angle > 0 then factor = -1 end - local correction = (steering_limit*(longit_speed/100)) * factor - local before_correction = self._steering_angle - self._steering_angle = self._steering_angle + correction - if math.sign(before_correction) ~= math.sign(self._steering_angle) then self._steering_angle = 0 end - end - end - - local angle_factor = self._steering_angle / 60 - if angle_factor < 0 then angle_factor = angle_factor * -1 end - local deacc_on_curve = longit_speed * angle_factor - deacc_on_curve = deacc_on_curve * -1 - if deacc_on_curve then retval_accel=vector.add(retval_accel,vector.multiply(hull_direction,deacc_on_curve)) end - - end - - return retval_accel, stop -end - - diff --git a/automobiles/automobiles_custom_physics.lua b/automobiles/automobiles_custom_physics.lua deleted file mode 100644 index 9614aa3..0000000 --- a/automobiles/automobiles_custom_physics.lua +++ /dev/null @@ -1,66 +0,0 @@ -local min = math.min -local abs = math.abs - -function automobiles.physics(self) - local friction = 0.99 - local vel=self.object:get_velocity() - -- dumb friction - if self.isonground and not self.isinliquid then - --minetest.chat_send_all('okay') - self.object:set_velocity({x=vel.x*friction, - y=vel.y, - z=vel.z*friction}) - end - - -- bounciness - if self.springiness and self.springiness > 0 then - local vnew = vector.new(vel) - - if not self.collided then -- ugly workaround for inconsistent collisions - for _,k in ipairs({'y','z','x'}) do - if vel[k]==0 and abs(self.lastvelocity[k])> 0.1 then - vnew[k]=-self.lastvelocity[k]*self.springiness - end - end - end - - if not vector.equals(vel,vnew) then - self.collided = true - else - if self.collided then - vnew = vector.new(self.lastvelocity) - end - self.collided = false - end - - self.object:set_velocity(vnew) - end - - -- buoyancy - local surface = nil - local surfnodename = nil - local spos = mobkit.get_stand_pos(self) - spos.y = spos.y+0.01 - -- get surface height - local snodepos = mobkit.get_node_pos(spos) - local surfnode = mobkit.nodeatpos(spos) - while surfnode and (surfnode.drawtype == 'liquid' or surfnode.drawtype == 'flowingliquid') do - surfnodename = surfnode.name - surface = snodepos.y +0.5 - if surface > spos.y+self.height then break end - snodepos.y = snodepos.y+1 - surfnode = mobkit.nodeatpos(snodepos) - end - self.isinliquid = surfnodename - if surface then -- standing in liquid --- self.isinliquid = true - local submergence = min(surface-spos.y,self.height)/self.height --- local balance = self.buoyancy*self.height - local buoyacc = mobkit.gravity*(self.buoyancy-submergence) - mobkit.set_acceleration(self.object, - {x=-vel.x*self.water_drag,y=buoyacc-vel.y*abs(vel.y)*0.4,z=-vel.z*self.water_drag}) - else - self.object:set_acceleration({x=0,y=mobkit.gravity,z=0}) - end - -end diff --git a/automobiles/control.lua b/automobiles_lib/control.lua similarity index 92% rename from automobiles/control.lua rename to automobiles_lib/control.lua index 53bb3ba..f207d49 100755 --- a/automobiles/control.lua +++ b/automobiles_lib/control.lua @@ -1,8 +1,8 @@ --global constants -automobiles.vector_up = vector.new(0, 1, 0) +automobiles_lib.vector_up = vector.new(0, 1, 0) -function automobiles.check_road_is_ok(obj, max_acc_factor) +function automobiles_lib.check_road_is_ok(obj, max_acc_factor) local pos_below = obj:get_pos() pos_below.y = pos_below.y - 0.1 local node_below = minetest.get_node(pos_below).name @@ -21,7 +21,7 @@ function automobiles.check_road_is_ok(obj, max_acc_factor) end end -function automobiles.control(self, dtime, hull_direction, longit_speed, longit_drag, later_drag, accel, max_acc_factor, max_speed, steering_limit, steering_speed) +function automobiles_lib.control(self, dtime, hull_direction, longit_speed, longit_drag, later_drag, accel, max_acc_factor, max_speed, steering_limit, steering_speed) self._last_time_command = self._last_time_command + dtime if self._last_time_command > 1 then self._last_time_command = 1 end @@ -37,7 +37,7 @@ function automobiles.control(self, dtime, hull_direction, longit_speed, longit_d if self._energy > 0 then if longit_speed < roadster.max_speed and ctrl.up then --get acceleration factor - acc = automobiles.check_road_is_ok(self.object, max_acc_factor) + acc = automobiles_lib.check_road_is_ok(self.object, max_acc_factor) --minetest.chat_send_all('engineacc: '.. engineacc) if acc > 1 and acc < max_acc_factor and longit_speed > 0 then --improper road will reduce speed diff --git a/automobiles/custom_physics.lua b/automobiles_lib/custom_physics.lua similarity index 97% rename from automobiles/custom_physics.lua rename to automobiles_lib/custom_physics.lua index 9614aa3..be58673 100755 --- a/automobiles/custom_physics.lua +++ b/automobiles_lib/custom_physics.lua @@ -1,7 +1,7 @@ local min = math.min local abs = math.abs -function automobiles.physics(self) +function automobiles_lib.physics(self) local friction = 0.99 local vel=self.object:get_velocity() -- dumb friction diff --git a/automobiles/fuel_management.lua b/automobiles_lib/fuel_management.lua similarity index 79% rename from automobiles/fuel_management.lua rename to automobiles_lib/fuel_management.lua index a2d63b4..c1f439f 100755 --- a/automobiles/fuel_management.lua +++ b/automobiles_lib/fuel_management.lua @@ -2,7 +2,7 @@ -- fuel -- -function automobiles.contains(table, val) +function automobiles_lib.contains(table, val) for k,v in pairs(table) do if k == val then return v @@ -11,7 +11,7 @@ function automobiles.contains(table, val) return false end -function automobiles.loadFuel(self, player_name, free, max_fuel) +function automobiles_lib.loadFuel(self, player_name, free, max_fuel) free = free or false local player = minetest.get_player_by_name(player_name) @@ -21,7 +21,7 @@ function automobiles.loadFuel(self, player_name, free, max_fuel) local item_name = "" if itmstck then item_name = itmstck:get_name() end - local fuel = automobiles.contains(automobiles.fuel, item_name) + local fuel = automobiles_lib.contains(automobiles_lib.fuel, item_name) if fuel or free == true then local stack = ItemStack(item_name .. " 1") if self._energy < max_fuel then @@ -30,7 +30,7 @@ function automobiles.loadFuel(self, player_name, free, max_fuel) self._energy = self._energy + fuel end if self._energy > max_fuel then self._energy = max_fuel end - automobiles.last_fuel_display = 0 + automobiles_lib.last_fuel_display = 0 if self._energy == max_fuel then minetest.chat_send_player(player_name, "Full tank!") end end diff --git a/automobiles/ground_detection.lua b/automobiles_lib/ground_detection.lua similarity index 71% rename from automobiles/ground_detection.lua rename to automobiles_lib/ground_detection.lua index 400a3ab..3643b50 100644 --- a/automobiles/ground_detection.lua +++ b/automobiles_lib/ground_detection.lua @@ -1,5 +1,5 @@ --lets assume that the rear axis is at object center, so we will use the distance only for front wheels -function automobiles.ground_get_distances(self, radius, axis_distance) +function automobiles_lib.ground_get_distances(self, radius, axis_distance) --local mid_axis = (axis_length / 2)/10 local hip = axis_distance @@ -14,35 +14,35 @@ function automobiles.ground_get_distances(self, radius, axis_distance) local pos = self.object:get_pos() - local r_x, r_z = automobiles.get_xz_from_hipotenuse(pos.x, pos.z, yaw, 0) + local r_x, r_z = automobiles_lib.get_xz_from_hipotenuse(pos.x, pos.z, yaw, 0) local r_y = pos.y local rear_axis = {x=r_x, y=r_y, z=r_z} - local rear_obstacle_level = automobiles.get_obstacle(rear_axis) + local rear_obstacle_level = automobiles_lib.get_obstacle(rear_axis) --minetest.chat_send_all("rear"..dump(rear_obstacle_level)) - local f_x, f_z = automobiles.get_xz_from_hipotenuse(pos.x, pos.z, yaw, hip) - local x, f_y = automobiles.get_xz_from_hipotenuse(f_x, r_y, pitch - math.rad(90), hip) --the x is only a mock + local f_x, f_z = automobiles_lib.get_xz_from_hipotenuse(pos.x, pos.z, yaw, hip) + local x, f_y = automobiles_lib.get_xz_from_hipotenuse(f_x, r_y, pitch - math.rad(90), hip) --the x is only a mock --minetest.chat_send_all("r: "..r_y.." f: "..f_y .." - "..math.deg(pitch)) local front_axis = {x=f_x, y=f_y, z=f_z} - local front_obstacle_level = automobiles.get_obstacle(front_axis) + local front_obstacle_level = automobiles_lib.get_obstacle(front_axis) --minetest.chat_send_all("front"..dump(front_obstacle_level)) --[[local left_front = {x=0, y=f_y, z=0} - left_front.x, left_front.z = automobiles.get_xz_from_hipotenuse(f_x, f_z, yaw+math.rad(90), mid_axis) + left_front.x, left_front.z = automobiles_lib.get_xz_from_hipotenuse(f_x, f_z, yaw+math.rad(90), mid_axis) local right_front = {x=0, y=f_y, z=0} - right_front.x, right_front.z = automobiles.get_xz_from_hipotenuse(f_x, f_z, yaw-math.rad(90), mid_axis)]]-- + right_front.x, right_front.z = automobiles_lib.get_xz_from_hipotenuse(f_x, f_z, yaw-math.rad(90), mid_axis)]]-- --[[ - local rear_obstacle_level = automobiles.get_obstacle(rear_axis, 0.2, 0.25)]]-- + local rear_obstacle_level = automobiles_lib.get_obstacle(rear_axis, 0.2, 0.25)]]-- --[[local left_rear = {x=0, y=r_y, z=0} - left_rear.x, left_rear.z = automobiles.get_xz_from_hipotenuse(r_x, r_z, yaw+math.rad(90), mid_axis) + left_rear.x, left_rear.z = automobiles_lib.get_xz_from_hipotenuse(r_x, r_z, yaw+math.rad(90), mid_axis) local right_rear = {x=0, y=r_y, z=0} - right_rear.x, right_rear.z = automobiles.get_xz_from_hipotenuse(r_x, r_z, yaw-math.rad(90), mid_axis)]]-- + right_rear.x, right_rear.z = automobiles_lib.get_xz_from_hipotenuse(r_x, r_z, yaw-math.rad(90), mid_axis)]]-- --lets try to get the pitch if front_obstacle_level.y ~= nil and rear_obstacle_level.y ~= nil then @@ -62,7 +62,7 @@ function automobiles.ground_get_distances(self, radius, axis_distance) end -function automobiles.get_xz_from_hipotenuse(orig_x, orig_z, yaw, distance) +function automobiles_lib.get_xz_from_hipotenuse(orig_x, orig_z, yaw, distance) --cara, o minetest é bizarro, ele considera o eixo no sentido ANTI-HORÁRIO... Então pra equação funcionar, subtrair o angulo de 360 antes yaw = math.rad(360) - yaw local z = (math.cos(yaw)*distance) + orig_z @@ -70,14 +70,14 @@ function automobiles.get_xz_from_hipotenuse(orig_x, orig_z, yaw, distance) return x, z end -function automobiles.get_obstacle(ref_pos) +function automobiles_lib.get_obstacle(ref_pos) --lets clone the table local retval = {x=ref_pos.x, y=ref_pos.y, z=ref_pos.z} --minetest.chat_send_all("aa y: " .. dump(retval.y)) local i_pos = {x=ref_pos.x, y=ref_pos.y, z=ref_pos.z} --minetest.chat_send_all("bb y: " .. dump(i_pos.y)) - local y = automobiles.eval_interception(i_pos, {x=i_pos.x, y=i_pos.y - 2, z=i_pos.z}) + local y = automobiles_lib.eval_interception(i_pos, {x=i_pos.x, y=i_pos.y - 2, z=i_pos.z}) if y then retval.y = y end @@ -94,7 +94,7 @@ local function get_nodedef_field(nodename, fieldname) return minetest.registered_nodes[nodename][fieldname] end -function automobiles.eval_interception(initial_pos, end_pos) +function automobiles_lib.eval_interception(initial_pos, end_pos) local ret_y = nil local cast = minetest.raycast(initial_pos, end_pos, true, false) local thing = cast:next() @@ -116,7 +116,7 @@ function automobiles.eval_interception(initial_pos, end_pos) return ret_y end -function automobiles.get_node_below(pos, dist) +function automobiles_lib.get_node_below(pos, dist) local node = minetest.get_node(pos) local pos_below = pos pos_below.y = pos_below.y - (dist + 0.1) diff --git a/automobiles/init.lua b/automobiles_lib/init.lua similarity index 83% rename from automobiles/init.lua rename to automobiles_lib/init.lua index 01dbd26..380d637 100755 --- a/automobiles/init.lua +++ b/automobiles_lib/init.lua @@ -1,15 +1,15 @@ -- Minetest 5.4.1 : automobiles -automobiles = {} +automobiles_lib = {} -automobiles.fuel = {['biofuel:biofuel'] = 1,['biofuel:bottle_fuel'] = 1, +automobiles_lib.fuel = {['biofuel:biofuel'] = 1,['biofuel:bottle_fuel'] = 1, ['biofuel:phial_fuel'] = 0.25, ['biofuel:fuel_can'] = 10} -automobiles.gravity = 9.8 -automobiles.is_creative = minetest.settings:get_bool("creative_mode", false) +automobiles_lib.gravity = 9.8 +automobiles_lib.is_creative = minetest.settings:get_bool("creative_mode", false) --cars colors -automobiles.colors ={ +automobiles_lib.colors ={ black='#2b2b2b', blue='#0063b0', brown='#8c5922', @@ -31,24 +31,24 @@ automobiles.colors ={ -- helpers and co. -- -function automobiles.get_hipotenuse_value(point1, point2) +function automobiles_lib.get_hipotenuse_value(point1, point2) return math.sqrt((point1.x - point2.x) ^ 2 + (point1.y - point2.y) ^ 2 + (point1.z - point2.z) ^ 2) end -function automobiles.dot(v1,v2) +function automobiles_lib.dot(v1,v2) return (v1.x*v2.x)+(v1.y*v2.y)+(v1.z*v2.z) end -function automobiles.sign(n) +function automobiles_lib.sign(n) return n>=0 and 1 or -1 end -function automobiles.minmax(v,m) +function automobiles_lib.minmax(v,m) return math.min(math.abs(v),m)*minekart.sign(v) end --painting -function automobiles.paint(self, colstr) +function automobiles_lib.paint(self, colstr) if colstr then self._color = colstr local l_textures = self.initial_properties.textures @@ -63,7 +63,7 @@ function automobiles.paint(self, colstr) end -- attach player -function automobiles.attach_driver(self, player) +function automobiles_lib.attach_driver(self, player) local name = player:get_player_name() self.driver_name = name @@ -82,7 +82,7 @@ function automobiles.attach_driver(self, player) end) end -function automobiles.dettach_driver(self, player) +function automobiles_lib.dettach_driver(self, player) local name = self.driver_name --self._engine_running = false @@ -101,7 +101,7 @@ function automobiles.dettach_driver(self, player) -- detach the player if player then - --automobiles.remove_hud(player) + --automobiles_lib.remove_hud(player) player:set_detach() player_api.player_attached[name] = nil @@ -112,7 +112,7 @@ function automobiles.dettach_driver(self, player) end -- attach passenger -function automobiles.attach_pax(self, player, onside) +function automobiles_lib.attach_pax(self, player, onside) local onside = onside or false local name = player:get_player_name() @@ -170,7 +170,7 @@ function automobiles.attach_pax(self, player, onside) end end -function automobiles.dettach_pax(self, player) +function automobiles_lib.dettach_pax(self, player) local name = player:get_player_name() --self._passenger -- passenger clicked the object => driver gets off the vehicle @@ -194,7 +194,7 @@ function automobiles.dettach_pax(self, player) --remove_physics_override(player, {speed=1,gravity=1,jump=1}) end -function automobiles.get_gauge_angle(value, initial_angle) +function automobiles_lib.get_gauge_angle(value, initial_angle) initial_angle = initial_angle or 90 local angle = value * 18 angle = angle - initial_angle @@ -202,8 +202,8 @@ function automobiles.get_gauge_angle(value, initial_angle) return angle end -dofile(minetest.get_modpath("automobiles") .. DIR_DELIM .. "custom_physics.lua") -dofile(minetest.get_modpath("automobiles") .. DIR_DELIM .. "control.lua") -dofile(minetest.get_modpath("automobiles") .. DIR_DELIM .. "fuel_management.lua") -dofile(minetest.get_modpath("automobiles") .. DIR_DELIM .. "ground_detection.lua") +dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "custom_physics.lua") +dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "control.lua") +dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "fuel_management.lua") +dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "ground_detection.lua") diff --git a/automobiles/mod.conf b/automobiles_lib/mod.conf similarity index 50% rename from automobiles/mod.conf rename to automobiles_lib/mod.conf index e014792..098c20b 100755 --- a/automobiles/mod.conf +++ b/automobiles_lib/mod.conf @@ -1,2 +1,2 @@ -name = automobiles +name = automobiles_lib depends=biofuel,mobkit diff --git a/automobiles/models/automobiles_pivot_mesh.b3d b/automobiles_lib/models/automobiles_pivot_mesh.b3d similarity index 100% rename from automobiles/models/automobiles_pivot_mesh.b3d rename to automobiles_lib/models/automobiles_pivot_mesh.b3d diff --git a/automobiles/models/automobiles_pointer.b3d b/automobiles_lib/models/automobiles_pointer.b3d similarity index 100% rename from automobiles/models/automobiles_pointer.b3d rename to automobiles_lib/models/automobiles_pointer.b3d diff --git a/automobiles/textures/automobiles_alpha.png b/automobiles_lib/textures/automobiles_alpha.png similarity index 100% rename from automobiles/textures/automobiles_alpha.png rename to automobiles_lib/textures/automobiles_alpha.png diff --git a/automobiles/textures/automobiles_black.png b/automobiles_lib/textures/automobiles_black.png similarity index 100% rename from automobiles/textures/automobiles_black.png rename to automobiles_lib/textures/automobiles_black.png diff --git a/automobiles/textures/automobiles_glass.png b/automobiles_lib/textures/automobiles_glass.png similarity index 100% rename from automobiles/textures/automobiles_glass.png rename to automobiles_lib/textures/automobiles_glass.png diff --git a/automobiles/textures/automobiles_grey.png b/automobiles_lib/textures/automobiles_grey.png similarity index 100% rename from automobiles/textures/automobiles_grey.png rename to automobiles_lib/textures/automobiles_grey.png diff --git a/automobiles/textures/automobiles_metal.png b/automobiles_lib/textures/automobiles_metal.png similarity index 100% rename from automobiles/textures/automobiles_metal.png rename to automobiles_lib/textures/automobiles_metal.png diff --git a/automobiles/textures/automobiles_metal2.png b/automobiles_lib/textures/automobiles_metal2.png similarity index 100% rename from automobiles/textures/automobiles_metal2.png rename to automobiles_lib/textures/automobiles_metal2.png diff --git a/automobiles/textures/automobiles_painting.png b/automobiles_lib/textures/automobiles_painting.png similarity index 100% rename from automobiles/textures/automobiles_painting.png rename to automobiles_lib/textures/automobiles_painting.png diff --git a/automobiles/textures/automobiles_red.png b/automobiles_lib/textures/automobiles_red.png similarity index 100% rename from automobiles/textures/automobiles_red.png rename to automobiles_lib/textures/automobiles_red.png diff --git a/automobiles/textures/automobiles_target.png b/automobiles_lib/textures/automobiles_target.png similarity index 100% rename from automobiles/textures/automobiles_target.png rename to automobiles_lib/textures/automobiles_target.png diff --git a/automobiles/textures/automobiles_white.png b/automobiles_lib/textures/automobiles_white.png similarity index 100% rename from automobiles/textures/automobiles_white.png rename to automobiles_lib/textures/automobiles_white.png diff --git a/automobiles/textures/automobiles_wood.png b/automobiles_lib/textures/automobiles_wood.png similarity index 100% rename from automobiles/textures/automobiles_wood.png rename to automobiles_lib/textures/automobiles_wood.png diff --git a/automobiles/textures/automobiles_wood2.png b/automobiles_lib/textures/automobiles_wood2.png similarity index 100% rename from automobiles/textures/automobiles_wood2.png rename to automobiles_lib/textures/automobiles_wood2.png diff --git a/automobiles_roadster/init.lua b/automobiles_roadster/init.lua index f1f27e9..4479dcd 100755 --- a/automobiles_roadster/init.lua +++ b/automobiles_roadster/init.lua @@ -4,7 +4,7 @@ roadster={} roadster.LONGIT_DRAG_FACTOR = 0.16*0.16 roadster.LATER_DRAG_FACTOR = 30.0 -roadster.gravity = automobiles.gravity +roadster.gravity = automobiles_lib.gravity roadster.max_speed = 15 roadster.max_acc_factor = 5 roadster.max_fuel = 10 @@ -14,10 +14,10 @@ ROADSTER_GAUGE_FUEL_POSITION = {x=0,y=8.04,z=17.84} roadster.front_wheel_xpos = 10.26 roadster.rear_wheel_xpos = 10.26 -dofile(minetest.get_modpath("automobiles") .. DIR_DELIM .. "custom_physics.lua") -dofile(minetest.get_modpath("automobiles") .. DIR_DELIM .. "control.lua") -dofile(minetest.get_modpath("automobiles") .. DIR_DELIM .. "fuel_management.lua") -dofile(minetest.get_modpath("automobiles") .. DIR_DELIM .. "ground_detection.lua") +dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "custom_physics.lua") +dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "control.lua") +dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "fuel_management.lua") +dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "ground_detection.lua") dofile(minetest.get_modpath("automobiles_roadster") .. DIR_DELIM .. "roadster_utilities.lua") dofile(minetest.get_modpath("automobiles_roadster") .. DIR_DELIM .. "roadster_entities.lua") dofile(minetest.get_modpath("automobiles_roadster") .. DIR_DELIM .. "roadster_forms.lua") diff --git a/automobiles_roadster/mod.conf b/automobiles_roadster/mod.conf index a9586fe..32e0ea8 100755 --- a/automobiles_roadster/mod.conf +++ b/automobiles_roadster/mod.conf @@ -2,4 +2,4 @@ name=automobiles_roadster title=Roadster description=A roadster automobile author=apercy -depends=biofuel,automobiles,mobkit +depends=biofuel,automobiles_lib,mobkit diff --git a/automobiles_roadster/roadster_crafts.lua b/automobiles_roadster/roadster_crafts.lua index fbefff4..21b5c5d 100644 --- a/automobiles_roadster/roadster_crafts.lua +++ b/automobiles_roadster/roadster_crafts.lua @@ -39,7 +39,7 @@ minetest.register_craftitem("automobiles_roadster:roadster", { ent.owner = owner car:set_yaw(placer:get_look_horizontal()) itemstack:take_item() - ent.object:set_acceleration({x=0,y=-automobiles.gravity,z=0}) + ent.object:set_acceleration({x=0,y=-automobiles_lib.gravity,z=0}) end end diff --git a/automobiles_roadster/roadster_entities.lua b/automobiles_roadster/roadster_entities.lua index ea12761..9ca62eb 100755 --- a/automobiles_roadster/roadster_entities.lua +++ b/automobiles_roadster/roadster_entities.lua @@ -220,7 +220,7 @@ minetest.register_entity("automobiles_roadster:roadster", { infotext = "A very nice roadster!", hp = 50, buoyancy = 2, - physics = automobiles.physics, + physics = automobiles_lib.physics, lastvelocity = vector.new(), time_total = 0, _passenger = nil, @@ -274,7 +274,7 @@ minetest.register_entity("automobiles_roadster:roadster", { self.object:set_animation({x = 1, y = 8}, 0, 0, true) - automobiles.paint(self, self._color) + automobiles_lib.paint(self, self._color) local pos = self.object:get_pos() local top1=minetest.add_entity(self.object:get_pos(),'automobiles_roadster:top1') @@ -361,14 +361,14 @@ minetest.register_entity("automobiles_roadster:roadster", { local nhdir = {x=hull_direction.z,y=0,z=-hull_direction.x} -- lateral unit vector local velocity = self.object:get_velocity() - local longit_speed = automobiles.dot(velocity,hull_direction) + local longit_speed = automobiles_lib.dot(velocity,hull_direction) local fuel_weight_factor = (5 - self._energy)/5000 local longit_drag = vector.multiply(hull_direction,(longit_speed*longit_speed) * - (roadster.LONGIT_DRAG_FACTOR - fuel_weight_factor) * -1 * automobiles.sign(longit_speed)) + (roadster.LONGIT_DRAG_FACTOR - fuel_weight_factor) * -1 * automobiles_lib.sign(longit_speed)) - local later_speed = automobiles.dot(velocity,nhdir) + local later_speed = automobiles_lib.dot(velocity,nhdir) local later_drag = vector.multiply(nhdir,later_speed* - later_speed*roadster.LATER_DRAG_FACTOR*-1*automobiles.sign(later_speed)) + later_speed*roadster.LATER_DRAG_FACTOR*-1*automobiles_lib.sign(later_speed)) local accel = vector.add(longit_drag,later_drag) @@ -411,7 +411,7 @@ minetest.register_entity("automobiles_roadster:roadster", { local curr_pos = self.object:get_pos() if is_attached then --and self.driver_name == self.owner then - local impact = automobiles.get_hipotenuse_value(velocity, self.lastvelocity) + local impact = automobiles_lib.get_hipotenuse_value(velocity, self.lastvelocity) if impact > 1 then --self.damage = self.damage + impact --sum the impact value directly to damage meter if self._last_time_collision_snd > 0.3 then @@ -426,7 +426,7 @@ minetest.register_entity("automobiles_roadster:roadster", { }) end --[[if self.damage > 100 then --if acumulated damage is greater than 100, adieu - automobiles.destroy(self) + automobiles_lib.destroy(self) end]]-- end @@ -448,7 +448,7 @@ minetest.register_entity("automobiles_roadster:roadster", { --control local steering_angle_max = 30 local steering_speed = 40 - accel, stop = automobiles.control(self, dtime, hull_direction, longit_speed, longit_drag, later_drag, accel, roadster.max_acc_factor, roadster.max_speed, steering_angle_max, steering_speed) + accel, stop = automobiles_lib.control(self, dtime, hull_direction, longit_speed, longit_drag, later_drag, accel, roadster.max_acc_factor, roadster.max_speed, steering_angle_max, steering_speed) else if self.sound_handle ~= nil then minetest.sound_stop(self.sound_handle) @@ -470,10 +470,10 @@ minetest.register_entity("automobiles_roadster:roadster", { if math.abs(self._steering_angle)>5 then local turn_rate = math.rad(40) newyaw = yaw + dtime*(1 - 1 / (math.abs(longit_speed) + 1)) * - self._steering_angle / 30 * turn_rate * automobiles.sign(longit_speed) + self._steering_angle / 30 * turn_rate * automobiles_lib.sign(longit_speed) end - automobiles.ground_get_distances(self, 0.5, 2.422) + automobiles_lib.ground_get_distances(self, 0.5, 2.422) --[[if player and is_attached then player:set_look_horizontal(newyaw) @@ -498,7 +498,7 @@ minetest.register_entity("automobiles_roadster:roadster", { ---------------------------------- if self._energy > 0 then local zero_reference = vector.new() - local acceleration = automobiles.get_hipotenuse_value(accel, zero_reference) + local acceleration = automobiles_lib.get_hipotenuse_value(accel, zero_reference) --minetest.chat_send_all(acceleration) local consumed_power = acceleration/40000 self._energy = self._energy - consumed_power; @@ -511,12 +511,12 @@ minetest.register_entity("automobiles_roadster:roadster", { roadster.engine_set_sound_and_animation(self, longit_speed) end - local energy_indicator_angle = automobiles.get_gauge_angle(self._energy) + local energy_indicator_angle = automobiles_lib.get_gauge_angle(self._energy) self.fuel_gauge:set_attach(self.object,'',ROADSTER_GAUGE_FUEL_POSITION,{x=0,y=0,z=energy_indicator_angle}) ---------------------------- -- end energy consumption -- - accel.y = -automobiles.gravity + accel.y = -automobiles_lib.gravity if stop ~= true then self.object:set_pos(curr_pos) @@ -565,9 +565,9 @@ minetest.register_entity("automobiles_roadster:roadster", { refuel works it car is stopped and engine is off ]]-- local velocity = self.object:get_velocity() - local speed = automobiles.get_hipotenuse_value(vector.new(), velocity) + local speed = automobiles_lib.get_hipotenuse_value(vector.new(), velocity) if math.abs(speed) <= 0.1 then - if automobiles.loadFuel(self, puncher:get_player_name(), false, roadster.max_fuel) then return end + if automobiles_lib.loadFuel(self, puncher:get_player_name(), false, roadster.max_fuel) then return end end -- end refuel @@ -589,7 +589,7 @@ minetest.register_entity("automobiles_roadster:roadster", { local color, indx, _ if split[1] then _,indx = split[1]:find('dye') end if indx then - for clr,_ in pairs(automobiles.colors) do + for clr,_ in pairs(automobiles_lib.colors) do local _,x = split[2]:find(clr) if x then color = clr end end @@ -601,10 +601,10 @@ minetest.register_entity("automobiles_roadster:roadster", { --lets paint!!!! --local color = item_name:sub(indx+1) - local colstr = automobiles.colors[color] + local colstr = automobiles_lib.colors[color] --minetest.chat_send_all(color ..' '.. dump(colstr)) if colstr then - automobiles.paint(self, colstr) + automobiles_lib.paint(self, colstr) itmstck:set_count(itmstck:get_count()-1) puncher:set_wielded_item(itmstck) end @@ -653,7 +653,7 @@ minetest.register_entity("automobiles_roadster:roadster", { else if name == self.owner then --is the owner, okay, lets attach - automobiles.attach_driver(self, clicker) + automobiles_lib.attach_driver(self, clicker) -- sound self.sound_handle = minetest.sound_play({name = "roadster_engine"}, {object = self.object, gain = 0.5, pitch = 0.6, max_hear_distance = 10, loop = true,}) @@ -663,13 +663,13 @@ minetest.register_entity("automobiles_roadster:roadster", { if self._passenger == nil then --there is no passenger, so lets attach if self.driver_name then - automobiles.attach_pax(self, clicker, true) + automobiles_lib.attach_pax(self, clicker, true) end else --there is a passeger if self._passenger == name then --if you are the psenger, so deattach - automobiles.dettach_pax(self, clicker) + automobiles_lib.dettach_pax(self, clicker) end end end diff --git a/automobiles_roadster/roadster_forms.lua b/automobiles_roadster/roadster_forms.lua index 5ff095b..beb5aae 100644 --- a/automobiles_roadster/roadster_forms.lua +++ b/automobiles_roadster/roadster_forms.lua @@ -40,10 +40,10 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) if ent._passenger then --any pax? local pax_obj = minetest.get_player_by_name(ent._passenger) - automobiles.dettach_pax(ent, pax_obj) + automobiles_lib.dettach_pax(ent, pax_obj) end - automobiles.dettach_driver(ent, player) + automobiles_lib.dettach_driver(ent, player) end minetest.close_formspec(name, "roadster:driver_main") end diff --git a/modpack.conf b/modpack.conf index 67e0db3..529758d 100755 --- a/modpack.conf +++ b/modpack.conf @@ -1,4 +1,4 @@ -name=automobiles +name=automobiles_pck title=Automobiles description=Collection of automobiles author = apercy