From db4eca8b7370a8754d2ce916ac36464fb691091c Mon Sep 17 00:00:00 2001 From: minertestdude <43986027+minertestdude@users.noreply.github.com> Date: Sat, 11 Apr 2020 15:02:05 +0200 Subject: MineClone2 support for Elevator mod and few improvements (#13) * deprecating outdated file * Add files via upload * Mineclone2 compatibility, externalization of few settings, inability to break by hand - integrated full Mineclone2 game compatibility layer - externalized elevator settings (easier upgrades for server owners) - turn off the ability to destroy shafts by hand, as this could lead to accidents * Add mineclone textures These textures are MIT licensed and motor texture is done by me, likewise MIT. License added. * Add license about mineclone2 variant of textures * Update readme with support information about Mineclone2. * This should finally nail the correct groups for mineclone2. Sorry. --- LICENSE.txt | 10 +++ README.md | 2 +- components.lua | 132 +++++++++++++++++++++++++--------------- crafts.lua | 30 ++++++++- depends.txt | 5 -- init.lua | 6 +- mod.conf | 4 +- settingtypes.txt | 8 +++ textures/elevator_box_mcl.png | Bin 0 -> 209 bytes textures/elevator_motor_mcl.png | Bin 0 -> 373 bytes textures/elevator_shaft_mcl.png | Bin 0 -> 209 bytes 11 files changed, 136 insertions(+), 61 deletions(-) delete mode 100644 depends.txt create mode 100644 settingtypes.txt create mode 100644 textures/elevator_box_mcl.png create mode 100644 textures/elevator_motor_mcl.png create mode 100644 textures/elevator_shaft_mcl.png diff --git a/LICENSE.txt b/LICENSE.txt index 2a0794c..aa52b25 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -13,3 +13,13 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +---- +Elevator motor and elevator textures for MCL2 are based on "default_glass.png", +included with MCL2 game, original copyright: +"MIT License. + +The textures are taken from the Minecraft resource pack “Faithful 1.11” by +Vattic and xMrVizzy and contributers." + +Elevator motor design is (c) minertestdude, redistributed under MIT license. diff --git a/README.md b/README.md index 999e65c..fdf670a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Realtime Elevators for Minetest ## Dependencies -This mod has no dependencies other than default, but has recipes designed for use with technic and either homedecor/chains (for chains) or farming redo (for rope) and will detect if those are installed. +This mod has no dependencies other than default, but has recipes designed for use with technic and either homedecor/chains (for chains) or farming redo (for rope) and will detect if those are installed. This mod supports MineClone 2 game. ## Usage Each shaft begins with a motor, and extends down through shaft and elevator nodes. Each elevator node can be used to travel to any other elevator node below the motor and through an unbroken shaft. Only one player can use each shaft at once. diff --git a/components.lua b/components.lua index 7c182ae..b0d997b 100644 --- a/components.lua +++ b/components.lua @@ -3,6 +3,10 @@ local phash = elevator.phash local get_node = elevator.get_node local homedecor_path = minetest.get_modpath("homedecor") +local mineclone_path = core.get_modpath("mcl_core") and mcl_core +local default_path = core.get_modpath("default") and default + +local moditems = {} -- local table to hold substitutes -- Use homedecor's placeholder if possible. if homedecor_path then @@ -33,15 +37,36 @@ else }) end +if mineclone_path then + moditems.el_shaft_groups = {pickaxey=1,axey=1,handy=1,swordy=1,transport=1,dig_by_piston=1} + moditems.el_motor_groups = {pickaxey=1,axey=1,handy=1,swordy=1,transport=1,dig_by_piston=1} + moditems.elevator_groups = {pickaxey=1,axey=1,handy=1,swordy=1,transport=1,dig_by_piston=1} + moditems.elevator_special_groups = {not_in_creative_inventory=1,pickaxey=1,axey=1,handy=1,swordy=1,transport=1,dig_by_piston=1} + moditems.sounds_stone = mcl_sounds.node_sound_stone_defaults + moditems.el_motor_gfx = "elevator_motor_mcl.png" + moditems.el_shaft_gfx = "elevator_shaft_mcl.png" + moditems.el_box_gfx = "elevator_box_mcl.png" + +elseif default_path then + moditems.el_shaft_groups = {cracky=2,oddly_breakable_by_hand=0} -- removing ability to destroy by hand to prevent accidental breakage of whole elevators + moditems.el_motor_groups = {cracky=1} + moditems.elevator_groups = {cracky=1,choppy=1,snappy=1} + moditems.elevator_special_groups = {not_in_creative_inventory=1} + moditems.sounds_stone = default.node_sound_stone_defaults + moditems.el_motor_gfx = "elevator_motor.png" + moditems.el_shaft_gfx = "elevator_shaft.png" + moditems.el_box_gfx = "elevator_box.png" +end + minetest.register_node("elevator:shaft", { description = "Elevator Shaft", - tiles = { "elevator_shaft.png" }, + tiles = { moditems.el_shaft_gfx }, drawtype = "nodebox", paramtype = "light", on_rotate = screwdriver.disallow, sunlight_propagates = true, - groups = {cracky=2, oddly_breakable_by_hand=1}, - sounds = default.node_sound_stone_defaults(), + groups = moditems.el_shaft_groups, + sounds = moditems.sounds_stone(), node_box = { type = "fixed", fixed = { @@ -68,6 +93,40 @@ minetest.register_node("elevator:shaft", { -- Remove boxes and deactivate elevators below us. elevator.unbuild(pos, 1) end, + _mcl_blast_resistance = 15, -- mineclone2 specific + _mcl_hardness = 5, -- mineclone2 specific + }) + +minetest.register_node("elevator:motor", { + description = "Elevator Motor", + tiles = { + "default_steel_block.png", + "default_steel_block.png", + moditems.el_motor_gfx, + moditems.el_motor_gfx, + moditems.el_motor_gfx, + moditems.el_motor_gfx, + }, + groups = moditems.el_motor_groups, + sounds = moditems.sounds_stone(), + after_place_node = function(pos, placer, itemstack) + -- Set up the motor table. + elevator.motors[phash(pos)] = { + elevators = {}, + pnames = {}, + labels = {}, + } + elevator.save_elevator() + elevator.build_motor(phash(pos)) + end, + on_destruct = function(pos) + -- Destroy everything related to this motor. + elevator.boxes[phash(pos)] = nil + elevator.motors[phash(pos)] = nil + elevator.save_elevator() + end, + _mcl_blast_resistance = 15, -- mineclone2 specific + _mcl_hardness = 5, -- mineclone2 specific }) local box = { @@ -105,44 +164,16 @@ minetest.register_node("elevator:elevator_box", { tiles = { "default_steel_block.png", "default_steel_block.png", - "elevator_box.png", - "elevator_box.png", - "elevator_box.png", - "elevator_box.png", + moditems.el_box_gfx, + moditems.el_box_gfx, + moditems.el_box_gfx, + moditems.el_box_gfx, }, - groups = {not_in_creative_inventory = 1}, + groups = moditems.elevator_special_groups, light_source = 4, -}) - -minetest.register_node("elevator:motor", { - description = "Elevator Motor", - tiles = { - "default_steel_block.png", - "default_steel_block.png", - "elevator_motor.png", - "elevator_motor.png", - "elevator_motor.png", - "elevator_motor.png", - }, - groups = {cracky=1}, - sounds = default.node_sound_stone_defaults(), - after_place_node = function(pos, placer, itemstack) - -- Set up the motor table. - elevator.motors[phash(pos)] = { - elevators = {}, - pnames = {}, - labels = {}, - } - elevator.save_elevator() - elevator.build_motor(phash(pos)) - end, - on_destruct = function(pos) - -- Destroy everything related to this motor. - elevator.boxes[phash(pos)] = nil - elevator.motors[phash(pos)] = nil - elevator.save_elevator() - end, + _mcl_blast_resistance = 15, -- mineclone2 specific + _mcl_hardness = 5, -- mineclone2 specific }) for _,mode in ipairs({"on", "off"}) do @@ -201,19 +232,19 @@ for _,mode in ipairs({"on", "off"}) do tiles = on and { "default_steel_block.png", "default_steel_block.png", - "elevator_box.png", - "elevator_box.png", - "elevator_box.png", - "elevator_box.png", + moditems.el_box_gfx, + moditems.el_box_gfx, + moditems.el_box_gfx, + moditems.el_box_gfx, } or { - "elevator_box.png", - "elevator_box.png", - "elevator_box.png", - "elevator_box.png", - "elevator_box.png", - "elevator_box.png", + moditems.el_box_gfx, + moditems.el_box_gfx, + moditems.el_box_gfx, + moditems.el_box_gfx, + moditems.el_box_gfx, + moditems.el_box_gfx, }, - groups = {cracky=1, choppy=1, snappy=1}, + groups = moditems.elevator_groups, drop = "elevator:elevator_off", -- Emit a bit of light when active. @@ -327,6 +358,9 @@ for _,mode in ipairs({"on", "off"}) do minetest.remove_node(p) end end, + + _mcl_blast_resistance = 15, -- mineclone2 specific + _mcl_hardness = 5, -- mineclone2 specific }) end diff --git a/crafts.lua b/crafts.lua index 5f5831a..06cfa6e 100644 --- a/crafts.lua +++ b/crafts.lua @@ -1,8 +1,36 @@ -- Detect optional mods. local technic_path = minetest.get_modpath("technic") local chains_path = minetest.get_modpath("chains") +local mineclone_path = core.get_modpath("mcl_core") and mcl_core -if technic_path and chains_path then +if mineclone_path then + minetest.register_craft({ + output = "elevator:elevator", + recipe = { + {"mcl_core:iron_ingot", "mcl_core:paper", "mcl_core:iron_ingot"}, + {"mcl_core:iron_ingot", "mcl_core:gold_ingot", "mcl_core:iron_ingot"}, + {"mcl_core:clay_lump", "group:glass", "mcl_core:clay_lump"}, + }, + }) + + minetest.register_craft({ + output = "elevator:shaft", + recipe = { + {"mcl_core:iron_ingot", "group:wood"}, + {"group:wood", "mcl_core:iron_ingot"}, + }, + }) + + minetest.register_craft({ + output = "elevator:motor", + recipe = { + {"mcl_core:gold_ingot", "mcl_core:iron_ingot", "mcl_core:gold_ingot"}, + {"mcl_core:ironblock", "mcl_furnaces:furnace", "mcl_core:ironblock"}, + {"mcl_core:paper", "mcl_core:gold_ingot", "mcl_core:paper"} + }, + }) + +elseif technic_path and chains_path then minetest.register_craft({ output = "elevator:elevator", recipe = { diff --git a/depends.txt b/depends.txt deleted file mode 100644 index 6796bf4..0000000 --- a/depends.txt +++ /dev/null @@ -1,5 +0,0 @@ -default -technic? -homedecor? -chains? -farming? diff --git a/init.lua b/init.lua index b462b5b..b2eb03e 100644 --- a/init.lua +++ b/init.lua @@ -5,11 +5,11 @@ local armor_path = minetest.get_modpath("3d_armor") -- contains .motors loaded from mod storage -- runtime variables and api functions elevator = { - SPEED = 10, -- Initial speed of a box. - ACCEL = 0.1, -- Acceleration of a box. + SPEED = minetest.settings:get("elevator_speed") or 10, -- Initial speed of a box. + ACCEL = minetest.settings:get("elevator_accel") or 0.1, -- Acceleration of a box. VISUAL_INCREASE = 1.75, VERSION = 8, -- Elevator interface/database version. - PTIMEOUT = 120, -- Maximum time a box can go without players nearby. + PTIMEOUT = minetest.settings:get("elevator_time") or 120, -- Maximum time a box can go without players nearby. boxes = {}, -- Elevator boxes in action. lastboxes = {}, -- Player near box timeout. diff --git a/mod.conf b/mod.conf index b86b042..99537e3 100644 --- a/mod.conf +++ b/mod.conf @@ -1,3 +1,3 @@ name = elevator -depends = default -optional_depends = technic, homedecor, chains, farming +description = An entity-based elevator allowing fast realtime travel in Minetest. Supports Minetest Game and MineClone2. +optional_depends = default, technic, homedecor, chains, farming, mcl_core, mcl_sounds diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..d950bbb --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1,8 @@ +# Initial speed of the box +elevator_speed (Initial elevator speed) float 10 + +# Acceleration of the box +elevator_accel (Elevator acceleration) float 0.1 + +# Maximum time a box can go without players nearby. +elevator_time (Maximum idle time without players) int 120 diff --git a/textures/elevator_box_mcl.png b/textures/elevator_box_mcl.png new file mode 100644 index 0000000..827662f Binary files /dev/null and b/textures/elevator_box_mcl.png differ diff --git a/textures/elevator_motor_mcl.png b/textures/elevator_motor_mcl.png new file mode 100644 index 0000000..7e7d168 Binary files /dev/null and b/textures/elevator_motor_mcl.png differ diff --git a/textures/elevator_shaft_mcl.png b/textures/elevator_shaft_mcl.png new file mode 100644 index 0000000..f9f1826 Binary files /dev/null and b/textures/elevator_shaft_mcl.png differ -- cgit v1.2.3