Update carts mod

master
MoNTE48 2019-06-26 01:06:44 +02:00
parent f8ef223e83
commit 6f4253471d
50 changed files with 169 additions and 203 deletions

View File

@ -1,41 +0,0 @@
boost_cart = {}
boost_cart.modpath = minetest.get_modpath("boost_cart")
local function getNum(setting)
return tonumber(minetest.settings:get(setting))
end
-- Maximal speed of the cart in m/s
boost_cart.speed_max = getNum("boost_cart.speed_max") or 12
-- Set to -1 to disable punching the cart from inside
boost_cart.punch_speed_max = getNum("boost_cart.punch_speed_max") or 8
-- Maximal distance for the path correction (for dtime peaks)
boost_cart.path_distance_max = 3
-- Support for non-default games
if not default.player_attached then
default.player_attached = {}
end
dofile(boost_cart.modpath.."/functions.lua")
dofile(boost_cart.modpath.."/rails.lua")
if minetest.global_exists("mesecon") 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
dofile(boost_cart.modpath.."/cart_entity.lua")
-- Aliases
minetest.register_alias("railcart:cart", "carts:cart")
minetest.register_alias("railcart:cart_entity", "carts:cart")
minetest.register_alias("default:rail", "boost_cart:rail")
minetest.register_alias("railtrack:powerrail", "carts:powerrail")
minetest.register_alias("railtrack:superrail", "carts:powerrail")
minetest.register_alias("railtrack:brakerail", "carts:brakerail")
minetest.register_alias("railtrack:switchrail", "boost_cart:startstoprail")
minetest.register_alias("railtrack:fixer", "default:stick")
minetest.register_alias("railtrack:inspector", "default:stick")

View File

@ -1 +0,0 @@
name = boost_cart

View File

@ -1,4 +1,4 @@
Minetest mod: boost_cart
MultiCraft Game mod: carts
==========================
Based on (and fully compatible with) the mod "carts" by PilzAdam
and the one contained in the subgame "minetest_game".
@ -48,9 +48,6 @@ license).
Authors
---------
Various authors
carts_rail_*.png
klankbeeld (CC-BY 3.0)
http://freesound.org/people/klankbeeld/sounds/174042/

View File

