From f18f36ac0d5416311b74160942e5f4946742c7d1 Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Sat, 2 Jul 2016 21:05:57 -0400 Subject: Added boost_cart mod --- boost_cart/README.txt | 23 ++ boost_cart/depends.txt | 3 + boost_cart/detector.lua | 50 +++ boost_cart/functions.lua | 192 ++++++++++++ boost_cart/init.lua | 349 +++++++++++++++++++++ boost_cart/models/cart.png | Bin 0 -> 216 bytes boost_cart/models/cart.x | 339 ++++++++++++++++++++ boost_cart/rails.lua | 104 ++++++ boost_cart/textures/cart_bottom.png | Bin 0 -> 114 bytes boost_cart/textures/cart_side.png | Bin 0 -> 147 bytes boost_cart/textures/cart_top.png | Bin 0 -> 131 bytes boost_cart/textures/carts_rail_brk.png | Bin 0 -> 577 bytes boost_cart/textures/carts_rail_cp.png | Bin 0 -> 522 bytes boost_cart/textures/carts_rail_crossing_brk.png | Bin 0 -> 549 bytes boost_cart/textures/carts_rail_crossing_cp.png | Bin 0 -> 495 bytes boost_cart/textures/carts_rail_crossing_dtc.png | Bin 0 -> 621 bytes boost_cart/textures/carts_rail_crossing_dtc_on.png | Bin 0 -> 654 bytes boost_cart/textures/carts_rail_crossing_pwr.png | Bin 0 -> 458 bytes boost_cart/textures/carts_rail_curved_brk.png | Bin 0 -> 537 bytes boost_cart/textures/carts_rail_curved_cp.png | Bin 0 -> 488 bytes boost_cart/textures/carts_rail_curved_dtc.png | Bin 0 -> 578 bytes boost_cart/textures/carts_rail_curved_dtc_on.png | Bin 0 -> 575 bytes boost_cart/textures/carts_rail_curved_pwr.png | Bin 0 -> 443 bytes boost_cart/textures/carts_rail_dtc.png | Bin 0 -> 542 bytes boost_cart/textures/carts_rail_dtc_on.png | Bin 0 -> 559 bytes boost_cart/textures/carts_rail_pwr.png | Bin 0 -> 498 bytes boost_cart/textures/carts_rail_t_junction_brk.png | Bin 0 -> 538 bytes boost_cart/textures/carts_rail_t_junction_cp.png | Bin 0 -> 496 bytes boost_cart/textures/carts_rail_t_junction_dtc.png | Bin 0 -> 607 bytes .../textures/carts_rail_t_junction_dtc_on.png | Bin 0 -> 621 bytes boost_cart/textures/carts_rail_t_junction_pwr.png | Bin 0 -> 539 bytes boost_cart/textures/default_rail_t_junction.png | Bin 0 -> 476 bytes 32 files changed, 1060 insertions(+) create mode 100644 boost_cart/README.txt create mode 100644 boost_cart/depends.txt create mode 100644 boost_cart/detector.lua create mode 100644 boost_cart/functions.lua create mode 100644 boost_cart/init.lua create mode 100644 boost_cart/models/cart.png create mode 100644 boost_cart/models/cart.x create mode 100644 boost_cart/rails.lua create mode 100644 boost_cart/textures/cart_bottom.png create mode 100644 boost_cart/textures/cart_side.png create mode 100644 boost_cart/textures/cart_top.png create mode 100644 boost_cart/textures/carts_rail_brk.png create mode 100644 boost_cart/textures/carts_rail_cp.png create mode 100644 boost_cart/textures/carts_rail_crossing_brk.png create mode 100644 boost_cart/textures/carts_rail_crossing_cp.png create mode 100644 boost_cart/textures/carts_rail_crossing_dtc.png create mode 100644 boost_cart/textures/carts_rail_crossing_dtc_on.png create mode 100644 boost_cart/textures/carts_rail_crossing_pwr.png create mode 100644 boost_cart/textures/carts_rail_curved_brk.png create mode 100644 boost_cart/textures/carts_rail_curved_cp.png create mode 100644 boost_cart/textures/carts_rail_curved_dtc.png create mode 100644 boost_cart/textures/carts_rail_curved_dtc_on.png create mode 100644 boost_cart/textures/carts_rail_curved_pwr.png create mode 100644 boost_cart/textures/carts_rail_dtc.png create mode 100644 boost_cart/textures/carts_rail_dtc_on.png create mode 100644 boost_cart/textures/carts_rail_pwr.png create mode 100644 boost_cart/textures/carts_rail_t_junction_brk.png create mode 100644 boost_cart/textures/carts_rail_t_junction_cp.png create mode 100644 boost_cart/textures/carts_rail_t_junction_dtc.png create mode 100644 boost_cart/textures/carts_rail_t_junction_dtc_on.png create mode 100644 boost_cart/textures/carts_rail_t_junction_pwr.png create mode 100644 boost_cart/textures/default_rail_t_junction.png diff --git a/boost_cart/README.txt b/boost_cart/README.txt new file mode 100644 index 0000000..4807105 --- /dev/null +++ b/boost_cart/README.txt @@ -0,0 +1,23 @@ +Minetest mod: boost_cart +======================= +Based on (and fully compatible with) the mod "carts" by PilzAdam +Target: Run smoothly and do not use too much CPU + +License of source code: +----------------------- +WTFPL + +License of media (textures, sounds and models): +----------------------------------------------- +CC-0 + +Authors of media files: +----------------------- +kddekadenz: + cart_bottom.png + cart_side.png + cart_top.png + +Zeg9: + cart.x + cart.png \ No newline at end of file diff --git a/boost_cart/depends.txt b/boost_cart/depends.txt new file mode 100644 index 0000000..bfb43df --- /dev/null +++ b/boost_cart/depends.txt @@ -0,0 +1,3 @@ +default +mesecons? +moreores? \ No newline at end of file diff --git a/boost_cart/detector.lua b/boost_cart/detector.lua new file mode 100644 index 0000000..17d1f16 --- /dev/null +++ b/boost_cart/detector.lua @@ -0,0 +1,50 @@ +local mesecons_rules = mesecon.rules.flat + +function boost_cart: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}) + end + mesecon.receptor_off(pos, mesecons_rules) + end +end + +function boost_cart:signal_detector_rail(pos) + local node = minetest.get_node(pos) + if minetest.get_item_group(node.name, "detector_rail") ~= 1 then + return + end + --minetest.log("action", "Signaling detector at " .. minetest.pos_to_string(pos)) + if node.name == "boost_cart:detectorrail" then + minetest.swap_node(pos, {name = "boost_cart:detectorrail_on", param2=node.param2}) + end + mesecon.receptor_on(pos, mesecons_rules) + minetest.after(0.5, boost_cart.turnoff_detector_rail, boost_cart, pos) +end + +boost_cart:register_rail("boost_cart:detectorrail", { + description = "Detector rail", + tiles = {"carts_rail_dtc.png", "carts_rail_curved_dtc.png", "carts_rail_t_junction_dtc.png", "carts_rail_crossing_dtc.png"}, + groups = {dig_immediate = 2, attached_node = 1, rail = 1, connect_to_raillike = 1, 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)", + tiles = {"carts_rail_dtc_on.png", "carts_rail_curved_dtc_on.png", "carts_rail_t_junction_dtc_on.png", "carts_rail_crossing_dtc_on.png"}, + groups = {dig_immediate = 2, attached_node = 1, rail = 1, connect_to_raillike = 1, detector_rail = 1, not_in_creative_inventory = 1}, + drop = "boost_cart:detectorrail", + + mesecons = {receptor = {state = "on", rules = mesecons_rules }}, +}) + +minetest.register_craft({ + output = "boost_cart:detectorrail 6", + recipe = { + {"default:steel_ingot", "mesecons:wire_00000000_off", "default:steel_ingot"}, + {"default:steel_ingot", "group:stick", "default:steel_ingot"}, + {"default:steel_ingot", "mesecons:wire_00000000_off", "default:steel_ingot"}, + }, +}) diff --git a/boost_cart/functions.lua b/boost_cart/functions.lua new file mode 100644 index 0000000..a06f34d --- /dev/null +++ b/boost_cart/functions.lua @@ -0,0 +1,192 @@ +function boost_cart:get_sign(z) + if z == 0 then + return 0 + else + return z / math.abs(z) + end +end + +function boost_cart:manage_attachment(player, status, obj) + if not player then + return + end + local player_name = player:get_player_name() + if default.player_attached[player_name] == status then + return + end + default.player_attached[player_name] = status + + if status then + player:set_attach(obj, "", {x=0, y=6, z=0}, {x=0, y=0, z=0}) + player:set_eye_offset({x=0, y=-4, z=0},{x=0, y=-4, z=0}) + else + player:set_detach() + player:set_eye_offset({x=0, y=0, z=0},{x=0, y=0, z=0}) + end +end + +function boost_cart:velocity_to_dir(v) + if math.abs(v.x) > math.abs(v.z) then + return {x=boost_cart:get_sign(v.x), y=boost_cart:get_sign(v.y), z=0} + else + return {x=0, y=boost_cart:get_sign(v.y), z=boost_cart:get_sign(v.z)} + end +end + +function boost_cart:is_rail(pos, railtype) + local node = minetest.get_node(pos).name + if node == "ignore" then + local vm = minetest.get_voxel_manip() + local emin, emax = vm:read_from_map(pos, pos) + local area = VoxelArea:new{ + MinEdge = emin, + MaxEdge = emax, + } + local data = vm:get_data() + local vi = area:indexp(pos) + node = minetest.get_name_from_content_id(data[vi]) + end + if minetest.get_item_group(node, "rail") == 0 then + return false + end + if not railtype then + return true + end + return minetest.get_item_group(node, "connect_to_raillike") == railtype +end + +function boost_cart:check_front_up_down(pos, dir_, check_down, railtype) + local dir = vector.new(dir_) + local cur = nil + + -- Front + dir.y = 0 + cur = vector.add(pos, dir) + if boost_cart:is_rail(cur, railtype) then + return dir + end + -- Up + if check_down then + dir.y = 1 + cur = vector.add(pos, dir) + if boost_cart:is_rail(cur, railtype) then + return dir + end + end + -- Down + dir.y = -1 + cur = vector.add(pos, dir) + if boost_cart:is_rail(cur, railtype) then + return dir + end + return nil +end + +function boost_cart:get_rail_direction(pos_, dir, ctrl, old_switch, railtype) + local pos = vector.round(pos_) + local cur = nil + local left_check, right_check = true, true + + -- Check left and right + local left = {x=0, y=0, z=0} + local right = {x=0, y=0, z=0} + if dir.z ~= 0 and dir.x == 0 then + left.x = -dir.z + right.x = dir.z + elseif dir.x ~= 0 and dir.z == 0 then + left.z = dir.x + right.z = -dir.x + end + + if ctrl then + if old_switch == 1 then + left_check = false + elseif old_switch == 2 then + right_check = false + end + if ctrl.left and left_check then + cur = boost_cart:check_front_up_down(pos, left, false, railtype) + if cur then + return cur, 1 + end + left_check = false + end + if ctrl.right and right_check then + cur = boost_cart:check_front_up_down(pos, right, false, railtype) + if cur then + return cur, 2 + end + right_check = true + end + end + + -- Normal + cur = boost_cart:check_front_up_down(pos, dir, true, railtype) + if cur then + return cur + end + + -- Left, if not already checked + if left_check then + cur = boost_cart:check_front_up_down(pos, left, false, railtype) + if cur then + return cur + end + end + + -- Right, if not already checked + if right_check then + cur = boost_cart:check_front_up_down(pos, right, false, railtype) + if cur then + return cur + end + end + + -- Backwards + if not old_switch then + cur = boost_cart:check_front_up_down(pos, { + x = -dir.x, + y = dir.y, + z = -dir.z + }, true, railtype) + if cur then + return cur + end + end + + return {x=0, y=0, z=0} +end + +function boost_cart: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 + obj_:get_luaentity() and + obj_:get_luaentity().name == "carts:cart" then + obj_:get_luaentity():on_punch() + end + end +end + +function boost_cart:register_rail(name, def) + local def_default = { + drawtype = "raillike", + paramtype = "light", + sunlight_propagates = true, + is_ground_content = true, + walkable = false, + selection_box = { + type = "fixed", + fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2}, + } + } + for k, v in pairs(def_default) do + def[k] = v + end + if not def.inventory_image then + def.wield_image = def.tiles[1] + def.inventory_image = def.tiles[1] + end + + minetest.register_node(name, def) +end \ No newline at end of file diff --git a/boost_cart/init.lua b/boost_cart/init.lua new file mode 100644 index 0000000..e1363c7 --- /dev/null +++ b/boost_cart/init.lua @@ -0,0 +1,349 @@ + +boost_cart = {} +boost_cart.modpath = minetest.get_modpath("boost_cart") + +-- Maximal speed of the cart in m/s +boost_cart.speed_max = 10 +-- Set to nil to disable punching the cart from inside +boost_cart.punch_speed_min = 7 + + +if not boost_cart.modpath then + error("\nWrong mod directory name! Please change it to 'boost_cart'.\n" .. + "See also: http://dev.minetest.net/Installing_Mods") +end + +function vector.floor(v) + return { + x = math.floor(v.x), + y = math.floor(v.y), + z = math.floor(v.z) + } +end + +dofile(boost_cart.modpath.."/functions.lua") +dofile(boost_cart.modpath.."/rails.lua") + +if mesecon then + dofile(boost_cart.modpath.."/detector.lua") +end + +-- Support for non-default games +if not default.player_attached then + default.player_attached = {} +end + +boost_cart.cart = { + 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 + velocity = {x=0, y=0, z=0}, -- only used on punch + old_dir = {x=0, y=0, z=0}, + old_pos = nil, + old_switch = 0, + railtype = nil, + attached_items = {} +} + +function boost_cart.cart:on_rightclick(clicker) + if not clicker or not clicker:is_player() then + return + 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, false) + elseif not self.driver then + self.driver = player_name + boost_cart:manage_attachment(clicker, true, self.object) + end +end + +function boost_cart.cart:on_activate(staticdata, dtime_s) + self.object:set_armor_groups({immortal=1}) + if string.sub(staticdata, 1, string.len("return")) ~= "return" then + return + end + local data = minetest.deserialize(staticdata) + if not data or type(data) ~= "table" then + return + end + self.railtype = data.railtype +end + +function boost_cart.cart:get_staticdata() + return minetest.serialize({ + railtype = self.railtype + }) +end + +function boost_cart.cart:on_punch(puncher, time_from_last_punch, tool_capabilities, direction) + local pos = self.object:getpos() + if not self.railtype then + local bar = vector.floor(vector.add(pos, 0.1)) + local node = minetest.get_node(bar).name + self.railtype = minetest.get_item_group(node, "connect_to_raillike") + end + + if not puncher or not puncher:is_player() then + local cart_dir = boost_cart:get_rail_direction(pos, {x=1, y=0, z=0}, nil, nil, self.railtype) + if vector.equals(cart_dir, {x=0, y=0, z=0}) then + return + end + self.velocity = vector.multiply(cart_dir, 3) + self.old_pos = nil + self.punched = true + return + end + + if puncher:get_player_control().sneak then + if self.driver then + if self.old_pos then + self.object:setpos(self.old_pos) + end + local player = minetest.get_player_by_name(self.driver) + boost_cart:manage_attachment(player, false) + end + 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") + if not leftover:is_empty() then + minetest.add_item(self.object:getpos(), leftover) + end + self.object:remove() + return + end + + + local vel = self.object:getvelocity() + if puncher:get_player_name() == self.driver then + if math.abs(vel.x + vel.z) > (boost_cart.punch_speed_min or -1) then + return + end + end + + local punch_dir = boost_cart: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) + if vector.equals(cart_dir, {x=0, y=0, z=0}) then + return + end + + local punch_interval = 1 + if tool_capabilities and tool_capabilities.full_punch_interval then + punch_interval = tool_capabilities.full_punch_interval + end + time_from_last_punch = math.min(time_from_last_punch or punch_interval, punch_interval) + local f = 3 * (time_from_last_punch / punch_interval) + + self.velocity = vector.multiply(cart_dir, f) + self.old_pos = nil + self.punched = true +end + +function boost_cart.cart:on_step(dtime) + local vel = self.object:getvelocity() + local update = {} + if self.punched then + vel = vector.add(vel, self.velocity) + self.object:setvelocity(vel) + self.old_dir.y = 0 + elseif vector.equals(vel, {x=0, y=0, z=0}) then + return + end + + local dir, last_switch = nil, nil + local pos = self.object:getpos() + if self.old_pos and not self.punched then + local flo_pos = vector.floor(pos) + local flo_old = vector.floor(self.old_pos) + if vector.equals(flo_pos, flo_old) then + return + end + end + + local ctrl, player = nil, nil + if self.driver then + player = minetest.get_player_by_name(self.driver) + if player then + ctrl = player:get_player_control() + end + end + if self.old_pos then + local diff = vector.subtract(self.old_pos, pos) + for _,v in ipairs({"x","y","z"}) do + if math.abs(diff[v]) > 1.1 then + local expected_pos = vector.add(self.old_pos, self.old_dir) + dir, last_switch = boost_cart:get_rail_direction(pos, self.old_dir, ctrl, self.old_switch, self.railtype) + if vector.equals(dir, {x=0, y=0, z=0}) then + dir = false + pos = vector.new(expected_pos) + update.pos = true + end + break + end + end + end + + if vel.y == 0 then + for _,v in ipairs({"x", "z"}) do + if vel[v] ~= 0 and math.abs(vel[v]) < 0.9 then + vel[v] = 0 + update.vel = true + end + end + end + + local cart_dir = boost_cart:velocity_to_dir(vel) + local max_vel = boost_cart.speed_max + if not dir then + dir, last_switch = boost_cart:get_rail_direction(pos, cart_dir, ctrl, self.old_switch, self.railtype) + end + + local new_acc = {x=0, y=0, z=0} + if vector.equals(dir, {x=0, y=0, z=0}) then + vel = {x=0, y=0, z=0} + update.vel = true + else + -- If the direction changed + if dir.x ~= 0 and self.old_dir.z ~= 0 then + vel.x = dir.x * math.abs(vel.z) + vel.z = 0 + pos.z = math.floor(pos.z + 0.5) + update.pos = true + end + if dir.z ~= 0 and self.old_dir.x ~= 0 then + vel.z = dir.z * math.abs(vel.x) + vel.x = 0 + pos.x = math.floor(pos.x + 0.5) + update.pos = true + end + -- Up, down? + if dir.y ~= self.old_dir.y then + vel.y = dir.y * math.abs(vel.x + vel.z) + pos = vector.round(pos) + update.pos = true + end + + -- Slow down or speed up.. + local acc = dir.y * -1.8 + + local speed_mod = tonumber(minetest.get_meta(pos):get_string("cart_acceleration")) + if speed_mod and speed_mod ~= 0 then + if speed_mod > 0 then + for _,v in ipairs({"x","y","z"}) do + if math.abs(vel[v]) >= max_vel then + speed_mod = 0 + break + end + end + end + acc = acc + (speed_mod * 8) + else + acc = acc - 0.4 + -- Handbrake + if ctrl and ctrl.down and math.abs(vel.x + vel.z) > 1.2 then + acc = acc - 1.2 + end + end + + new_acc = vector.multiply(dir, acc) + end + + if mesecon then + boost_cart:signal_detector_rail(vector.floor(pos)) + end + + self.object:setacceleration(new_acc) + self.old_pos = vector.new(pos) + self.old_dir = vector.new(dir) + self.old_switch = last_switch + + -- Limits + for _,v in ipairs({"x","y","z"}) do + if math.abs(vel[v]) > max_vel then + vel[v] = boost_cart:get_sign(vel[v]) * max_vel + update.vel = true + end + end + + if self.punched then + -- Collect dropped items + for _,obj_ in ipairs(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 + 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_ + end + end + self.punched = false + end + + if not (update.vel or update.pos) then + return + end + + local yaw = 0 + if dir.x < 0 then + yaw = 0.5 + elseif dir.x > 0 then + yaw = 1.5 + elseif dir.z < 0 then + yaw = 1 + end + self.object:setyaw(yaw * math.pi) + + local anim = {x=0, y=0} + if dir.y == -1 then + anim = {x=1, y=1} + elseif dir.y == 1 then + anim = {x=2, y=2} + end + self.object:set_animation(anim, 1, 0) + + self.object:setvelocity(vel) + if update.pos then + self.object:setpos(pos) + end + update = nil +end + +minetest.register_entity(":carts:cart", boost_cart.cart) +minetest.register_craftitem(":carts:cart", { + description = "Cart (Sneak+Click to pick up)", + inventory_image = minetest.inventorycube("cart_top.png", "cart_side.png", "cart_side.png"), + wield_image = "cart_side.png", + 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 + + itemstack:take_item() + 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"}, + }, +}) \ No newline at end of file diff --git a/boost_cart/models/cart.png b/boost_cart/models/cart.png new file mode 100644 index 0000000..d4b12d6 Binary files /dev/null and b/boost_cart/models/cart.png differ diff --git a/boost_cart/models/cart.x b/boost_cart/models/cart.x new file mode 100644 index 0000000..3325aaf --- /dev/null +++ b/boost_cart/models/cart.x @@ -0,0 +1,339 @@ +xof 0303txt 0032 + +Frame Root { + FrameTransformMatrix { + 1.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 0.000000, 1.000000, 0.000000, + 0.000000, 1.000000,-0.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000;; + } + Frame Cube { + FrameTransformMatrix { + 5.000000, 0.000000,-0.000000, 0.000000, + -0.000000, 3.535534, 3.535534, 0.000000, + 0.000000,-3.535534, 3.535534, 0.000000, + 0.000000,-3.000000, 3.000000, 1.000000;; + } + Mesh { //Cube_001 Mesh + 72; + -1.000000; 1.000000;-1.000000;, + -1.000000;-1.000000;-1.000000;, + 1.000000;-1.000000;-1.000000;, + 1.000000; 1.000000;-1.000000;, + -0.833334;-1.000000; 1.000000;, + -1.000000;-1.000000; 1.000000;, + -1.000000;-0.833333; 1.000000;, + -0.833334;-0.833333; 1.000000;, + -1.000000;-1.000000;-1.000000;, + -1.000000;-1.000000; 1.000000;, + 0.999999;-1.000001; 1.000000;, + 1.000000;-1.000000;-1.000000;, + 0.999999;-1.000001; 1.000000;, + 0.833332;-1.000000; 1.000000;, + 0.833333;-0.833334; 1.000000;, + 1.000000;-0.833334; 1.000000;, + 0.833332;-1.000000; 1.000000;, + -0.833334;-1.000000; 1.000000;, + -0.833334;-0.833333; 1.000000;, + 0.833333;-0.833334; 1.000000;, + 1.000000; 0.833333; 1.000000;, + 0.833334; 0.833333; 1.000000;, + 0.833334; 1.000000; 1.000000;, + 1.000000; 0.999999; 1.000000;, + 1.000000;-0.833334; 1.000000;, + 0.833333;-0.833334; 1.000000;, + 0.833334; 0.833333; 1.000000;, + 1.000000; 0.833333; 1.000000;, + 0.833334; 0.833333; 1.000000;, + -0.833333; 0.833333; 1.000000;, + -0.833333; 1.000000; 1.000000;, + 0.833334; 1.000000; 1.000000;, + 0.833334; 0.833333;-0.800000;, + -0.833333; 0.833333;-0.800000;, + -0.833333; 0.833333; 1.000000;, + 0.833334; 0.833333; 1.000000;, + -0.833333; 0.833333; 1.000000;, + -1.000000; 0.833333; 1.000000;, + -1.000000; 1.000000; 1.000000;, + -0.833333; 1.000000; 1.000000;, + -0.833334;-0.833333; 1.000000;, + -1.000000;-0.833333; 1.000000;, + -1.000000; 0.833333; 1.000000;, + -0.833333; 0.833333; 1.000000;, + 0.833333;-0.833334;-0.800000;, + -0.833334;-0.833333;-0.800000;, + -0.833333; 0.833333;-0.800000;, + 0.833334; 0.833333;-0.800000;, + -0.833333; 0.833333;-0.800000;, + -0.833334;-0.833333;-0.800000;, + -0.833334;-0.833333; 1.000000;, + -0.833333; 0.833333; 1.000000;, + -0.833334;-0.833333;-0.800000;, + 0.833333;-0.833334;-0.800000;, + 0.833333;-0.833334; 1.000000;, + -0.833334;-0.833333; 1.000000;, + 0.833333;-0.833334;-0.800000;, + 0.833334; 0.833333;-0.800000;, + 0.833334; 0.833333; 1.000000;, + 0.833333;-0.833334; 1.000000;, + -1.000000; 1.000000;-1.000000;, + -1.000000; 1.000000; 1.000000;, + -1.000000;-1.000000; 1.000000;, + -1.000000;-1.000000;-1.000000;, + -1.000000; 1.000000; 1.000000;, + -1.000000; 1.000000;-1.000000;, + 1.000000; 1.000000;-1.000000;, + 1.000000; 0.999999; 1.000000;, + 1.000000;-1.000000;-1.000000;, + 0.999999;-1.000001; 1.000000;, + 1.000000; 0.999999; 1.000000;, + 1.000000; 1.000000;-1.000000;; + 18; + 4;0;1;2;3;, + 4;4;5;6;7;, + 4;8;9;10;11;, + 4;12;13;14;15;, + 4;16;17;18;19;, + 4;20;21;22;23;, + 4;24;25;26;27;, + 4;28;29;30;31;, + 4;32;33;34;35;, + 4;36;37;38;39;, + 4;40;41;42;43;, + 4;44;45;46;47;, + 4;48;49;50;51;, + 4;52;53;54;55;, + 4;56;57;58;59;, + 4;60;61;62;63;, + 4;64;65;66;67;, + 4;68;69;70;71;; + MeshNormals { //Cube_001 Normals + 72; + 0.000000; 0.000000;-1.000000;, + 0.000000; 0.000000;-1.000000;, + 0.000000; 0.000000;-1.000000;, + 0.000000; 0.000000;-1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + -0.000000;-1.000000;-0.000000;, + -0.000000;-1.000000;-0.000000;, + -0.000000;-1.000000;-0.000000;, + -0.000000;-1.000000;-0.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + -0.000000;-1.000000; 0.000000;, + -0.000000;-1.000000; 0.000000;, + -0.000000;-1.000000; 0.000000;, + -0.000000;-1.000000; 0.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 0.000000;-0.000000; 1.000000;, + 1.000000;-0.000000; 0.000000;, + 1.000000;-0.000000; 0.000000;, + 1.000000;-0.000000; 0.000000;, + 1.000000;-0.000000; 0.000000;, + 0.000000; 1.000000; 0.000000;, + 0.000000; 1.000000; 0.000000;, + 0.000000; 1.000000; 0.000000;, + 0.000000; 1.000000; 0.000000;, + -1.000000; 0.000000; 0.000000;, + -1.000000; 0.000000; 0.000000;, + -1.000000; 0.000000; 0.000000;, + -1.000000; 0.000000; 0.000000;, + -1.000000; 0.000000;-0.000000;, + -1.000000; 0.000000;-0.000000;, + -1.000000; 0.000000;-0.000000;, + -1.000000; 0.000000;-0.000000;, + 0.000000; 1.000000; 0.000000;, + 0.000000; 1.000000; 0.000000;, + 0.000000; 1.000000; 0.000000;, + 0.000000; 1.000000; 0.000000;, + 1.000000;-0.000000; 0.000000;, + 1.000000;-0.000000; 0.000000;, + 1.000000;-0.000000; 0.000000;, + 1.000000;-0.000000; 0.000000;; + 18; + 4;0;1;2;3;, + 4;4;5;6;7;, + 4;8;9;10;11;, + 4;12;13;14;15;, + 4;16;17;18;19;, + 4;20;21;22;23;, + 4;24;25;26;27;, + 4;28;29;30;31;, + 4;32;33;34;35;, + 4;36;37;38;39;, + 4;40;41;42;43;, + 4;44;45;46;47;, + 4;48;49;50;51;, + 4;52;53;54;55;, + 4;56;57;58;59;, + 4;60;61;62;63;, + 4;64;65;66;67;, + 4;68;69;70;71;; + } //End of Cube_001 Normals + MeshMaterialList { //Cube_001 Material List + 1; + 18; + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0;; + Material Material { + 0.640000; 0.640000; 0.640000; 1.000000;; + 96.078431; + 0.500000; 0.500000; 0.500000;; + 0.000000; 0.000000; 0.000000;; + TextureFilename {"cart.png";} + } + } //End of Cube_001 Material List + MeshTextureCoords { //Cube_001 UV Coordinates + 72; + 0.000000; 0.500000;, + 0.500000; 0.500000;, + 0.500000; 1.000000;, + 0.000000; 1.000000;, + 0.031250; 0.500000;, + -0.000000; 0.500000;, + -0.000000; 0.468750;, + 0.031250; 0.468750;, + 0.500000; 0.500000;, + 0.500000; 0.000000;, + 1.000000; 0.000000;, + 1.000000; 0.500000;, + 0.468750; 0.468750;, + 0.500000; 0.468750;, + 0.500000; 0.500000;, + 0.468750; 0.500000;, + 0.031250; 0.468750;, + 0.468750; 0.468750;, + 0.468750; 0.500000;, + 0.031250; 0.500000;, + 0.468750; 0.000000;, + 0.500000; 0.000000;, + 0.500000; 0.031250;, + 0.468750; 0.031250;, + 0.468750; 0.031250;, + 0.500000; 0.031250;, + 0.500000; 0.468750;, + 0.468750; 0.468750;, + 0.468750; 0.031250;, + 0.031250; 0.031250;, + 0.031250; 0.000000;, + 0.468750; 0.000000;, + 1.000000; 0.500000;, + 0.500000; 0.500000;, + 0.500000; 0.000000;, + 1.000000; 0.000000;, + 0.031250; 0.031250;, + 0.000000; 0.031250;, + 0.000000; 0.000000;, + 0.031250; 0.000000;, + 0.031250; 0.468750;, + -0.000000; 0.468750;, + 0.000000; 0.031250;, + 0.031250; 0.031250;, + 0.000000; 0.500000;, + 0.500000; 0.500000;, + 0.500000; 1.000000;, + 0.000000; 1.000000;, + 1.000000; 0.500000;, + 0.500000; 0.500000;, + 0.500000; 0.000000;, + 1.000000; 0.000000;, + 1.000000; 0.500000;, + 0.500000; 0.500000;, + 0.500000; 0.000000;, + 1.000000; 0.000000;, + 1.000000; 0.500000;, + 0.500000; 0.500000;, + 0.500000; 0.000000;, + 1.000000; 0.000000;, + 0.500000; 0.500000;, + 0.500000; 0.000000;, + 1.000000; 0.000000;, + 1.000000; 0.500000;, + 1.000000; 0.000000;, + 1.000000; 0.500000;, + 0.500000; 0.500000;, + 0.500000; 0.000000;, + 0.500000; 0.500000;, + 0.500000; 0.000000;, + 1.000000; 0.000000;, + 1.000000; 0.500000;; + } //End of Cube_001 UV Coordinates + } //End of Cube_001 Mesh + } //End of Cube +} //End of Root Frame +AnimationSet { + Animation { + {Cube} + AnimationKey { //Position + 2; + 4; + 0;3; 0.000000, 0.000000, 0.000000;;, + 1;3; 0.000000, 3.000000, 3.000000;;, + 2;3; 0.000000,-3.000000, 3.000000;;, + 3;3; 0.000000,-3.000000, 3.000000;;; + } + AnimationKey { //Rotation + 0; + 4; + 0;4; -1.000000, 0.000000, 0.000000, 0.000000;;, + 1;4; -0.923880,-0.382683,-0.000000, 0.000000;;, + 2;4; -0.923880, 0.382683, 0.000000, 0.000000;;, + 3;4; -0.923880, 0.382683, 0.000000, 0.000000;;; + } + AnimationKey { //Scale + 1; + 4; + 0;3; 5.000000, 5.000000, 5.000000;;, + 1;3; 5.000000, 5.000000, 5.000000;;, + 2;3; 5.000000, 5.000000, 5.000000;;, + 3;3; 5.000000, 5.000000, 5.000000;;; + } + } +} //End of AnimationSet diff --git a/boost_cart/rails.lua b/boost_cart/rails.lua new file mode 100644 index 0000000..02c5f48 --- /dev/null +++ b/boost_cart/rails.lua @@ -0,0 +1,104 @@ +minetest.register_node(":default:rail", { + description = "Rail", + drawtype = "raillike", + tiles = {"default_rail.png", "default_rail_curved.png", "default_rail_t_junction.png", "default_rail_crossing.png"}, + inventory_image = "default_rail.png", + wield_image = "default_rail.png", + paramtype = "light", + sunlight_propagates = true, + is_ground_content = true, + walkable = false, + selection_box = { + type = "fixed", + fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2}, + }, + groups = {dig_immediate = 2, attached_node = 1, rail = 1, connect_to_raillike = 1}, +}) + +if minetest.get_modpath("moreores") then + -- Moreores' copper rail + minetest.register_alias("carts:copperrail", "moreores:copper_rail") +else + boost_cart:register_rail(":carts:copperrail", { + description = "Copper rail", + tiles = {"carts_rail_cp.png", "carts_rail_curved_cp.png", "carts_rail_t_junction_cp.png", "carts_rail_crossing_cp.png"}, + groups = {dig_immediate = 2, attached_node = 1, rail = 1, connect_to_raillike = 1}, + }) + + minetest.register_craft({ + output = "carts:copperrail 12", + recipe = { + {"default:copper_ingot", "group:stick", "default:copper_ingot"}, + {"default:copper_ingot", "group:stick", "default:copper_ingot"}, + {"default:copper_ingot", "group:stick", "default:copper_ingot"}, + } + }) +end + +-- Speed up + +boost_cart:register_rail(":carts:powerrail", { + description = "Powered rail", + tiles = {"carts_rail_pwr.png", "carts_rail_curved_pwr.png", "carts_rail_t_junction_pwr.png", "carts_rail_crossing_pwr.png"}, + groups = {dig_immediate = 2, attached_node = 1, rail = 1, connect_to_raillike = 1}, + + after_place_node = function(pos, placer, itemstack) + if not mesecon then + minetest.get_meta(pos):set_string("cart_acceleration", "0.5") + end + end, + + mesecons = { + effector = { + action_on = function(pos, node) + boost_cart:boost_rail(pos, 0.5) + end, + + action_off = function(pos, node) + minetest.get_meta(pos):set_string("cart_acceleration", "0") + end, + }, + }, +}) + +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"}, + } +}) + +boost_cart:register_rail(":carts:brakerail", { + description = "Brake rail", + tiles = {"carts_rail_brk.png", "carts_rail_curved_brk.png", "carts_rail_t_junction_brk.png", "carts_rail_crossing_brk.png"}, + groups = {dig_immediate = 2, attached_node = 1, rail = 1, connect_to_raillike = 1}, + + after_place_node = function(pos, placer, itemstack) + if not mesecon then + minetest.get_meta(pos):set_string("cart_acceleration", "-0.2") + end + end, + + mesecons = { + effector = { + action_on = function(pos, node) + boost_cart:boost_rail(pos, -0.2) + end, + + action_off = function(pos, node) + minetest.get_meta(pos):set_string("cart_acceleration", "0") + end, + }, + }, +}) + +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"}, + } +}) \ No newline at end of file diff --git a/boost_cart/textures/cart_bottom.png b/boost_cart/textures/cart_bottom.png new file mode 100644 index 0000000..e74ef2b Binary files /dev/null and b/boost_cart/textures/cart_bottom.png differ diff --git a/boost_cart/textures/cart_side.png b/boost_cart/textures/cart_side.png new file mode 100644 index 0000000..1bd55e7 Binary files /dev/null and b/boost_cart/textures/cart_side.png differ diff --git a/boost_cart/textures/cart_top.png b/boost_cart/textures/cart_top.png new file mode 100644 index 0000000..b763025 Binary files /dev/null and b/boost_cart/textures/cart_top.png differ diff --git a/boost_cart/textures/carts_rail_brk.png b/boost_cart/textures/carts_rail_brk.png new file mode 100644 index 0000000..2717bd5 Binary files /dev/null and b/boost_cart/textures/carts_rail_brk.png differ diff --git a/boost_cart/textures/carts_rail_cp.png b/boost_cart/textures/carts_rail_cp.png new file mode 100644 index 0000000..119461f Binary files /dev/null and b/boost_cart/textures/carts_rail_cp.png differ diff --git a/boost_cart/textures/carts_rail_crossing_brk.png b/boost_cart/textures/carts_rail_crossing_brk.png new file mode 100644 index 0000000..f9ce303 Binary files /dev/null and b/boost_cart/textures/carts_rail_crossing_brk.png differ diff --git a/boost_cart/textures/carts_rail_crossing_cp.png b/boost_cart/textures/carts_rail_crossing_cp.png new file mode 100644 index 0000000..b04aa63 Binary files /dev/null and b/boost_cart/textures/carts_rail_crossing_cp.png differ diff --git a/boost_cart/textures/carts_rail_crossing_dtc.png b/boost_cart/textures/carts_rail_crossing_dtc.png new file mode 100644 index 0000000..cf04f0f Binary files /dev/null and b/boost_cart/textures/carts_rail_crossing_dtc.png differ diff --git a/boost_cart/textures/carts_rail_crossing_dtc_on.png b/boost_cart/textures/carts_rail_crossing_dtc_on.png new file mode 100644 index 0000000..b6f5b87 Binary files /dev/null and b/boost_cart/textures/carts_rail_crossing_dtc_on.png differ diff --git a/boost_cart/textures/carts_rail_crossing_pwr.png b/boost_cart/textures/carts_rail_crossing_pwr.png new file mode 100644 index 0000000..dc317cf Binary files /dev/null and b/boost_cart/textures/carts_rail_crossing_pwr.png differ diff --git a/boost_cart/textures/carts_rail_curved_brk.png b/boost_cart/textures/carts_rail_curved_brk.png new file mode 100644 index 0000000..c55183d Binary files /dev/null and b/boost_cart/textures/carts_rail_curved_brk.png differ diff --git a/boost_cart/textures/carts_rail_curved_cp.png b/boost_cart/textures/carts_rail_curved_cp.png new file mode 100644 index 0000000..004ef56 Binary files /dev/null and b/boost_cart/textures/carts_rail_curved_cp.png differ diff --git a/boost_cart/textures/carts_rail_curved_dtc.png b/boost_cart/textures/carts_rail_curved_dtc.png new file mode 100644 index 0000000..8117c27 Binary files /dev/null and b/boost_cart/textures/carts_rail_curved_dtc.png differ diff --git a/boost_cart/textures/carts_rail_curved_dtc_on.png b/boost_cart/textures/carts_rail_curved_dtc_on.png new file mode 100644 index 0000000..032630f Binary files /dev/null and b/boost_cart/textures/carts_rail_curved_dtc_on.png differ diff --git a/boost_cart/textures/carts_rail_curved_pwr.png b/boost_cart/textures/carts_rail_curved_pwr.png new file mode 100644 index 0000000..4aef5dd Binary files /dev/null and b/boost_cart/textures/carts_rail_curved_pwr.png differ diff --git a/boost_cart/textures/carts_rail_dtc.png b/boost_cart/textures/carts_rail_dtc.png new file mode 100644 index 0000000..5e2ccef Binary files /dev/null and b/boost_cart/textures/carts_rail_dtc.png differ diff --git a/boost_cart/textures/carts_rail_dtc_on.png b/boost_cart/textures/carts_rail_dtc_on.png new file mode 100644 index 0000000..e81dbe1 Binary files /dev/null and b/boost_cart/textures/carts_rail_dtc_on.png differ diff --git a/boost_cart/textures/carts_rail_pwr.png b/boost_cart/textures/carts_rail_pwr.png new file mode 100644 index 0000000..f346a02 Binary files /dev/null and b/boost_cart/textures/carts_rail_pwr.png differ diff --git a/boost_cart/textures/carts_rail_t_junction_brk.png b/boost_cart/textures/carts_rail_t_junction_brk.png new file mode 100644 index 0000000..5689ffe Binary files /dev/null and b/boost_cart/textures/carts_rail_t_junction_brk.png differ diff --git a/boost_cart/textures/carts_rail_t_junction_cp.png b/boost_cart/textures/carts_rail_t_junction_cp.png new file mode 100644 index 0000000..3da9094 Binary files /dev/null and b/boost_cart/textures/carts_rail_t_junction_cp.png differ diff --git a/boost_cart/textures/carts_rail_t_junction_dtc.png b/boost_cart/textures/carts_rail_t_junction_dtc.png new file mode 100644 index 0000000..b154f43 Binary files /dev/null and b/boost_cart/textures/carts_rail_t_junction_dtc.png differ diff --git a/boost_cart/textures/carts_rail_t_junction_dtc_on.png b/boost_cart/textures/carts_rail_t_junction_dtc_on.png new file mode 100644 index 0000000..9fda111 Binary files /dev/null and b/boost_cart/textures/carts_rail_t_junction_dtc_on.png differ diff --git a/boost_cart/textures/carts_rail_t_junction_pwr.png b/boost_cart/textures/carts_rail_t_junction_pwr.png new file mode 100644 index 0000000..d7edaf1 Binary files /dev/null and b/boost_cart/textures/carts_rail_t_junction_pwr.png differ diff --git a/boost_cart/textures/default_rail_t_junction.png b/boost_cart/textures/default_rail_t_junction.png new file mode 100644 index 0000000..fe62905 Binary files /dev/null and b/boost_cart/textures/default_rail_t_junction.png differ -- cgit v1.2.3