Compare commits

...

9 Commits

Author SHA1 Message Date
d3a0b0e2c2 Merge remote-tracking branch 'upstream/master' into nalc-1.2-dev 2020-06-16 21:23:06 +02:00
5b53183381 Descend from cart using sneak (#31) 2020-05-30 09:08:54 +02:00
56f5b18dae Fix item collection
Broken since 5.3.0-dev

Co-authored-by: SmallJoker <mk939@ymail.com>
2020-05-29 19:14:16 +02:00
c8f7cae2c8 Set driver to nil (like before)
The driver variable is not handled by boost_cart:manage_attachment
2020-05-16 19:13:26 +02:00
30f870e88c Reset player view and attachment table on death 2020-05-15 19:02:38 +02:00
d29700143e Supprime les redéfinitions de certains crafts
powerrail et brakerail
2020-01-04 18:55:33 +01:00
cc293e95fe Fix model animations after detach, remove README.txt 2019-11-26 19:41:18 +01:00
f7a649e596 Convert README to Markdown (#30)
Based on work by @Panquesito7
2019-11-20 19:22:02 +01:00
ae33bd7a68 Bump to 5.0.0 and fix the copper rail
moreores only adds the copper rail when the 'carts' mod was found
2019-10-18 10:09:29 +02:00
9 changed files with 111 additions and 131 deletions

50
README.md Normal file
View File

@ -0,0 +1,50 @@
# Boost Cart
Based on (and fully compatible with) the mod "carts" by PilzAdam
and the one contained in the subgame "minetest_game".
Target: Run smoothly as possible, even on laggy servers.
## Features
- A fast cart for your railway or roller coaster
- Easily configurable cart speed using the Advanced Settings
- Boost and brake rails
- By mesecons controlled Start-Stop rails
- Detector rails that send a mesecons signal when the cart drives over them
- Rail junction switching with the 'right/left' walking keys
- Handbrake with the 'back' key
- Support for non-minetest_game subgames
- Descend from cart using the `sneak` key
## Settings
This mod can be adjusted to fit the preference of a player or server. Use the `Settings -> All Settings` dialog in the main menu or tune your
minetest.conf file manually:
#### `boost_cart.speed_max = 10`
* Maximal speed of the cart in m/s
* Possible values: 1 ... 100
#### `boost_cart.punch_speed_max = 7`
* Maximal speed to which the driving player can accelerate the cart by punching from inside the cart.
* Possible values: -1 ... 100
* Value `-1` will disable this feature.
## License for everything
CC-0, if not specified otherwise below
Authors
---------
Various authors
- carts_rail_*.png
kddekadenz
- cart_bottom.png
- cart_side.png
- cart_top.png
klankbeeld (CC-BY 3.0)
- http://freesound.org/people/klankbeeld/sounds/174042/
- cart_rail.*.ogg
Zeg9
- cart.x
- cart.png

View File

@ -1,57 +0,0 @@
Minetest mod: boost_cart
==========================
Based on (and fully compatible with) the mod "carts" by PilzAdam
and the one contained in the subgame "minetest_game".
Target: Run smoothly as possible, even on laggy servers.
Features
----------
- A fast cart for your railway or roller coaster
- Easily configurable cart speed using the Advanced Settings
- Boost and brake rails
- By mesecons controlled Start-Stop rails
- Detector rails that send a mesecons signal when the cart drives over them
- Rail junction switching with the 'right/left' walking keys
- Handbrake with the 'back' key
- Support for non-minetest_game subgames
Settings
----------
This mod can be adjusted to fit the conditions of a player or server.
Use the Advanced Settings dialog in the main menu or tune your
minetest.conf file manually:
boost_cart.speed_max = 10
^ Possible values: 1 ... 100
^ Maximal speed of the cart in m/s
boost_cart.punch_speed_max = 7
^ Possible values: -1 ... 100
^ Maximal speed to which the driving player can accelerate the cart
by punching from inside the cart. -1 will disable this feature.
License for everything
------------------------
CC-0, if not specified otherwise below
Authors
---------
Various authors
carts_rail_*.png
kddekadenz
cart_bottom.png
cart_side.png
cart_top.png
klankbeeld (CC-BY 3.0)
http://freesound.org/people/klankbeeld/sounds/174042/
cart_rail.*.ogg
Zeg9
cart.x
cart.png

View File

@ -1,6 +1,4 @@
local HAVE_MESECONS_ENABLED = minetest.global_exists("mesecon")
function boost_cart:on_rail_step(entity, pos, distance) function boost_cart:on_rail_step(entity, pos, distance)
-- Play rail sound -- Play rail sound
if entity.sound_counter <= 0 then if entity.sound_counter <= 0 then
@ -13,7 +11,7 @@ function boost_cart:on_rail_step(entity, pos, distance)
end end
entity.sound_counter = entity.sound_counter - distance entity.sound_counter = entity.sound_counter - distance
if HAVE_MESECONS_ENABLED then if boost_cart.MESECONS then
boost_cart:signal_detector_rail(pos) boost_cart:signal_detector_rail(pos)
end end
end end
@ -40,7 +38,7 @@ local cart_entity = {
} }
-- Model and textures -- Model and textures
if boost_cart.mtg_compat then if boost_cart.MTG_CARTS then
cart_entity.initial_properties.mesh = "carts_cart.b3d" cart_entity.initial_properties.mesh = "carts_cart.b3d"
cart_entity.initial_properties.textures = {"carts_cart.png"} cart_entity.initial_properties.textures = {"carts_cart.png"}
end end
@ -97,6 +95,7 @@ end
function cart_entity:on_detach_child(child) function cart_entity:on_detach_child(child)
if child and child:get_player_name() == self.driver then if child and child:get_player_name() == self.driver then
self.driver = nil self.driver = nil
boost_cart:manage_attachment(child, nil)
end end
end end
@ -289,7 +288,7 @@ function cart_entity:on_step(dtime)
acc = speed_mod * 10 acc = speed_mod * 10
end end
end end
if acc == nil and boost_cart.mtg_compat then if acc == nil and boost_cart.MTG_CARTS then
-- MTG Cart API adaption -- MTG Cart API adaption
local rail_node = minetest.get_node(vector.round(pos)) local rail_node = minetest.get_node(vector.round(pos))
local railparam = carts.railparams[rail_node.name] local railparam = carts.railparams[rail_node.name]
@ -305,6 +304,12 @@ function cart_entity:on_step(dtime)
acc = -0.4 acc = -0.4
end end
end end
if ctrl and ctrl.sneak then
-- Descend when sneak is pressed
boost_cart:manage_attachment(player, nil)
player = nil
ctrl = nil
end
if acc then if acc then
-- Slow down or speed up, depending on Y direction -- Slow down or speed up, depending on Y direction
@ -341,10 +346,13 @@ function cart_entity:on_step(dtime)
if self.punched then if self.punched then
-- Collect dropped items -- Collect dropped items
for _, obj_ in pairs(minetest.get_objects_inside_radius(pos, 1)) do for _, obj_ in pairs(minetest.get_objects_inside_radius(pos, 1)) do
if not obj_:is_player() and local ent = obj_:get_luaentity()
obj_:get_luaentity() and -- Careful here: physical_state and disable_physics are item-internal APIs
not obj_:get_luaentity().physical_state and if ent and ent.name == "__builtin:item" and ent.physical_state then
obj_:get_luaentity().name == "__builtin:item" then -- Check API to support 5.2.0 and older
if ent.disable_physics then
ent:disable_physics()
end
obj_:set_attach(self.object, "", {x=0, y=0, z=0}, {x=0, y=0, z=0}) obj_:set_attach(self.object, "", {x=0, y=0, z=0}, {x=0, y=0, z=0})
self.attached_items[#self.attached_items + 1] = obj_ self.attached_items[#self.attached_items + 1] = obj_
@ -380,18 +388,14 @@ function cart_entity:on_step(dtime)
-- Change player model rotation, depending on the Y direction -- Change player model rotation, depending on the Y direction
if player and dir.y ~= old_y_dir then if player and dir.y ~= old_y_dir then
local feet = {x=0, y=0, z=0} local feet = {x=0, y=-4, z=0}
local eye = {x=0, y=-4, z=0} local eye = {x=0, y=-4, z=0}
feet.y = boost_cart.old_player_model and 6 or -4
if dir.y ~= 0 then if dir.y ~= 0 then
-- TODO: Find a better way to calculate this -- TODO: Find a better way to calculate this
if boost_cart.old_player_model then feet.y = feet.y + 4
feet.y = feet.y + 2 feet.z = -dir.y * 2
feet.z = -dir.y * 6
else
feet.y = feet.y + 4
feet.z = -dir.y * 2
end
eye.z = -dir.y * 8 eye.z = -dir.y * 8
end end
player:set_attach(self.object, "", feet, player:set_attach(self.object, "", feet,
@ -414,7 +418,7 @@ end
minetest.register_entity(":carts:cart", cart_entity) minetest.register_entity(":carts:cart", cart_entity)
-- Register item to place the entity -- Register item to place the entity
if not boost_cart.mtg_compat then if not boost_cart.MTG_CARTS then
minetest.register_craftitem(":carts:cart", { minetest.register_craftitem(":carts:cart", {
description = "Cart (Sneak+Click to pick up)", description = "Cart (Sneak+Click to pick up)",
inventory_image = minetest.inventorycube( inventory_image = minetest.inventorycube(

View File

@ -1,4 +0,0 @@
default
mesecons?
moreores?
carts?

View File

@ -1 +0,0 @@
This mod offers improved minecarts and a few more rail types.

View File

@ -10,19 +10,18 @@ function boost_cart:manage_attachment(player, obj)
if not player then if not player then
return return
end end
local status = obj ~= nil local wants_attach = obj ~= nil
local player_name = player:get_player_name() local attached = player:get_attach() ~= nil
if default.player_attached[player_name] == status then
if attached == wants_attach then
return return
end end
default.player_attached[player_name] = status
if status then local player_name = player:get_player_name()
local y_pos = self.old_player_model and 6 or -4 boost_cart.player_attached[player_name] = wants_attach
if player:get_properties().visual == "upright_sprite" then
y_pos = -4 if wants_attach then
end player:set_attach(obj, "", {x=0, y=-4, z=0}, {x=0, y=0, z=0})
player:set_attach(obj, "", {x=0, y=y_pos, z=0}, {x=0, y=0, z=0})
player:set_eye_offset({x=0, y=-4, z=0},{x=0, y=-4, z=0}) player:set_eye_offset({x=0, y=-4, z=0},{x=0, y=-4, z=0})
else else
player:set_detach() player:set_detach()

View File

@ -1,12 +1,15 @@
if not minetest.features.object_use_texture_alpha then
error("[boost_cart] Your Minetest version is no longer supported."
.. " (Version < 5.0.0)")
end
boost_cart = {} boost_cart = {}
boost_cart.modpath = minetest.get_modpath("boost_cart") boost_cart.modpath = minetest.get_modpath("boost_cart")
boost_cart.MESECONS = minetest.global_exists("mesecon")
boost_cart.MTG_CARTS = minetest.global_exists("carts") and carts.pathfinder
if not minetest.settings then boost_cart.PLAYER_API = minetest.global_exists("player_api")
error("[boost_cart] Your Minetest version is no longer supported." boost_cart.player_attached = {}
.. " (Version <= 0.4.15)")
end
local function getNum(setting) local function getNum(setting)
return tonumber(minetest.settings:get(setting)) return tonumber(minetest.settings:get(setting))
@ -20,27 +23,22 @@ boost_cart.punch_speed_max = getNum("boost_cart.punch_speed_max") or 7
boost_cart.path_distance_max = 3 boost_cart.path_distance_max = 3
-- Support for non-default games if boost_cart.PLAYER_API then
if not default.player_attached then -- This is a table reference!
default.player_attached = {} boost_cart.player_attached = player_api.player_attached
end end
minetest.after(0, function()
boost_cart.old_player_model = not minetest.global_exists("player_api")
end)
dofile(boost_cart.modpath.."/functions.lua") dofile(boost_cart.modpath.."/functions.lua")
dofile(boost_cart.modpath.."/rails.lua") dofile(boost_cart.modpath.."/rails.lua")
if minetest.global_exists("mesecon") then if boost_cart.MESECONS then
dofile(boost_cart.modpath.."/detector.lua") dofile(boost_cart.modpath.."/detector.lua")
--else --else
-- minetest.register_alias("carts:powerrail", "boost_cart:detectorrail") -- minetest.register_alias("carts:powerrail", "boost_cart:detectorrail")
-- minetest.register_alias("carts:powerrail", "boost_cart:detectorrail_on") -- minetest.register_alias("carts:powerrail", "boost_cart:detectorrail_on")
end end
boost_cart.mtg_compat = minetest.global_exists("carts") and carts.pathfinder if boost_cart.MTG_CARTS then
if boost_cart.mtg_compat then
minetest.log("action", "[boost_cart] Overwriting definitions of similar carts mod") minetest.log("action", "[boost_cart] Overwriting definitions of similar carts mod")
end end
dofile(boost_cart.modpath.."/cart_entity.lua") dofile(boost_cart.modpath.."/cart_entity.lua")

View File

@ -1 +1,7 @@
name = boost_cart name = boost_cart
description = """
Boost Cart
The mod that add a cart and new kinds of rails to your world.
"""
depends = default
optional_depends = mesecons, moreores, carts, player_api

View File

@ -16,18 +16,21 @@ boost_cart:register_rail(":"..regular_rail_itemname, {
}) })
-- Moreores' copper rail -- Moreores' copper rail
local copperrail_registered = false
if minetest.get_modpath("moreores") then if minetest.get_modpath("moreores") then
minetest.register_alias("carts:copperrail", "moreores:copper_rail") minetest.register_alias("carts:copperrail", "moreores:copper_rail")
if minetest.raillike_group then local raildef = minetest.registered_nodes["moreores:copper_rail"]
if raildef and minetest.raillike_group then
-- Ensure that this rail uses the same connect_to_raillike -- Ensure that this rail uses the same connect_to_raillike
local new_groups = minetest.registered_nodes["moreores:copper_rail"].groups raildef.groups.connect_to_raillike = minetest.raillike_group("rail")
new_groups.connect_to_raillike = minetest.raillike_group("rail")
minetest.override_item("moreores:copper_rail", { minetest.override_item("moreores:copper_rail", {
groups = new_groups groups = raildef.groups
}) })
copperrail_registered = true
end end
else end
if not copperrail_registered then
boost_cart:register_rail(":carts:copperrail", { boost_cart:register_rail(":carts:copperrail", {
description = "Copper rail", description = "Copper rail",
tiles = { tiles = {
@ -72,15 +75,6 @@ boost_cart:register_rail(":carts:powerrail", {
}, },
}) })
minetest.register_craft({
output = "carts:powerrail 6",
recipe = {
{"default:steel_ingot", "default:mese_crystal_fragment", "default:steel_ingot"},
{"default:steel_ingot", "group:stick", "default:steel_ingot"},
{"default:steel_ingot", "default:mese_crystal_fragment", "default:steel_ingot"},
}
})
-- Brake rail -- Brake rail
boost_cart:register_rail(":carts:brakerail", { boost_cart:register_rail(":carts:brakerail", {
description = "Brake rail", description = "Brake rail",
@ -106,15 +100,6 @@ boost_cart:register_rail(":carts:brakerail", {
}, },
}) })
minetest.register_craft({
output = "carts:brakerail 6",
recipe = {
{"default:steel_ingot", "default:coal_lump", "default:steel_ingot"},
{"default:steel_ingot", "group:stick", "default:steel_ingot"},
{"default:steel_ingot", "default:coal_lump", "default:steel_ingot"},
}
})
boost_cart:register_rail("boost_cart:startstoprail", { boost_cart:register_rail("boost_cart:startstoprail", {
description = "Start-stop rail", description = "Start-stop rail",
tiles = { tiles = {