summaryrefslogtreecommitdiff
path: root/currency
diff options
context:
space:
mode:
Diffstat (limited to 'currency')
-rw-r--r--currency/locale/ru.po4
-rw-r--r--currency/safe.lua61
2 files changed, 43 insertions, 22 deletions
diff --git a/currency/locale/ru.po b/currency/locale/ru.po
index 951e75f..15f54d9 100644
--- a/currency/locale/ru.po
+++ b/currency/locale/ru.po
@@ -8,14 +8,14 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-02-20 13:58-0700\n"
-"PO-Revision-Date: 2017-08-11 17:09+0300\n"
+"PO-Revision-Date: 2017-08-11 19:03+0300\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.0.3\n"
"Last-Translator: \n"
-"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
+"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
"Language: ru\n"
#: barter.lua:14 barter.lua:22
diff --git a/currency/safe.lua b/currency/safe.lua
index 1c53184..ed26119 100644
--- a/currency/safe.lua
+++ b/currency/safe.lua
@@ -2,15 +2,40 @@
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
-function default.get_safe_formspec(pos)
+function default.get_safe_formspec(pos, page)
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
+ local ipos = 50*page
local formspec =
- "size[8,9]"..
- "list[nodemeta:".. spos .. ";main;1,1;6,2;]"..
- "list[current_player;main;0,5;8,4;]"
+ "size[8,11]"..
+ default.gui_bg..
+ default.gui_bg_img..
+ default.gui_slots..
+ "button[1,-0.1;2,1;page1;Page 1]"..
+ "button[5,-0.1;2,1;page2;Page 2]"..
+ "list[nodemeta:".. spos .. ";main;0,0.9;8,6;"..ipos.."]"..
+ "list[current_player;main;0,7.2;8,4;]"..
+ "listring[nodemeta:".. spos .. ";main]"..
+ "listring[current_player;main]"
return formspec
end
+local function show_safe_form(clicker, pos, page)
+ minetest.show_formspec(
+ clicker:get_player_name(),
+ "currency:safe",
+ default.get_safe_formspec(pos, page)
+ )
+ minetest.register_on_receive_fields(function(player, form, pressed)
+ print("[SAFE] page button pressed: "..dump(pressed))
+ if form=="currency:safe" then
+ if pressed.page1 then show_safe_form(clicker, pos, 0) end
+ if pressed.page2 then show_safe_form(clicker, pos, 1) end
+ end
+ end)
+end
+
+
+
local function has_safe_privilege(meta, player)
local name = ""
if player then
@@ -31,13 +56,19 @@ minetest.register_node("currency:safe", {
paramtype = "light",
paramtype2 = "facedir",
tiles = {"safe_side.png",
- "safe_side.png",
+ "safe_side.png",
"safe_side.png",
"safe_side.png",
"safe_side.png",
"safe_front.png",},
is_ground_content = false,
groups = {cracky=1},
+ on_rightclick = function(pos, node, clicker)
+ local meta = minetest.get_meta(pos)
+ if has_safe_privilege(meta, clicker) then
+ show_safe_form(clicker, pos, 0)
+ end
+ end,
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "")
@@ -48,7 +79,7 @@ minetest.register_node("currency:safe", {
meta:set_string("infotext", "Safe")
meta:set_string("owner", "")
local inv = meta:get_inventory()
- inv:set_size("main", 6*2)
+ inv:set_size("main", 12*8)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
@@ -64,7 +95,7 @@ minetest.register_node("currency:safe", {
end
return count
end,
- allow_metadata_inventory_put = function(pos, listname, index, stack, player)
+ allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
if not has_safe_privilege(meta, player) then
minetest.log("action", S("@1 tried to access a safe belonging to @2 at @3",
@@ -73,7 +104,7 @@ minetest.register_node("currency:safe", {
end
return stack:get_count()
end,
- allow_metadata_inventory_take = function(pos, listname, index, stack, player)
+ allow_metadata_inventory_take = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
if not has_safe_privilege(meta, player) then
minetest.log("action", S("@1 tried to access a safe belonging to @2 at @3",
@@ -85,20 +116,10 @@ minetest.register_node("currency:safe", {
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
minetest.log("action", S("@1 moves stuff in safe at @2", player:get_player_name(), minetest.pos_to_string(pos)))
end,
- on_metadata_inventory_put = function(pos, listname, index, stack, player)
+ on_metadata_inventory_put = function(pos, listname, index, stack, player)
minetest.log("action", S("@1 moves stuff to safe at @2", player:get_player_name(), minetest.pos_to_string(pos)))
end,
- on_metadata_inventory_take = function(pos, listname, index, stack, player)
+ on_metadata_inventory_take = function(pos, listname, index, stack, player)
minetest.log("action", S("@1 takes stuff from safe at @2", player:get_player_name(), minetest.pos_to_string(pos)))
end,
- on_rightclick = function(pos, node, clicker)
- local meta = minetest.get_meta(pos)
- if has_safe_privilege(meta, clicker) then
- minetest.show_formspec(
- clicker:get_player_name(),
- "currency:safe",
- default.get_safe_formspec(pos)
- )
- end
- end,
})