Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- global
- pova = {}
- -- set player table on join
- minetest.register_on_joinplayer(function(player)
- pova[ player:get_player_name() ] = {}
- end)
- -- reset player table on respawn
- minetest.register_on_respawnplayer(function(player)
- pova[ player:get_player_name() ] = {}
- end)
- -- blank player table on leave
- minetest.register_on_leaveplayer(function(player)
- pova[ player:get_player_name() ] = nil
- end)
- -- main counter that runs every second and totals override list
- local timer = 0
- minetest.register_globalstep(function(dtime)
- timer = timer + dtime
- -- every 1 second
- if timer < 1 then
- return
- end
- -- reset time for next check
- timer = 0
- -- define locals outside loop
- local name
- local speed, jump, gravity = 1, 1, 1 -- defaults
- -- loop through players
- for _,player in ipairs(minetest.get_connected_players()) do
- name = player:get_player_name()
- if pova[name] then
- for id, var in pairs(pova[name]) do
- speed = speed + (pova[name][id].speed or 0)
- jump = jump + (pova[name][id].jump or 0)
- gravity = gravity + (pova[name][id].gravity or 0)
- end
- print ("speed: " .. speed .. " / jump: " .. jump .. " / gravity: " .. gravity)
- player:set_physics_override(speed, jump, gravity)
- end
- end
- end)
- -- axe tool that adds to override table on use
- minetest.register_craftitem("pova:axe", {
- description = "Test Axe (left to apply, right to remove effects)",
- inventory_image = "default_tool_steelaxe.png",
- liquids_pointable = true,
- on_use = function(itemstack, user, pointed_thing)
- local name = user:get_player_name()
- pova[name]["test"] = {}
- pova[name]["test"].speed = 1
- pova[name]["test"].jump = 2
- pova[name]["test"].gravity = 0.5
- end,
- on_place = function(itemstack, user, pointed_thing)
- local name = user:get_player_name()
- pova[name]["test"] = {}
- end,
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement