Added options for 'cheaters'

This commit is contained in:
əlemi 2019-10-23 00:02:56 +02:00
parent b293e835a8
commit 07dd5d802d
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -5,15 +5,21 @@ let g:best_combo = g:best_combo[0] " Reading from file returns a list, but
let g:last_combo = reltime() " Set current time as last combo time let g:last_combo = reltime() " Set current time as last combo time
let g:airline_section_b = 'ᛥ %{g:combo_counter} [%{g:best_combo}]' " I use airline vim and inserted the combo meter in it let g:airline_section_b = 'ᛥ %{g:combo_counter} [%{g:best_combo}]' " I use airline vim and inserted the combo meter in it
function! UpdateCombo() function! UpdateCombo()
if reltimefloat(reltime(g:last_combo)) > 1 " Timeout is 1 second if reltimefloat(reltime(g:last_combo)) > 0.5 " Timeout is 0.5 seconds
if g:combo_counter > g:best_combo " Before resetting combo counter, check if new high score if g:combo_counter > g:best_combo " Before resetting combo counter, check if new high score
call writefile([g:combo_counter], "/home/$USER/.vim/.combo") call writefile([g:combo_counter], "/home/$USER/.vim/.combo") " Sorry no idea how to solve this yes
let g:best_combo = g:combo_counter let g:best_combo = g:combo_counter
endif endif
let g:combo_counter = 1 let g:combo_counter = 1
else else
let g:combo_counter +=1 let g:combo_counter +=1
endif endif
let g:last_combo = reltime() let g:last_combo = reltime()
endfunction endfunction
autocmd CursorMovedI * call UpdateCombo() " Every time the cursor moves, call combo function autocmd CursorMovedI * call UpdateCombo() " Every time the cursor moves, cwall combo function
" NOT NECESSARY! Only enable if you find yourself cheating!
" inoremap <Left> <C-o>:let g:combo_counter=0<CR><Left>
" inoremap <Right> <C-o>:let g:combo_counter=0<CR><Right>
" inoremap <Up> <C-o>:let g:combo_counter=0<CR><Up>
" inoremap <Down> <C-o>:let g:combo_counter=0<CR><Down>