Compare commits

...

24 Commits

Author SHA1 Message Date
a10108a887 Merge remote-tracking branch 'upstream/master' 2022-06-25 16:42:56 +02:00
SmallJoker
e458734cc5 Import two my MTG commits for better driving experience
Takes the changes from MTG commit 38307da and 71ea0c6
2022-06-03 20:41:33 +02:00
f0ce2517e5 Merge remote-tracking branch 'upstream/master' 2021-08-16 18:10:04 +02:00
SmallJoker
3bd7d6f8ca Fix item pickups not working sometimes 2021-08-14 16:51:37 +02:00
30e5558096 Merge remote-tracking branch 'upstream/master' 2021-05-09 21:21:07 +02:00
SmallJoker
b05a49afb5 Fix 0/0 condition on faulty tool capabilities 2021-05-02 15:01:58 +02:00
d3a0b0e2c2 Merge remote-tracking branch 'upstream/master' into nalc-1.2-dev 2020-06-16 21:23:06 +02:00
SmallJoker
5b53183381 Descend from cart using sneak (#31) 2020-05-30 09:08:54 +02:00
sfan5
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
SmallJoker
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
SmallJoker
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
SmallJoker
cc293e95fe Fix model animations after detach, remove README.txt 2019-11-26 19:41:18 +01:00
SmallJoker
f7a649e596 Convert README to Markdown (#30)
Based on work by @Panquesito7
2019-11-20 19:22:02 +01:00
SmallJoker
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
SmallJoker
e4edb96d30 Use initial_properties, backup old_pos for loading 2018-09-01 14:49:16 +02:00
SmallJoker
3386942d71 Add basic documentation 2018-07-30 17:16:14 +02:00
SmallJoker
d486143f42 Reset acceleration at speed limit 2018-07-07 15:23:30 +02:00
SmallJoker
34155473a9 Fix controls not working when going uphill 2018-07-04 22:04:55 +02:00
SmallJoker
7e275e1985 Disallow rail switching up/downhill 2018-07-04 21:23:06 +02:00
SmallJoker
c6b9e4b672 Various improvements and bugfixes
Clear driver on leave using the detach callback (0.5.x and later)
Fix upright_sprite attachment position
Fallback to the regular node sound when metal does not exist
Set animation to "stand" on attach
2018-05-12 11:36:00 +02:00
SmallJoker
3781f6d4c0 Make moreores' copper rail connect again, add metal sounds 2018-05-04 14:38:52 +02:00
SmallJoker
f4c1a2ec3b Fix edge case crash due nil old_pos, remove player_api warning 2018-01-15 18:41:40 +01:00
SmallJoker
57d09fac79 Revert velocity calculation change from e3688b5
Accelerates carts too much when going up/downhill
Caused by wrong vector length calculation. This will need to be altered again if there will be 45° rails
2017-11-28 18:33:37 +01:00
11 changed files with 278 additions and 179 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*.bak
*.diff
*.patch

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)
-- Play rail sound
if entity.sound_counter <= 0 then
@ -13,18 +11,20 @@ function boost_cart:on_rail_step(entity, pos, distance)
end
entity.sound_counter = entity.sound_counter - distance
if HAVE_MESECONS_ENABLED then
if boost_cart.MESECONS then
boost_cart:signal_detector_rail(pos)
end
end
local cart_entity = {
physical = false,
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
visual = "mesh",
mesh = "cart.x",
visual_size = {x=1, y=1},
textures = {"cart.png"},
initial_properties = {
physical = false,
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
visual = "mesh",
mesh = "cart.x",
visual_size = {x=1, y=1},
textures = {"cart.png"},
},
driver = nil,
punched = false, -- used to re-send velocity and position
@ -38,9 +38,9 @@ local cart_entity = {
}
-- Model and textures
if boost_cart.mtg_compat then
cart_entity.mesh = "carts_cart.b3d"
cart_entity.textures = {"carts_cart.png"}
if boost_cart.MTG_CARTS then
cart_entity.initial_properties.mesh = "carts_cart.b3d"
cart_entity.initial_properties.textures = {"carts_cart.png"}
end
function cart_entity:on_rightclick(clicker)
@ -49,11 +49,10 @@ function cart_entity:on_rightclick(clicker)
end
local player_name = clicker:get_player_name()
if self.driver and player_name == self.driver then
self.driver = nil
boost_cart:manage_attachment(clicker, nil)
elseif not self.driver then
self.driver = player_name
boost_cart:manage_attachment(clicker, self.object)
self.driver = player_name
end
end
@ -69,18 +68,30 @@ function cart_entity:on_activate(staticdata, dtime_s)
return
end
self.railtype = data.railtype
if data.old_dir then
self.old_dir = data.old_dir
self.old_dir = data.old_dir or self.old_dir
self.old_pos = data.old_pos or self.old_pos
-- Correct the position when the cart drives further after the last 'step()'
if self.old_pos and boost_cart:is_rail(self.old_pos, self.railtype) then
self.object:set_pos(self.old_pos)
end
end
function cart_entity:get_staticdata()
return minetest.serialize({
railtype = self.railtype,
old_dir = self.old_dir
old_dir = self.old_dir,
old_pos = self.old_pos
})
end
-- 0.5.x and later: When the driver leaves
function cart_entity:on_detach_child(child)
if child and child:get_player_name() == self.driver then
boost_cart:manage_attachment(child, nil)
self.driver = nil
end
end
function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction)
local pos = self.object:get_pos()
local vel = self.object:get_velocity()
@ -109,8 +120,13 @@ function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities,
boost_cart:manage_attachment(player, nil)
end
for _, obj_ in pairs(self.attached_items) do
if obj_ then
local ent = obj_ and obj_:get_luaentity()
if ent then
obj_:set_detach()
-- Attention! Internal item API
if ent.enable_physics then
ent:enable_physics()
end
end
end
@ -138,7 +154,8 @@ function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities,
end
local punch_interval = 1
if tool_capabilities and tool_capabilities.full_punch_interval then
-- Faulty tool registrations may cause the interval to be set to 0 !
if tool_capabilities and (tool_capabilities.full_punch_interval or 0) > 0 then
punch_interval = tool_capabilities.full_punch_interval
end
time_from_last_punch = math.min(time_from_last_punch or punch_interval, punch_interval)
@ -161,11 +178,11 @@ function cart_entity:on_step(dtime)
end
local pos = self.object:get_pos()
local cart_dir = boost_cart:velocity_to_dir(vel)
local same_dir = vector.equals(cart_dir, self.old_dir)
local dir = boost_cart:velocity_to_dir(vel)
local dir_changed = not vector.equals(dir, self.old_dir)
local update = {}
if self.old_pos and not self.punched and same_dir then
if self.old_pos and not self.punched and not dir_changed then
local flo_pos = vector.round(pos)
local flo_old = vector.round(self.old_pos)
if vector.equals(flo_pos, flo_old) then
@ -186,7 +203,7 @@ function cart_entity:on_step(dtime)
end
local stop_wiggle = false
if self.old_pos and same_dir then
if self.old_pos and not dir_changed then
-- Detection for "skipping" nodes (perhaps use average dtime?)
-- It's sophisticated enough to take the acceleration in account
local acc = self.object:get_acceleration()
@ -201,7 +218,7 @@ function cart_entity:on_step(dtime)
-- No rail found: set to the expected position
pos = new_pos
update.pos = true
cart_dir = new_dir
dir = new_dir
end
elseif self.old_pos and self.old_dir.y ~= 1 and not self.punched then
-- Stop wiggle
@ -211,19 +228,25 @@ function cart_entity:on_step(dtime)
-- dir: New moving direction of the cart
-- switch_keys: Currently pressed L(1) or R(2) key,
-- used to ignore the key on the next rail node
local dir, switch_keys = boost_cart:get_rail_direction(
pos, cart_dir, ctrl, self.old_switch, self.railtype
local switch_keys
dir, switch_keys = boost_cart:get_rail_direction(
pos, dir, ctrl, self.old_switch, self.railtype
)
local dir_changed = not vector.equals(dir, self.old_dir)
dir_changed = not vector.equals(dir, self.old_dir)
local new_acc = {x=0, y=0, z=0}
local acc = 0
if stop_wiggle or vector.equals(dir, {x=0, y=0, z=0}) then
dir = vector.new(self.old_dir)
vel = {x=0, y=0, z=0}
local pos_r = vector.round(pos)
if not boost_cart:is_rail(pos_r, self.railtype) then
if not boost_cart:is_rail(pos_r, self.railtype)
and self.old_pos then
pos = self.old_pos
elseif not stop_wiggle then
-- End of rail: Smooth out.
pos = pos_r
dir_changed = false
dir.y = 0
else
pos.y = math.floor(pos.y + 0.5)
end
@ -232,7 +255,7 @@ function cart_entity:on_step(dtime)
else
-- Direction change detected
if dir_changed then
vel = vector.multiply(dir, v3_len(vel))
vel = vector.multiply(dir, math.abs(vel.x + vel.z))
update.vel = true
if dir.y ~= self.old_dir.y then
pos = vector.round(pos)
@ -250,7 +273,7 @@ function cart_entity:on_step(dtime)
end
-- Calculate current cart acceleration
local acc = nil
acc = nil
local acc_meta = minetest.get_meta(pos):get_string("cart_acceleration")
if acc_meta == "halt" and not self.punched then
@ -269,7 +292,7 @@ function cart_entity:on_step(dtime)
acc = speed_mod * 10
end
end
if acc == nil and boost_cart.mtg_compat then
if acc == nil and boost_cart.MTG_CARTS then
-- MTG Cart API adaption
local rail_node = minetest.get_node(vector.round(pos))
local railparam = carts.railparams[rail_node.name]
@ -285,36 +308,36 @@ function cart_entity:on_step(dtime)
acc = -0.4
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
-- Slow down or speed up, depending on Y direction
acc = acc + dir.y * -2.1
acc = acc + dir.y * -4
else
acc = 0
end
new_acc = vector.multiply(dir, acc)
end
-- Limits
local max_vel = boost_cart.speed_max
for _,v in pairs({"x","y","z"}) do
if math.abs(vel[v]) > max_vel then
vel[v] = boost_cart:get_sign(vel[v]) * max_vel
new_acc[v] = 0
update.vel = true
end
-- Limit cart speed
local vel_len = vector.length(vel)
if vel_len > boost_cart.speed_max then
vel = vector.multiply(vel, boost_cart.speed_max / vel_len)
update.vel = true
end
if vel_len >= boost_cart.speed_max and acc > 0 then
acc = 0
end
self.object:set_acceleration(new_acc)
self.object:set_acceleration(vector.multiply(dir, acc))
self.old_pos = vector.round(pos)
local old_y_dir = self.old_dir.y
if not vector.equals(dir, {x=0, y=0, z=0}) and not stop_wiggle then
self.old_dir = dir
else
-- Cart stopped, set the animation to 0
self.old_dir.y = 0
end
local old_y_dir = self.old_dir.y -- For player tilt
self.old_dir = vector.new(dir)
self.old_switch = switch_keys
boost_cart:on_rail_step(self, self.old_pos, distance)
@ -322,10 +345,13 @@ function cart_entity:on_step(dtime)
if self.punched then
-- Collect dropped items
for _, obj_ in pairs(minetest.get_objects_inside_radius(pos, 1)) do
if not obj_:is_player() and
obj_:get_luaentity() and
not obj_:get_luaentity().physical_state and
obj_:get_luaentity().name == "__builtin:item" then
local ent = obj_:get_luaentity()
-- Attention! Physics must be disabled prior to attach
if ent and ent.name == "__builtin:item" and not obj_:get_attach() 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})
self.attached_items[#self.attached_items + 1] = obj_
@ -338,8 +364,6 @@ function cart_entity:on_step(dtime)
if not (update.vel or update.pos) then
return
end
-- Re-use "dir", localize self.old_dir
dir = self.old_dir
local yaw = 0
if dir.x < 0 then
@ -361,18 +385,14 @@ function cart_entity:on_step(dtime)
-- Change player model rotation, depending on the Y direction
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}
feet.y = boost_cart.old_player_model and 6 or -4
if dir.y ~= 0 then
-- TODO: Find a better way to calculate this
if boost_cart.old_player_model then
feet.y = feet.y + 2
feet.z = -dir.y * 6
else
feet.y = feet.y + 4
feet.z = -dir.y * 2
end
feet.y = feet.y + 4
feet.z = -dir.y * 2
eye.z = -dir.y * 8
end
player:set_attach(self.object, "", feet,
@ -395,7 +415,7 @@ end
minetest.register_entity(":carts:cart", cart_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", {
description = "Cart (Sneak+Click to pick up)",
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.

71
doc/mod_api.txt Normal file
View File

@ -0,0 +1,71 @@
boost_cart API
==============
This file provides information about the API of boost_cart for the use in
mods. The API might change slightly when the development goes on, so avoid
using internal tables or functions which are not documented here.
Types
-----
* `SwitchIgnore` -> `number/nil`
* Specifies which player control was pressed. This value is used to prefer
straight rails instead of preferring left and right rail checks.
* `1`: Ignore left rail
* `2`: Ignore right rail
* `nil`: Ignore no rail
Entity movement
---------------
These functions are grouped so that they make sense and then sorted alphabetically.
* `boost_cart:manage_attachment(player, obj)`
* Attaches or detaches the player to/from an object, depending on what is
supplied to `obj`.
* `player`: `ObjectRef` of the player
* `obj`: `ObjectRef` (to attach) or `nil` (to detach)
* `boost_cart:get_sign(n)` -> `number`
* Returns the sign for the given number. Values: `-1`, `0`, `1`
* `n`: any `number`
* `boost_cart:velocity_to_dir(vel)` -> `vector`
* Returns the cart direction depending on `vel`. Each coordinate can have
one of the `get_sign()` return values.
* `vel`: velocity as `vector`
* `boost_cart:boost_rail(pos, amount)`
* Sets the rail acceleration for the given position to `amount` and punches
carts which are at the given position.
* `pos`: `vector`, rail position
* `amount`: `number`, negative to brake, positive to boost
* `boost_cart:get_rail_direction(pos, dir, ctrl, old_switch, railtype)`
-> `vector, SwitchIgnore`
* Returns the direction to where the next rail is, and which player control that
should be ignored in the next call.
* `pos`: `vector`, position of the cart
* `dir`: `vector`, movement direction of the cart (see `velocity_to_dir()`)
* `ctrl`: Player controls table or `nil` (no player)
* `old_switch`: `SwitchIgnore`
* `railtype`: (optional) `number`, gets passed indirectly to `is_rail()`
Rail helper functions
---------------------
* `boost_cart:get_rail_groups(groups)` -> `table`
* Returns a group table with preset values for a common rail node
* `groups`: (optional) `table`, additional groups append (or overwrite)
* Hint: To register an incompatible rail type, set the group
`connect_to_raillike` to the value returned by
`minetest.raillike_group(new_rail_type)`
* `boost_cart:is_rail(pos, [railtype])` -> `boolean`
* Returns whether the node at `pos` is a rail. When `railtype` is specified,
`true` is only returned when the node is in the same rail group.
* `pos`: `vector` of the node to check
* `railtype`: (optional) `number`, rail group number
* `boost_cart:register_rail(name, def)`
* Registers a new rail with preset node definition defaults as fallback
* `name`: `string`, node name of the new rail
* `def`: Node definition table, containing at least the following keys:
* `description`
* `groups`
* `tiles`

View File

@ -10,17 +10,26 @@ function boost_cart:manage_attachment(player, obj)
if not player then
return
end
local status = obj ~= nil
local player_name = player:get_player_name()
if default.player_attached[player_name] == status then
local do_attach = obj ~= nil
if obj and player:get_attach() == obj then
return
end
default.player_attached[player_name] = status
if status then
local y_pos = self.old_player_model and 6 or -4
player:set_attach(obj, "", {x=0, y=y_pos, z=0}, {x=0, y=0, z=0})
if boost_cart.PLAYER_API then
local player_name = player:get_player_name()
player_api.player_attached[player_name] = do_attach
end
if do_attach then
player:set_attach(obj, "", {x=0, y=-4, z=0}, {x=0, y=0, z=0})
player:set_eye_offset({x=0, y=-4, z=0},{x=0, y=-4, z=0})
if boost_cart.PLAYER_API then
-- player_api does not update the animation
-- when the player is attached, reset to default animation
player_api.set_animation(player, "stand")
end
else
player:set_detach()
player:set_eye_offset({x=0, y=0, z=0},{x=0, y=0, z=0})
@ -104,6 +113,16 @@ function boost_cart:get_rail_direction(pos_, dir, ctrl, old_switch, railtype)
right.z = -dir.x
end
local straight_priority = ctrl and dir.y ~= 0
-- Normal, to disallow rail switching up- & downhill
if straight_priority then
cur = self:check_front_up_down(pos, dir, true, railtype)
if cur then
return cur
end
end
if ctrl then
if old_switch == 1 then
left_check = false
@ -127,9 +146,11 @@ function boost_cart:get_rail_direction(pos_, dir, ctrl, old_switch, railtype)
end
-- Normal
cur = self:check_front_up_down(pos, dir, true, railtype)
if cur then
return cur
if not straight_priority then
cur = self:check_front_up_down(pos, dir, true, railtype)
if cur then
return cur
end
end
-- Left, if not already checked
@ -208,6 +229,9 @@ function boost_cart:boost_rail(pos, amount)
end
function boost_cart:register_rail(name, def_overwrite)
local sound_func = default.node_sound_metal_defaults
or default.node_sound_defaults
local def = {
drawtype = "raillike",
paramtype = "light",
@ -217,7 +241,8 @@ function boost_cart:register_rail(name, def_overwrite)
selection_box = {
type = "fixed",
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
}
},
sounds = sound_func()
}
for k, v in pairs(def_overwrite) do
def[k] = v

View File

@ -1,12 +1,14 @@
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.modpath = minetest.get_modpath("boost_cart")
if not minetest.settings then
error("[boost_cart] Your Minetest version is no longer supported."
.. " (Version <= 0.4.15)")
end
boost_cart.MESECONS = minetest.global_exists("mesecon")
boost_cart.MTG_CARTS = minetest.global_exists("carts") and carts.pathfinder
boost_cart.PLAYER_API = minetest.global_exists("player_api")
local function getNum(setting)
return tonumber(minetest.settings:get(setting))
@ -17,30 +19,20 @@ boost_cart.speed_max = getNum("boost_cart.speed_max") or 10
-- Set to -1 to disable punching the cart from inside
boost_cart.punch_speed_max = getNum("boost_cart.punch_speed_max") or 7
-- Maximal distance for the path correction (for dtime peaks)
boost_cart.path_distance_max = 3
boost_cart.path_distance_max = 4
-- Support for non-default games
if not default.player_attached then
default.player_attached = {}
end
minetest.after(1, function()
boost_cart.old_player_model = type(player_api) ~= "table"
end)
dofile(boost_cart.modpath.."/functions.lua")
dofile(boost_cart.modpath.."/rails.lua")
if minetest.global_exists("mesecon") then
if boost_cart.MESECONS then
dofile(boost_cart.modpath.."/detector.lua")
--else
-- minetest.register_alias("carts:powerrail", "boost_cart:detectorrail")
-- minetest.register_alias("carts:powerrail", "boost_cart:detectorrail_on")
end
boost_cart.mtg_compat = minetest.global_exists("carts") and carts.pathfinder
if boost_cart.mtg_compat then
if boost_cart.MTG_CARTS then
minetest.log("action", "[boost_cart] Overwriting definitions of similar carts mod")
end
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,9 +16,21 @@ boost_cart:register_rail(":"..regular_rail_itemname, {
})
-- Moreores' copper rail
local copperrail_registered = false
if minetest.get_modpath("moreores") then
minetest.register_alias("carts:copperrail", "moreores:copper_rail")
else
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
raildef.groups.connect_to_raillike = minetest.raillike_group("rail")
minetest.override_item("moreores:copper_rail", {
groups = raildef.groups
})
copperrail_registered = true
end
end
if not copperrail_registered then
boost_cart:register_rail(":carts:copperrail", {
description = "Copper rail",
tiles = {
@ -63,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
boost_cart:register_rail(":carts:brakerail", {
description = "Brake rail",
@ -97,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", {
description = "Start-stop rail",
tiles = {