From af62f41ce1e458b85089bc1bcdd90bbde1c73e67 Mon Sep 17 00:00:00 2001 From: Kiri Eda Date: Sun, 28 May 2017 18:55:41 +0200 Subject: [PATCH] Make node references absolute. Accomodate different top directory name. --- detector.lua | 16 ++++++++-------- init.lua | 12 +++++------- rails.lua | 4 ++-- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/detector.lua b/detector.lua index f345ac6..6e7bf26 100644 --- a/detector.lua +++ b/detector.lua @@ -3,8 +3,8 @@ 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}) + 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 @@ -16,14 +16,14 @@ function boost_cart:signal_detector_rail(pos) return end - if node.name == "boost_cart:detectorrail" then - minetest.swap_node(pos, {name = "boost_cart:detectorrail_on", param2=node.param2}) + 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", { +boost_cart:register_rail(":boost_cart:detectorrail", { description = "Detector rail", tiles = { "carts_rail_straight_dtc.png", "carts_rail_curved_dtc.png", @@ -34,7 +34,7 @@ boost_cart:register_rail("boost_cart:detectorrail", { mesecons = {receptor = {state = "off", rules = mesecons_rules}}, }) -boost_cart:register_rail("boost_cart:detectorrail_on", { +boost_cart:register_rail(":boost_cart:detectorrail_on", { description = "Detector rail ON (you hacker you)", tiles = { "carts_rail_straight_dtc_on.png", "carts_rail_curved_dtc_on.png", @@ -43,13 +43,13 @@ boost_cart:register_rail("boost_cart:detectorrail_on", { groups = boost_cart:get_rail_groups({ detector_rail = 1, not_in_creative_inventory = 1 }), - drop = "boost_cart:detectorrail", + drop = ":boost_cart:detectorrail", mesecons = {receptor = {state = "on", rules = mesecons_rules}}, }) minetest.register_craft({ - output = "boost_cart:detectorrail 6", + output = ":boost_cart:detectorrail 6", recipe = { {"default:steel_ingot", "mesecons:wire_00000000_off", "default:steel_ingot"}, {"default:steel_ingot", "group:stick", "default:steel_ingot"}, diff --git a/init.lua b/init.lua index 7dd5c44..276e3dd 100644 --- a/init.lua +++ b/init.lua @@ -1,16 +1,14 @@ - +modDirectory = "boostcart" boost_cart = {} -boost_cart.modpath = minetest.get_modpath("boost_cart") +boost_cart.modpath = minetest.get_modpath(modDirectory) -- Maximal speed of the cart in m/s boost_cart.speed_max = 10 -- Set to -1 to disable punching the cart from inside boost_cart.punch_speed_max = 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") + error("\nWrong mod directory name! Please change it to '" ..modDirectory.. "'.\nSee also: http://dev.minetest.net/Installing_Mods") end -- Support for non-default games @@ -24,8 +22,8 @@ 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") +-- 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 diff --git a/rails.lua b/rails.lua index a03961b..9fc3328 100644 --- a/rails.lua +++ b/rails.lua @@ -106,7 +106,7 @@ minetest.register_craft({ } }) -boost_cart:register_rail("boost_cart:startstoprail", { +boost_cart:register_rail(":boost_cart:startstoprail", { description = "Start-stop rail", tiles = { "carts_rail_straight_ss.png", "carts_rail_curved_ss.png", @@ -132,6 +132,6 @@ boost_cart:register_rail("boost_cart:startstoprail", { minetest.register_craft({ type = "shapeless", - output = "boost_cart:startstoprail 2", + output = ":boost_cart:startstoprail 2", recipe = {"carts:powerrail", "carts:brakerail"}, })