Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
188
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",256},{"leftclick",128},{"sneak",64},{"aux",32},{"jump",16},{"right",8},{"left",4},{"down",2},{"up",1}}
  7.     for _,data in pairs(keys) do
  8.         if input - data[2] >= 0 then
  9.             input_table[data[1]] = true
  10.             input = input - data[2]
  11.         end
  12.     end
  13.     return(input_table)
  14. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement