diff --git a/tubelib_addons1/nodes.lua b/tubelib_addons1/nodes.lua index 87c892a..a956aff 100644 --- a/tubelib_addons1/nodes.lua +++ b/tubelib_addons1/nodes.lua @@ -118,7 +118,7 @@ end ------------------------------------------------------------------------------- -- Ethereal Farming ------------------------------------------------------------------------------- -fn("ethereal:strawberry_8", "ethereal:strawberry 2", "ethereal:strawberry 1") +fn("ethereal:strawberry_8", "ethereal:strawberry 2", "ethereal:strawberry_1") fn("ethereal:onion_5", "ethereal:wild_onion_plant 2", "ethereal:onion_1") diff --git a/tubelib_addons2/locale/template.txt b/tubelib_addons2/locale/template.txt index 1228f9a..1eecfc2 100644 --- a/tubelib_addons2/locale/template.txt +++ b/tubelib_addons2/locale/template.txt @@ -1,6 +1,7 @@ # textdomain: tubelib_addons2 + ### accesscontrol.lua ### Access code (4 digits):= diff --git a/tubelib_addons3/chest_cart.lua b/tubelib_addons3/chest_cart.lua new file mode 100644 index 0000000..5332f3d --- /dev/null +++ b/tubelib_addons3/chest_cart.lua @@ -0,0 +1,171 @@ +--[[ + + Tubelib Addons 3 + ================ + + Copyright (C) 2017-2020 Joachim Stolberg + + AGPL v3 + See LICENSE.txt for more information + + chest.lua + + A high performance chest + +]]-- + +-- Load support for I18n +local S = tubelib_addons3.S + +local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end +local S2P = minetest.string_to_pos +local M = minetest.get_meta + +local function on_rightclick(pos, node, clicker) + if clicker and clicker:is_player() then + if M(pos):get_int("userID") == 0 then + minecart.show_formspec(pos, clicker) + end + end +end + +local function formspec() + return "size[8,6]".. + default.gui_bg.. + default.gui_bg_img.. + default.gui_slots.. + "list[context;main;3,0;2,2;]".. + "list[current_player;main;0,2.3;8,4;]".. + "listring[context;main]".. + "listring[current_player;main]" +end + +local function allow_metadata_inventory_put(pos, listname, index, stack, player) + local owner = M(pos):get_string("owner") + if owner ~= "" and owner ~= player:get_player_name() then + return 0 + end + return stack:get_count() +end + +local function allow_metadata_inventory_take(pos, listname, index, stack, player) + local owner = M(pos):get_string("owner") + if owner ~= "" and owner ~= player:get_player_name() then + return 0 + end + return stack:get_count() +end + +minetest.register_node("tubelib_addons3:chest_cart", { + description = S("TA Chest Cart"), + tiles = { + -- up, down, right, left, back, front + "tubelib_addons3_chest_cart_top.png", + "tubelib_addons3_chest_cart_bottom.png", + "tubelib_addons3_chest_cart_side.png", + "tubelib_addons3_chest_cart_side.png", + "tubelib_addons3_chest_cart_front.png", + "tubelib_addons3_chest_cart_front.png", + }, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-7/16, 3/16, -7/16, 7/16, 8/16, 7/16}, + {-8/16, -8/16, -8/16, 8/16, 3/16, 8/16}, + }, + }, + paramtype2 = "facedir", + paramtype = "light", + use_texture_alpha = true, + sunlight_propagates = true, + is_ground_content = false, + groups = {cracky = 2, crumbly = 2, choppy = 2}, + node_placement_prediction = "", + diggable = false, + + on_place = minecart.on_nodecart_place, + on_punch = minecart.on_nodecart_punch, + allow_metadata_inventory_put = allow_metadata_inventory_put, + allow_metadata_inventory_take = allow_metadata_inventory_take, + on_rightclick = on_rightclick, + + after_place_node = function(pos, placer) + local inv = M(pos):get_inventory() + inv:set_size('main', 4) + if placer and placer:is_player() then + minecart.show_formspec(pos, placer) + else + M(pos):set_string("formspec", formspec()) + end + end, + + set_cargo = function(pos, data) + local inv = M(pos):get_inventory() + for idx, stack in ipairs(data) do + inv:set_stack("main", idx, stack) + end + end, + + get_cargo = function(pos) + local inv = M(pos):get_inventory() + local data = {} + for idx = 1, 4 do + local stack = inv:get_stack("main", idx) + data[idx] = {name = stack:get_name(), count = stack:get_count()} + end + return data + end, + + has_cargo = function(pos) + local inv = minetest.get_meta(pos):get_inventory() + return not inv:is_empty("main") + end +}) + +minecart.register_cart_entity("tubelib_addons3:chest_cart_entity", "tubelib_addons3:chest_cart", "chest", { + initial_properties = { + physical = false, + collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, + visual = "wielditem", + textures = {"tubelib_addons3:chest_cart"}, + visual_size = {x=0.66, y=0.66, z=0.66}, + static_save = false, + }, +}) + +tubelib.register_node("tubelib_addons3:chest_cart", {}, { + on_pull_stack = function(pos, side) + local meta = minetest.get_meta(pos) + return tubelib.get_stack(meta, "main") + end, + on_pull_item = function(pos, side) + local meta = minetest.get_meta(pos) + return tubelib.get_item(meta, "main") + end, + on_push_item = function(pos, side, item) + local meta = minetest.get_meta(pos) + return tubelib.put_item(meta, "main", item) + end, + on_unpull_item = function(pos, side, item) + local meta = minetest.get_meta(pos) + return tubelib.put_item(meta, "main", item) + end, + + on_recv_message = function(pos, topic, payload) + if topic == "state" then + local meta = minetest.get_meta(pos) + return tubelib.get_inv_state(meta, "main") + else + return "unsupported" + end + end, +}) + +minetest.register_craft({ + output = "tubelib_addons3:chest_cart", + recipe = { + {"default:junglewood", "default:chest_locked", "default:junglewood"}, + {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}, + }, +}) diff --git a/tubelib_addons3/init.lua b/tubelib_addons3/init.lua index dd2beca..5f0d5a3 100644 --- a/tubelib_addons3/init.lua +++ b/tubelib_addons3/init.lua @@ -21,3 +21,7 @@ dofile(minetest.get_modpath("tubelib_addons3") .. '/distributor.lua') dofile(minetest.get_modpath("tubelib_addons3") .. '/pushing_chest.lua') dofile(minetest.get_modpath("tubelib_addons3") .. '/teleporter.lua') dofile(minetest.get_modpath("tubelib_addons3") .. '/funnel.lua') + +if minetest.global_exists("minecart") then + dofile(minetest.get_modpath("tubelib_addons3") .. '/chest_cart.lua') +end diff --git a/tubelib_addons3/locale/template.txt b/tubelib_addons3/locale/template.txt index c8b3db1..dca4125 100644 --- a/tubelib_addons3/locale/template.txt +++ b/tubelib_addons3/locale/template.txt @@ -7,6 +7,10 @@ HighPerf Chest= connected with= +### chest_cart.lua ### + +TA Chest Cart= + ### distributor.lua ### HighPerf Distributor= diff --git a/tubelib_addons3/locale/tubelib_addons3.de.tr b/tubelib_addons3/locale/tubelib_addons3.de.tr index ccd8084..9137367 100644 --- a/tubelib_addons3/locale/tubelib_addons3.de.tr +++ b/tubelib_addons3/locale/tubelib_addons3.de.tr @@ -7,6 +7,10 @@ HighPerf Chest=HighPerf Kiste connected with=verbunden mit +### chest_cart.lua ### + +TA Chest Cart=TA Kistenwagen + ### distributor.lua ### HighPerf Distributor=HighPerf Verteiler diff --git a/tubelib_addons3/mod.conf b/tubelib_addons3/mod.conf index cd72536..18f1527 100644 --- a/tubelib_addons3/mod.conf +++ b/tubelib_addons3/mod.conf @@ -1,3 +1,4 @@ name=tubelib_addons3 description=Tubelib Extension with High Performance nodes -depends=tubelib,tubelib_addons1,default +depends=tubelib,tubelib_addons1,default +optional_depends=minecart diff --git a/tubelib_addons3/textures/tubelib_addons3_chest_cart_bottom.png b/tubelib_addons3/textures/tubelib_addons3_chest_cart_bottom.png new file mode 100644 index 0000000..7aa750f Binary files /dev/null and b/tubelib_addons3/textures/tubelib_addons3_chest_cart_bottom.png differ diff --git a/tubelib_addons3/textures/tubelib_addons3_chest_cart_front.png b/tubelib_addons3/textures/tubelib_addons3_chest_cart_front.png new file mode 100644 index 0000000..3bf8f76 Binary files /dev/null and b/tubelib_addons3/textures/tubelib_addons3_chest_cart_front.png differ diff --git a/tubelib_addons3/textures/tubelib_addons3_chest_cart_side.png b/tubelib_addons3/textures/tubelib_addons3_chest_cart_side.png new file mode 100644 index 0000000..d04b4aa Binary files /dev/null and b/tubelib_addons3/textures/tubelib_addons3_chest_cart_side.png differ diff --git a/tubelib_addons3/textures/tubelib_addons3_chest_cart_top.png b/tubelib_addons3/textures/tubelib_addons3_chest_cart_top.png new file mode 100644 index 0000000..646f9ec Binary files /dev/null and b/tubelib_addons3/textures/tubelib_addons3_chest_cart_top.png differ