@ -1,23 +1,3 @@
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
minetest.sound_play("cart_rail", {
pos = pos,
max_hear_distance = 40,
gain = 0.5
})
entity.sound_counter = math.random(4, 15)
end
entity.sound_counter = entity.sound_counter - distance
if HAVE_MESECONS_ENABLED then
--boost_cart:signal_detector_rail(pos)
end
end
local cart_entity = {
initial_properties = {
physical = false,
@ -34,7 +14,6 @@ local cart_entity = {
old_dir = {x=1, y=0, z=0}, -- random value to start the cart on punch
old_pos = nil,
old_switch = 0,
sound_counter = 0,
railtype = nil,
attached_items = {}
}
@ -46,23 +25,19 @@ function cart_entity:on_rightclick(clicker)
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)
carts:manage_attachment(clicker, nil)
elseif not self.driver then
self.driver = player_name
boost_cart:manage_attachment(clicker, self.object)
carts:manage_attachment(clicker, self.object)
if default.player_set_animation then
-- player_api(/default) does not update the animation
-- player_api does not update the animation
-- when the player is attached, reset to default animation
default.player_set_animation(clicker, "stand")
end
player_api.set_animation(clicker, "stand")
end
end
function cart_entity:on_activate(staticdata, dtime_s)
self.object:set_armor_groups({immortal=1})
self.sound_counter = math.random(4, 15)
if string.sub(staticdata, 1, string.len("return")) ~= "return" then
return
end
@ -74,7 +49,7 @@ function cart_entity:on_activate(staticdata, dtime_s)
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
if self.old_pos and carts:is_rail(self.old_pos, self.railtype) then
self.object:set_pos(self.old_pos)
end
end
@ -101,9 +76,9 @@ function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities,
local node = minetest.get_node(pos).name
self.railtype = minetest.get_item_group(node, "connect_to_raillike")
end
-- Punched by non-player
if not puncher or not puncher:is_player() then
local cart_dir = boost_cart:get_rail_direction(pos, self.old_dir, nil, nil, self.railtype)
local cart_dir = carts:get_rail_direction(pos, self.old_dir, nil, nil, self.railtype)
if vector.equals(cart_dir, {x=0, y=0, z=0}) then
return
end
@ -111,41 +86,48 @@ function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities,
self.punched = true
return
end
-- Player digs cart by sneak-punch
if puncher:get_player_control().sneak then
-- Pick up cart: Drop all attachments
if self.sound_handle then
minetest.sound_stop(self.sound_handle)
end
-- Detach driver and items
if self.driver then
if self.old_pos then
self.object:set_pos(self.old_pos)
end
local player = minetest.get_player_by_name(self.driver)
boost_cart:manage_attachment(player, nil)
carts:manage_attachment(player, nil)
end
for _, obj_ in pairs(self.attached_items) do
for _, obj_ in ipairs(self.attached_items) do
if obj_ then
obj_:set_detach()
end
end
local leftover = puncher:get_inventory():add_item("main", "carts:cart")
-- Pick up cart
local inv = puncher:get_inventory()
if not (creative and creative.is_enabled_for
and creative.is_enabled_for(puncher:get_player_name()))
or not inv:contains_item("main", "carts:cart") then
local leftover = inv:add_item("main", "carts:cart")
-- If no room in inventory add a replacement cart to the world
if not leftover:is_empty() then
minetest.add_item(pos, leftover)
minetest.add_item(self.object:get_pos(), leftover)
end
end
self.object:remove()
return
end
-- Driver punches to accelerate the cart
-- Player punches cart to alter velocity
if puncher:get_player_name() == self.driver then
if math.abs(vel.x + vel.z) > boost_cart.punch_speed_max then
if math.abs(vel.x + vel.z) > carts.punch_speed_max then
return
end
end
local punch_dir = boost_cart:velocity_to_dir(puncher:get_look_dir())
local punch_dir = carts:velocity_to_dir(puncher:get_look_dir())
punch_dir.y = 0
local cart_dir = boost_cart:get_rail_direction(pos, punch_dir, nil, nil, self.railtype)
local cart_dir = carts:get_rail_direction(pos, punch_dir, nil, nil, self.railtype)
if vector.equals(cart_dir, {x=0, y=0, z=0}) then
return
end
@ -162,6 +144,12 @@ function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities,
self.punched = true
end
function carts:on_rail_step(entity, pos, distance)
if minetest.global_exists("mesecon") then
carts:signal_detector_rail(pos)
end
end
-- sound refresh interval = 1.0sec
local function rail_sound(self, dtime)
if not self.sound_ttl then
@ -183,14 +171,14 @@ local function rail_sound(self, dtime)
self.sound_handle = minetest.sound_play(
"carts_cart_moving", {
object = self.object,
gain = (speed / boost_cart.speed_max) / 2,
gain = (speed / carts.speed_max) / 2,
loop = true,
})
end
end
local v3_len = vector.length
function cart_entity:on_step(dtime)
local function rail_on_step(self, dtime)
-- Drop cart if there is no player or items inside.
if not self.driver and #self.attached_items == 0 then
@ -199,7 +187,6 @@ function cart_entity:on_step(dtime)
drop_timer = 60 -- 1 min
end
self.count = (self.count or 0) + dtime
if self.count > drop_timer then
minetest.add_item(self.object:get_pos(), "carts:cart")
if self.sound_handle then
@ -208,12 +195,10 @@ function cart_entity:on_step(dtime)
self.object:remove()
return
end
else
self.count = 0
end
rail_sound(self, dtime)
local vel = self.object:get_velocity()
if self.punched then
vel = vector.add(vel, self.velocity)
@ -224,7 +209,7 @@ function cart_entity:on_step(dtime)
end
local pos = self.object:get_pos()
local cart_dir = boost_cart:velocity_to_dir(vel)
local cart_dir = carts:velocity_to_dir(vel)
local same_dir = vector.equals(cart_dir, self.old_dir)
local update = {}
@ -238,7 +223,6 @@ function cart_entity:on_step(dtime)
end
local ctrl, player
local distance = 1
-- Get player controls
if self.driver then
@ -253,9 +237,9 @@ function cart_entity:on_step(dtime)
-- Detection for "skipping" nodes (perhaps use average dtime?)
-- It's sophisticated enough to take the acceleration in account
local acc = self.object:get_acceleration()
distance = dtime * (v3_len(vel) + 0.5 * dtime * v3_len(acc))
local distance = dtime * (v3_len(vel) + 0.5 * dtime * v3_len(acc))
local new_pos, new_dir = boost_cart:pathfinder(
local new_pos, new_dir = carts:pathfinder(
pos, self.old_pos, self.old_dir, distance, ctrl,
self.old_switch, self.railtype
)
@ -274,7 +258,7 @@ 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(
local dir, switch_keys = carts:get_rail_direction(
pos, cart_dir, ctrl, self.old_switch, self.railtype
)
local dir_changed = not vector.equals(dir, self.old_dir)
@ -283,7 +267,7 @@ function cart_entity:on_step(dtime)
if stop_wiggle or vector.equals(dir, {x=0, y=0, z=0}) then
vel = {x=0, y=0, z=0}
local pos_r = vector.round(pos)
if not boost_cart:is_rail(pos_r, self.railtype)
if not carts:is_rail(pos_r, self.railtype)
and self.old_pos then
pos = self.old_pos
elseif not stop_wiggle then
@ -333,7 +317,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 carts.mtg_compat then
-- MTG Cart API adaption
local rail_node = minetest.get_node(vector.round(pos))
local railparam = carts.railparams[rail_node.name]
@ -360,11 +344,11 @@ function cart_entity:on_step(dtime)
-- 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)
if vel_len > carts.speed_max then
vel = vector.multiply(vel, carts.speed_max / vel_len)
update.vel = true
end
if vel_len >= boost_cart.speed_max and acc > 0 then
if vel_len >= carts.speed_max and acc > 0 then
acc = 0
end
@ -380,7 +364,7 @@ function cart_entity:on_step(dtime)
end
self.old_switch = switch_keys
boost_cart:on_rail_step(self, self.old_pos, distance)
carts:on_rail_step(self, self.old_pos, distance)
if self.punched then
-- Collect dropped items
@ -450,42 +434,47 @@ function cart_entity:on_step(dtime)
end
end
minetest.register_entity(":carts:cart", cart_entity)
-- Register item to place the entity
if not boost_cart.mtg_compat then
minetest.register_craftitem(":carts:cart", {
description = "Cart (Sneak+Click to pick up)",
inventory_image = "carts_cart_inv.png",
wield_image = "carts_cart_inv.png",
stack_max = 1,
sounds = default.node_sound_metal_defaults(),
on_place = function(itemstack, placer, pointed_thing)
if not pointed_thing.type == "node" then
return
end
if boost_cart:is_rail(pointed_thing.under) then
minetest.add_entity(pointed_thing.under, "carts:cart")
elseif boost_cart:is_rail(pointed_thing.above) then
minetest.add_entity(pointed_thing.above, "carts:cart")
else
return
end
if not (creative and creative.is_enabled_for and
creative.is_enabled_for(placer)) or
not minetest.is_singleplayer() then
itemstack:take_item()
end
return itemstack
end,
})
minetest.register_craft({
output = "carts:cart",
recipe = {
{"default:steel_ingot", "", "default:steel_ingot"},
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
},
})
function cart_entity:on_step(dtime)
rail_on_step(self, dtime)
rail_sound(self, dtime)
end
minetest.register_entity("carts:cart", cart_entity)
minetest.register_craftitem("carts:cart", {
description = "Cart (Sneak+Click to pick up)",
inventory_image = "carts_cart_inv.png",
wield_image = "carts_cart_inv.png",
stack_max = 1,
sounds = default.node_sound_metal_defaults(),
on_place = function(itemstack, placer, pointed_thing)
if not pointed_thing.type == "node" then
return
end
if carts:is_rail(pointed_thing.under) then
minetest.add_entity(pointed_thing.under, "carts:cart")
elseif carts:is_rail(pointed_thing.above) then
minetest.add_entity(pointed_thing.above, "carts:cart")
else
return
end
minetest.sound_play({name = "default_place_node_metal", gain = 0.5},
{pos = pointed_thing.above})
if not (creative and creative.is_enabled_for and
creative.is_enabled_for(placer)) or
not minetest.is_singleplayer() then
itemstack:take_item()
end
return itemstack
end,
})
minetest.register_craft({
output = "carts:cart",
recipe = {
{"default:steel_ingot", "", "default:steel_ingot"},
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
},
})

View File

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

View File

@ -1,55 +1,54 @@
local mesecons_rules = mesecon.rules.flat
function boost_cart:turnoff_detector_rail(pos)
function carts:turnoff_detector_rail(pos)
local node = minetest.get_node(pos)
if minetest.get_item_group(node.name, "detector_rail") == 1 then
if node.name == "boost_cart:detectorrail_on" then --has not been dug
minetest.swap_node(pos, {name = "boost_cart:detectorrail", param2=node.param2})
if node.name == "carts:detectorrail_on" then --has not been dug
minetest.swap_node(pos, {name = "carts:detectorrail", param2=node.param2})
end
mesecon.receptor_off(pos, mesecons_rules)
end
end
function boost_cart:signal_detector_rail(pos)
function carts:signal_detector_rail(pos)
local node = minetest.get_node(pos)
if minetest.get_item_group(node.name, "detector_rail") ~= 1 then
return
end
if node.name == "boost_cart:detectorrail" then
minetest.swap_node(pos, {name = "boost_cart:detectorrail_on", param2=node.param2})
if node.name == "carts:detectorrail" then
minetest.swap_node(pos, {name = "carts:detectorrail_on", param2=node.param2})
end
mesecon.receptor_on(pos, mesecons_rules)
minetest.after(0.5, boost_cart.turnoff_detector_rail, boost_cart, pos)
minetest.after(0.5, carts.turnoff_detector_rail, carts, pos)
end
boost_cart:register_rail("boost_cart:detectorrail", {
carts:register_rail("carts:detectorrail", {
description = "Detector rail",
tiles = {
"carts_rail_straight_dtc.png", "carts_rail_curved_dtc.png",
"carts_rail_t_junction_dtc.png", "carts_rail_crossing_dtc.png"
},
groups = boost_cart:get_rail_groups({detector_rail = 1}),
groups = carts:get_rail_groups({detector_rail = 1}),
mesecons = {receptor = {state = "off", rules = mesecons_rules}},
})
boost_cart:register_rail("boost_cart:detectorrail_on", {
description = "Detector rail ON (you hacker you)",
carts:register_rail("carts:detectorrail_on", {
tiles = {
"carts_rail_straight_dtc_on.png", "carts_rail_curved_dtc_on.png",
"carts_rail_t_junction_dtc_on.png", "carts_rail_crossing_dtc_on.png"
},
groups = boost_cart:get_rail_groups({
groups = carts:get_rail_groups({
detector_rail = 1, not_in_creative_inventory = 1
}),
drop = "boost_cart:detectorrail",
drop = "carts:detectorrail",
mesecons = {receptor = {state = "on", rules = mesecons_rules}},
})
minetest.register_craft({
output = "boost_cart:detectorrail 6",
output = "carts:detectorrail 6",
recipe = {
{"default:steel_ingot", "", "default:steel_ingot"},
{"default:steel_ingot", "mesecons_pressureplates:pressure_plate_stone_off", "default:steel_ingot"},

View File

@ -1,4 +1,4 @@
function boost_cart:get_sign(z)
function carts:get_sign(z)
if z == 0 then
return 0
else
@ -6,16 +6,16 @@ function boost_cart:get_sign(z)
end
end
function boost_cart:manage_attachment(player, obj)
function carts: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
if player_api.player_attached[player_name] == status then
return
end
default.player_attached[player_name] = status
player_api.player_attached[player_name] = status
if status then
local y_pos = 6
@ -32,7 +32,7 @@ function boost_cart:manage_attachment(player, obj)
end
end
function boost_cart:velocity_to_dir(v)
function carts:velocity_to_dir(v)
if math.abs(v.x) > math.abs(v.z) then
return {x=self:get_sign(v.x), y=self:get_sign(v.y), z=0}
else
@ -42,7 +42,7 @@ end
local get_node = minetest.get_node
local get_item_group = minetest.get_item_group
function boost_cart:is_rail(pos, railtype)
function carts:is_rail(pos, railtype)
local node = get_node(pos).name
if node == "ignore" then
local vm = minetest.get_voxel_manip()
@ -64,34 +64,34 @@ function boost_cart:is_rail(pos, railtype)
return get_item_group(node, "connect_to_raillike") == railtype
end
function boost_cart:check_front_up_down(pos, dir_, check_up, railtype)
function carts:check_front_up_down(pos, dir_, check_up, railtype)
local dir = vector.new(dir_)
local cur = nil
-- Front
dir.y = 0
cur = vector.add(pos, dir)
if self:is_rail(cur, railtype) then
if carts:is_rail(cur, railtype) then
return dir
end
-- Up
if check_up then
dir.y = 1
cur = vector.add(pos, dir)
if self:is_rail(cur, railtype) then
if carts:is_rail(cur, railtype) then
return dir
end
end
-- Down
dir.y = -1
cur = vector.add(pos, dir)
if self:is_rail(cur, railtype) then
if carts:is_rail(cur, railtype) then
return dir
end
return nil
end
function boost_cart:get_rail_direction(pos_, dir, ctrl, old_switch, railtype)
function carts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype)
local pos = vector.round(pos_)
local cur = nil
local left_check, right_check = true, true
@ -149,7 +149,7 @@ function boost_cart:get_rail_direction(pos_, dir, ctrl, old_switch, railtype)
-- Left, if not already checked
if left_check then
cur = self:check_front_up_down(pos, left, false, railtype)
cur = carts:check_front_up_down(pos, left, false, railtype)
if cur then
return cur
end
@ -157,7 +157,7 @@ function boost_cart:get_rail_direction(pos_, dir, ctrl, old_switch, railtype)
-- Right, if not already checked
if right_check then
cur = self:check_front_up_down(pos, right, false, railtype)
cur = carts:check_front_up_down(pos, right, false, railtype)
if cur then
return cur
end
@ -165,7 +165,7 @@ function boost_cart:get_rail_direction(pos_, dir, ctrl, old_switch, railtype)
-- Backwards
if not old_switch then
cur = self:check_front_up_down(pos, {
cur = carts:check_front_up_down(pos, {
x = -dir.x,
y = dir.y,
z = -dir.z
@ -178,7 +178,7 @@ function boost_cart:get_rail_direction(pos_, dir, ctrl, old_switch, railtype)
return {x=0, y=0, z=0}
end
function boost_cart:pathfinder(pos_, old_pos, old_dir, distance, ctrl,
function carts:pathfinder(pos_, old_pos, old_dir, distance, ctrl,
pf_switch, railtype)
local pos = vector.round(pos_)
@ -188,7 +188,7 @@ function boost_cart:pathfinder(pos_, old_pos, old_dir, distance, ctrl,
local pf_pos = vector.round(old_pos)
local pf_dir = vector.new(old_dir)
distance = math.min(boost_cart.path_distance_max,
distance = math.min(carts.path_distance_max,
math.floor(distance + 1))
for i = 1, distance do
@ -211,7 +211,7 @@ function boost_cart:pathfinder(pos_, old_pos, old_dir, distance, ctrl,
return pf_pos, pf_dir
end
function boost_cart:boost_rail(pos, amount)
function carts:boost_rail(pos, amount)
minetest.get_meta(pos):set_string("cart_acceleration", tostring(amount))
for _,obj_ in ipairs(minetest.get_objects_inside_radius(pos, 0.5)) do
if not obj_:is_player() and
@ -222,7 +222,7 @@ function boost_cart:boost_rail(pos, amount)
end
end
function boost_cart:register_rail(name, def_overwrite)
function carts:register_rail(name, def_overwrite)
local def = {
drawtype = "raillike",
paramtype = "light",
@ -246,17 +246,14 @@ function boost_cart:register_rail(name, def_overwrite)
minetest.register_node(name, def)
end
function boost_cart:get_rail_groups(additional_groups)
function carts:get_rail_groups(additional_groups)
-- Get the default rail groups and add more when a table is given
local groups = {
dig_immediate = 2,
attached_node = 1,
rail = 1,
connect_to_raillike = 1
connect_to_raillike = minetest.raillike_group("rail")
}
if minetest.raillike_group then
groups.connect_to_raillike = minetest.raillike_group("rail")
end
if type(additional_groups) == "table" then
for k, v in pairs(additional_groups) do
groups[k] = v

View File

@ -0,0 +1,28 @@
carts = {}
carts.modpath = minetest.get_modpath("carts")
-- Maximal speed of the cart in m/s
carts.speed_max = 12
-- Set to -1 to disable punching the cart from inside
carts.punch_speed_max = 8
-- Maximal distance for the path correction (for dtime peaks)
carts.path_distance_max = 3
dofile(carts.modpath.."/functions.lua")
dofile(carts.modpath.."/rails.lua")
dofile(carts.modpath.."/detector.lua")
dofile(carts.modpath.."/cart_entity.lua")
-- Aliases
minetest.register_alias("railcart:cart", "carts:cart")
minetest.register_alias("railcart:cart_entity", "carts:cart")
minetest.register_alias("default:rail", "carts:rail")
minetest.register_alias("boost_cart:rail", "carts:rail")
minetest.register_alias("railtrack:powerrail", "carts:powerrail")
minetest.register_alias("railtrack:superrail", "carts:powerrail")
minetest.register_alias("railtrack:brakerail", "carts:brakerail")
minetest.register_alias("railtrack:switchrail", "carts:startstoprail")
minetest.register_alias("boost_cart:detectorrail", "carts:detectorrail")
minetest.register_alias("boost_cart:startstoprail", "carts:startstoprail")
minetest.register_alias("railtrack:fixer", "default:stick")
minetest.register_alias("railtrack:inspector", "default:stick")

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -1,16 +1,16 @@
-- Common rail registrations
boost_cart:register_rail("boost_cart:rail", {
carts:register_rail("carts:rail", {
description = "Rail",
tiles = {
"carts_rail_straight.png", "carts_rail_curved.png",
"carts_rail_t_junction.png", "carts_rail_crossing.png"
},
groups = boost_cart:get_rail_groups(),
groups = carts:get_rail_groups(),
}, {})
minetest.register_craft({
output = "boost_cart:rail 16",
output = "carts:rail 16",
recipe = {
{"default:steel_ingot", "", "default:steel_ingot"},
{"default:steel_ingot", "group:stick", "default:steel_ingot"},
@ -19,13 +19,13 @@ minetest.register_craft({
})
-- Power rail
boost_cart:register_rail(":carts:powerrail", {
description = "Powered rail",
carts:register_rail("carts:powerrail", {
description = "Powered Rail",
tiles = {
"carts_rail_straight_pwr.png", "carts_rail_curved_pwr.png",
"carts_rail_t_junction_pwr.png", "carts_rail_crossing_pwr.png"
},
groups = boost_cart:get_rail_groups(),
groups = carts:get_rail_groups(),
after_place_node = function(pos, placer, itemstack)
if not mesecon then
minetest.get_meta(pos):set_string("cart_acceleration", "0.5")
@ -34,7 +34,7 @@ boost_cart:register_rail(":carts:powerrail", {
mesecons = {
effector = {
action_on = function(pos, node)
boost_cart:boost_rail(pos, 0.5)
carts:boost_rail(pos, 0.5)
end,
action_off = function(pos, node)
minetest.get_meta(pos):set_string("cart_acceleration", "0")
@ -53,13 +53,13 @@ minetest.register_craft({
})
-- Brake rail
boost_cart:register_rail(":carts:brakerail", {
description = "Brake rail",
carts:register_rail("carts:brakerail", {
description = "Brake Rail",
tiles = {
"carts_rail_straight_brk.png", "carts_rail_curved_brk.png",
"carts_rail_t_junction_brk.png", "carts_rail_crossing_brk.png"
},
groups = boost_cart:get_rail_groups(),
groups = carts:get_rail_groups(),
after_place_node = function(pos, placer, itemstack)
if not mesecon then
minetest.get_meta(pos):set_string("cart_acceleration", "-0.3")
@ -86,13 +86,13 @@ minetest.register_craft({
}
})
boost_cart:register_rail("boost_cart:startstoprail", {
carts:register_rail("carts:startstoprail", {
description = "Start-stop rail",
tiles = {
"carts_rail_straight_ss.png", "carts_rail_curved_ss.png",
"carts_rail_t_junction_ss.png", "carts_rail_crossing_ss.png"
},
groups = boost_cart:get_rail_groups(),
groups = carts:get_rail_groups(),
after_place_node = function(pos, placer, itemstack)
if not mesecon then
minetest.get_meta(pos):set_string("cart_acceleration", "halt")
@ -101,7 +101,7 @@ boost_cart:register_rail("boost_cart:startstoprail", {
mesecons = {
effector = {
action_on = function(pos, node)
boost_cart:boost_rail(pos, 0.5)
carts:boost_rail(pos, 0.5)
end,
action_off = function(pos, node)
minetest.get_meta(pos):set_string("cart_acceleration", "halt")
@ -111,7 +111,7 @@ boost_cart:register_rail("boost_cart:startstoprail", {
})
minetest.register_craft({
output = "boost_cart:startstoprail 2",
output = "carts:startstoprail 2",
recipe = {
{"default:steel_ingot", "group:stick", "default:steel_ingot"},
{"default:steel_ingot", "mesecons_torch:mesecon_torch_on", "default:steel_ingot"},

View File

Before

Width:  |  Height:  |  Size: 522 B

After

Width:  |  Height:  |  Size: 522 B

View File

Before

Width:  |  Height:  |  Size: 245 B

After

Width:  |  Height:  |  Size: 245 B

View File

Before

Width:  |  Height:  |  Size: 403 B

After

Width:  |  Height:  |  Size: 403 B

View File

Before

Width:  |  Height:  |  Size: 513 B

After

Width:  |  Height:  |  Size: 513 B

View File

Before

Width:  |  Height:  |  Size: 577 B

After

Width:  |  Height:  |  Size: 577 B

View File

Before

Width:  |  Height:  |  Size: 397 B

After

Width:  |  Height:  |  Size: 397 B

View File

Before

Width:  |  Height:  |  Size: 579 B

After

Width:  |  Height:  |  Size: 579 B

View File

Before

Width:  |  Height:  |  Size: 240 B

After

Width:  |  Height:  |  Size: 240 B

View File

Before

Width:  |  Height:  |  Size: 378 B

After

Width:  |  Height:  |  Size: 378 B

View File

Before

Width:  |  Height:  |  Size: 417 B

After

Width:  |  Height:  |  Size: 417 B

View File

Before

Width:  |  Height:  |  Size: 457 B

After

Width:  |  Height:  |  Size: 457 B

View File

Before

Width:  |  Height:  |  Size: 458 B

After

Width:  |  Height:  |  Size: 458 B

View File

Before

Width:  |  Height:  |  Size: 371 B

After

Width:  |  Height:  |  Size: 371 B

View File

Before

Width:  |  Height:  |  Size: 474 B

After

Width:  |  Height:  |  Size: 474 B

View File

Before

Width:  |  Height:  |  Size: 243 B

After

Width:  |  Height:  |  Size: 243 B

View File

Before

Width:  |  Height:  |  Size: 439 B

After

Width:  |  Height:  |  Size: 439 B

View File

Before

Width:  |  Height:  |  Size: 478 B

After

Width:  |  Height:  |  Size: 478 B

View File

Before

Width:  |  Height:  |  Size: 516 B

After

Width:  |  Height:  |  Size: 516 B

View File

Before

Width:  |  Height:  |  Size: 427 B

After

Width:  |  Height:  |  Size: 427 B

View File

Before

Width:  |  Height:  |  Size: 518 B

After

Width:  |  Height:  |  Size: 518 B

View File

Before

Width:  |  Height:  |  Size: 415 B

After

Width:  |  Height:  |  Size: 415 B

View File

Before

Width:  |  Height:  |  Size: 402 B

After

Width:  |  Height:  |  Size: 402 B

View File

Before

Width:  |  Height:  |  Size: 501 B

After

Width:  |  Height:  |  Size: 501 B

View File

Before

Width:  |  Height:  |  Size: 526 B

After

Width:  |  Height:  |  Size: 526 B

View File

Before

Width:  |  Height:  |  Size: 402 B

After

Width:  |  Height:  |  Size: 402 B

View File

Before

Width:  |  Height:  |  Size: 568 B

After

Width:  |  Height:  |  Size: 568 B

View File

@ -9,7 +9,7 @@ ts_furniture.enable_sitting = false
local players = minetest.get_connected_players()
for i = 1, #players do
local name = players[i]:get_player_name()
if default.player_attached[name] and not players[i]:get_attach() and
if player_api.player_attached[name] and not players[i]:get_attach() and
(players[i]:get_player_control().up == true or
players[i]:get_player_control().down == true or
players[i]:get_player_control().left == true or
@ -17,7 +17,7 @@ ts_furniture.enable_sitting = false
players[i]:get_player_control().jump == true) then
players[i]:set_eye_offset({ x = 0, y = 0, z = 0 }, { x = 0, y = 0, z = 0 })
players[i]:set_physics_override(1, 1, 1)
default.player_attached[name] = false
player_api.player_attached[name] = false
player_api.set_animation(players[i], "stand", 30)
end
end
@ -25,16 +25,16 @@ end)
ts_furniture.sit = function(name, pos)
local player = minetest.get_player_by_name(name)
if default.player_attached[name] then
if player_api.player_attached[name] then
player:set_eye_offset({ x = 0, y = 0, z = 0 }, { x = 0, y = 0, z = 0 })
player:set_physics_override(1, 1, 1)
default.player_attached[name] = false
player_api.player_attached[name] = false
player_api.set_animation(player, "stand", 30)
else
player:moveto(pos)
player:set_eye_offset({ x = 0, y = -7, z = 2 }, { x = 0, y = 0, z = 0 })
player:set_physics_override(0, 0, 0)
default.player_attached[name] = true
player_api.player_attached[name] = true
player_api.set_animation(player, "sit", 30)
end
end]]