Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.60 KB | None | 0 0
  1. --make the data from get_key_pressed usable
  2. function minetest.get_control_bits(player)
  3.     local input = player:get_key_pressed()
  4.     local input_table = {up=false,down=false,left=false,right=false,jump=false,aux=false,sneak=false,leftclick=false,rightclick=false}
  5.     --iterate through the table using the highest value first
  6.     local keys = {"rightclick","leftclick","sneak","aux","jump","right","left","down","up"}
  7.     for index,data in pairs(keys) do
  8.         local modifier = math.pow(2, 9-index)
  9.         if input - modifier >= 0 then
  10.             input_table[data] = true
  11.             input = input - modifier
  12.         end
  13.     end
  14.     return(input_table)
  15. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement