travelnet.lua 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. -- contains the node definition for a general travelnet that can be used by anyone
  2. -- further travelnets can only be installed by the owner or by people with the travelnet_attach priv
  3. -- digging of such a travelnet is limited to the owner and to people with the travelnet_remove priv (useful for admins to clean up)
  4. -- (this can be overrided in config.lua)
  5. -- Author: Sokomine
  6. local S = travelnet.S;
  7. minetest.register_node("travelnet:travelnet", {
  8. description = S("Travelnet-Box"),
  9. drawtype = "mesh",
  10. mesh = "travelnet.obj",
  11. sunlight_propagates = true,
  12. paramtype = 'light',
  13. paramtype2 = "facedir",
  14. wield_scale = {x=0.6, y=0.6, z=0.6},
  15. selection_box = {
  16. type = "fixed",
  17. fixed = { -0.5, -0.5, -0.5, 0.5, 1.5, 0.5 }
  18. },
  19. collision_box = {
  20. type = "fixed",
  21. fixed = {
  22. { 0.45, -0.5,-0.5, 0.5, 1.45, 0.5},
  23. {-0.5 , -0.5, 0.45, 0.45, 1.45, 0.5},
  24. {-0.5, -0.5,-0.5 ,-0.45, 1.45, 0.5},
  25. --groundplate to stand on
  26. { -0.5,-0.5,-0.5,0.5,-0.45, 0.5},
  27. --roof
  28. { -0.5, 1.45,-0.5,0.5, 1.5, 0.5},
  29. -- control panel
  30. -- { -0.2, 0.6, 0.3, 0.2, 1.1, 0.5},
  31. },
  32. },
  33. tiles = travelnet.tiles_travelnet,
  34. inventory_image = travelnet.travelnet_inventory_image,
  35. groups = {}, --cracky=1,choppy=1,snappy=1},
  36. light_source = 10,
  37. after_place_node = function(pos, placer, itemstack)
  38. local meta = minetest.get_meta(pos);
  39. travelnet.reset_formspec( meta );
  40. meta:set_string("owner", placer:get_player_name() );
  41. end,
  42. on_receive_fields = travelnet.on_receive_fields,
  43. on_punch = function(pos, node, puncher)
  44. travelnet.update_formspec(pos, puncher:get_player_name(), nil)
  45. end,
  46. can_dig = function( pos, player )
  47. return travelnet.can_dig( pos, player, 'travelnet box' )
  48. end,
  49. after_dig_node = function(pos, oldnode, oldmetadata, digger)
  50. travelnet.remove_box( pos, oldnode, oldmetadata, digger )
  51. end,
  52. -- TNT and overenthusiastic DMs do not destroy travelnets
  53. on_blast = function(pos, intensity)
  54. end,
  55. -- taken from VanessaEs homedecor fridge
  56. on_place = function(itemstack, placer, pointed_thing)
  57. local pos = pointed_thing.above;
  58. local def = minetest.registered_nodes[
  59. minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name]
  60. if not def or not def.buildable_to then
  61. minetest.chat_send_player( placer:get_player_name(), S('Not enough vertical space to place the travelnet box!'))
  62. return;
  63. end
  64. return minetest.item_place(itemstack, placer, pointed_thing);
  65. end,
  66. })
  67. --[
  68. minetest.register_craft({
  69. output = "travelnet:travelnet",
  70. recipe = travelnet.travelnet_recipe,
  71. })