Advertisement
Guest User

Untitled

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