functions.lua 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. function darkage.on_rightclick(pos, node, clicker, itemstack, pt)
  2. local pname = clicker:get_player_name()
  3. local spos = pos.x .. "," .. pos.y .. "," .. pos.z
  4. local defgui = default.gui_bg .. default.gui_bg_img .. default.gui_slots
  5. local formspec = "size[8,7]" .. defgui ..
  6. "list[nodemeta:" .. spos .. ";main;0,0.3;8,2;]" ..
  7. "list[current_player;main;0,2.85;8,1;]" ..
  8. "list[current_player;main;0,4.08;8,3;8]" ..
  9. "listring[nodemeta:" .. spos .. ";main]" ..
  10. "listring[current_player;main]" ..
  11. default.get_hotbar_bg(0, 2.85)
  12. minetest.show_formspec(pname, "darkage:box", formspec)
  13. return itemstack
  14. end
  15. function darkage.on_player_receive_fields(player, formname, fields)
  16. if formname ~= "darkage:box" then
  17. return
  18. end
  19. return true
  20. end
  21. function darkage.on_construct(pos)
  22. local meta = minetest.get_meta(pos)
  23. meta:set_string("infotext", "Open Storage")
  24. local inv = meta:get_inventory()
  25. inv:set_size("main", 16)
  26. end
  27. function darkage.after_place_node(pos, placer, itemstack, pt)
  28. end
  29. function darkage.can_dig(pos, player)
  30. local meta = minetest.get_meta(pos)
  31. local inv = meta:get_inventory()
  32. return inv:is_empty("main")
  33. end
  34. function darkage.allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
  35. return count
  36. end
  37. function darkage.allow_metadata_inventory_put(pos, listname, index, stack, player)
  38. return stack:get_count()
  39. end
  40. function darkage.allow_metadata_inventory_take(pos, listname, index, stack, player)
  41. return stack:get_count()
  42. end
  43. function darkage.on_blast(pos, intensity)
  44. local drops = {}
  45. default.get_inventory_drops(pos, "main", drops)
  46. drops[#drops+1] = minetest.get_node(pos).name
  47. minetest.remove_node(pos)
  48. return drops
  49. end
  50. function darkage.on_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
  51. local pname = player:get_player_name()
  52. minetest.log("action", pname .. " moves stuff in storage at " .. minetest.pos_to_string(pos))
  53. end
  54. function darkage.on_metadata_inventory_put(pos, listname, index, stack, player)
  55. local pname = player:get_player_name()
  56. minetest.log("action", pname .. " moves " .. stack:get_name() .. " to storage at " .. minetest.pos_to_string(pos))
  57. end
  58. function darkage.on_metadata_inventory_take(pos, listname, index, stack, player)
  59. local pname = player:get_player_name()
  60. minetest.log("action", pname .. " takes " .. stack:get_name() .. " from storage at " .. minetest.pos_to_string(pos))
  61. end