Advertisement
Guest User

Untitled

a guest
Jan 27th, 2017
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. creative = {}
  2. creative.mode = minetest.setting_getbool("creative_mode")
  3.  
  4. minetest.register_privilege("creative", {"Allow player to use creative inventory",
  5. give_to_singleplayer = false})
  6.  
  7. function creative.is_enabled_for(name)
  8.  
  9. if minetest.check_player_privs(name, {creative = true}) then
  10. return true
  11. else
  12. return creative.mode
  13. end
  14. end
  15.  
  16. dofile(minetest.get_modpath("creative") .. "/inventory.lua")
  17.  
  18. if creative.mode then
  19. -- Dig time is modified according to difference (leveldiff) between tool
  20. -- 'maxlevel' and node 'level'. Digtime is divided by the larger of
  21. -- leveldiff and 1.
  22. -- To speed up digging in creative, hand 'maxlevel' and 'digtime' have been
  23. -- increased such that nodes of differing levels have an insignificant
  24. -- effect on digtime.
  25. local digtime = 42
  26. local caps = {times = {digtime, digtime, digtime}, uses = 0, maxlevel = 256}
  27.  
  28. minetest.register_item(":", {
  29. type = "none",
  30. wield_image = "wieldhand.png",
  31. wield_scale = {x = 1, y = 1, z = 2.5},
  32. range = 10,
  33. tool_capabilities = {
  34. full_punch_interval = 0.5,
  35. max_drop_level = 3,
  36. groupcaps = {
  37. crumbly = caps,
  38. cracky = caps,
  39. snappy = caps,
  40. choppy = caps,
  41. oddly_breakable_by_hand = caps,
  42. },
  43. damage_groups = {fleshy = 10},
  44. }
  45. })
  46. end
  47.  
  48. -- Unlimited node placement
  49. minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack)
  50. return creative.is_enabled_for(placer:get_player_name())
  51. end)
  52.  
  53. -- Don't pick up if the item is already in the inventory
  54. local old_handle_node_drops = minetest.handle_node_drops
  55. function minetest.handle_node_drops(pos, drops, digger)
  56. if not digger or not digger:is_player() then
  57. return
  58. end
  59. if not creative.is_enabled_for(digger:get_player_name()) then
  60. return old_handle_node_drops(pos, drops, digger)
  61. end
  62. local inv = digger:get_inventory()
  63. if inv then
  64. for _, item in ipairs(drops) do
  65. item = ItemStack(item):get_name()
  66. if not inv:contains_item("main", item) then
  67. inv:add_item("main", item)
  68. end
  69. end
  70. end
  71. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement