Advertisement
Guest User

Untitled

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