Guest User

Untitled

a guest
Apr 15th, 2018
56
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. -- global
  3. pova = {}
  4.  
  5.  
  6. -- set player table on join
  7. minetest.register_on_joinplayer(function(player)
  8. pova[ player:get_player_name() ] = {}
  9. end)
  10.  
  11. -- reset player table on respawn
  12. minetest.register_on_respawnplayer(function(player)
  13. pova[ player:get_player_name() ] = {}
  14. end)
  15.  
  16. -- blank player table on leave
  17. minetest.register_on_leaveplayer(function(player)
  18. pova[ player:get_player_name() ] = nil
  19. end)
  20.  
  21.  
  22. -- main counter that runs every second and totals override list
  23. local timer = 0
  24. minetest.register_globalstep(function(dtime)
  25.  
  26. timer = timer + dtime
  27.  
  28. -- every 1 second
  29. if timer < 1 then
  30. return
  31. end
  32.  
  33. -- reset time for next check
  34. timer = 0
  35.  
  36. -- define locals outside loop
  37. local name
  38. local speed, jump, gravity = 1, 1, 1
  39.  
  40. -- loop through players
  41. for _,player in ipairs(minetest.get_connected_players()) do
  42.  
  43. name = player:get_player_name()
  44.  
  45. if pova[name] then
  46.  
  47. for id, var in pairs(pova[name]) do
  48.  
  49. speed = speed + (pova[name][id].speed or 0)
  50. jump = jump + (pova[name][id].jump or 0)
  51. gravity = gravity + (pova[name][id].gravity or 0)
  52.  
  53. end
  54.  
  55. print ("speed: " .. speed .. " / jump: " .. jump .. " / gravity: " .. gravity)
  56.  
  57. player:set_physics_override(speed, jump, gravity)
  58.  
  59. end
  60.  
  61. end
  62.  
  63. end)
  64.  
  65.  
  66. -- axe tool that adds to override table on use
  67. minetest.register_craftitem("pova:axe", {
  68. description = "Test Axe",
  69. inventory_image = "default_tool_steelaxe.png",
  70. liquids_pointable = true,
  71.  
  72. on_use = function(itemstack, user, pointed_thing)
  73.  
  74. -- local pos = pointed_thing.under or user:getpos()
  75. local name = user:get_player_name()
  76.  
  77. pova[name]["test"] = {}
  78. pova[name]["test"].speed = 1
  79. pova[name]["test"].jump = 2
  80. pova[name]["test"].gravity = 0.5
  81. end,
  82. })
RAW Paste Data