Add a chest_cart for the mod minecart

This commit is contained in:
Joachim Stolberg 2021-06-06 11:16:10 +02:00
parent 71f67e881b
commit 4fa8db9042
11 changed files with 187 additions and 2 deletions

@ -118,7 +118,7 @@ end
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- Ethereal Farming -- 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") fn("ethereal:onion_5", "ethereal:wild_onion_plant 2", "ethereal:onion_1")

@ -1,6 +1,7 @@
# textdomain: tubelib_addons2 # textdomain: tubelib_addons2
### accesscontrol.lua ### ### accesscontrol.lua ###
Access code (4 digits):= Access code (4 digits):=

@ -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"},
},
})

@ -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") .. '/pushing_chest.lua')
dofile(minetest.get_modpath("tubelib_addons3") .. '/teleporter.lua') dofile(minetest.get_modpath("tubelib_addons3") .. '/teleporter.lua')
dofile(minetest.get_modpath("tubelib_addons3") .. '/funnel.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

@ -7,6 +7,10 @@
HighPerf Chest= HighPerf Chest=
connected with= connected with=
### chest_cart.lua ###
TA Chest Cart=
### distributor.lua ### ### distributor.lua ###
HighPerf Distributor= HighPerf Distributor=

@ -7,6 +7,10 @@
HighPerf Chest=HighPerf Kiste HighPerf Chest=HighPerf Kiste
connected with=verbunden mit connected with=verbunden mit
### chest_cart.lua ###
TA Chest Cart=TA Kistenwagen
### distributor.lua ### ### distributor.lua ###
HighPerf Distributor=HighPerf Verteiler HighPerf Distributor=HighPerf Verteiler

@ -1,3 +1,4 @@
name=tubelib_addons3 name=tubelib_addons3
description=Tubelib Extension with High Performance nodes description=Tubelib Extension with High Performance nodes
depends=tubelib,tubelib_addons1,default depends=tubelib,tubelib_addons1,default
optional_depends=minecart

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B