Created
January 2, 2017 15:35
-
-
Save octacian/f990c5996b008bd0dc6f5e9d10370520 to your computer and use it in GitHub Desktop.
ME Chest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- microexpansion/machines.lua | |
local chest_formspec = | |
"size[8,10]" .. | |
default.gui_bg .. | |
default.gui_bg_img .. | |
default.gui_slots .. | |
"list[current_name;main;0,0.3;8,4;]" .. | |
"list[current_player;main;0,5.5;8,1;]" .. | |
"list[current_player;main;0,6.73;8,3;8]" .. | |
"button[5.4,4.35;0.8,0.9;prev;<]" .. | |
"button[7.25,4.35;0.8,0.9;next;>]" .. | |
"field[0.3,4.6;2.2,1;filter;;]" .. | |
"button[2.1,4.5;0.8,0.5;search;?]" .. | |
"button[2.75,4.5;0.8,0.5;clear;X]" .. | |
"tooltip[search;Search]" .. | |
"tooltip[clear;Reset]" .. | |
"listring[current_name;main]" .. | |
"listring[current_player;main]" .. | |
"field_close_on_enter[filter;false]" .. | |
default.get_hotbar_bg(0,5.50) | |
-- ME chest | |
minetest.register_node("microexpansion:chest", { | |
description = "ME Chest\ncan interact with ME drives", | |
tiles = { | |
"microexpansion_chest_top.png", | |
"microexpansion_chest_top.png", | |
"microexpansion_chest_side.png", | |
"microexpansion_chest_side.png", | |
"microexpansion_chest_side.png", | |
"microexpansion_chest_front.png", | |
}, | |
is_ground_content = false, | |
groups = { cracky = 1 }, | |
paramtype = "light", | |
paramtype2 = "facedir", | |
on_receive_fields = function(pos, formname, fields, sender) | |
local name = sender:get_player_name() | |
end, | |
on_construct = function(pos) | |
local meta = minetest.get_meta(pos) | |
meta:set_string("formspec", chest_formspec) | |
local inv = meta:get_inventory() | |
inv:set_size("main", 8*4) | |
end, | |
can_dig = function(pos, player) | |
local meta = minetest.get_meta(pos); | |
local inv = meta:get_inventory() | |
return inv:is_empty("main") | |
end, | |
on_metadata_inventory_move = function(pos, from_list, from_index, | |
to_list, to_index, count, player) | |
minetest.log("action", player:get_player_name() .. | |
" moves stuff in chest at " .. minetest.pos_to_string(pos)) | |
end, | |
on_metadata_inventory_put = function(pos, listname, index, stack, player) | |
minetest.log("action", player:get_player_name() .. | |
" moves " .. stack:get_name() .. | |
" to chest at " .. minetest.pos_to_string(pos)) | |
end, | |
on_metadata_inventory_take = function(pos, listname, index, stack, player) | |
minetest.log("action", player:get_player_name() .. | |
" takes " .. stack:get_name() .. | |
" from chest at " .. minetest.pos_to_string(pos)) | |
end, | |
on_blast = function(pos) | |
local drops = {} | |
default.get_inventory_drops(pos, "main", drops) | |
drops[#drops+1] = "default:chest" | |
minetest.remove_node(pos) | |
return drops | |
end, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment