| Blockland Forums > General Discussion |
| Is there another key converter? |
| (1/4) > >> |
| Nobot:
Kalphiter's is down and I was wondering, is there any other way to do this? |
| Zalot:
why do you want a key converter kalphiter's seemed pretty useless to me |
| Xalos:
--- Quote from: Nobot on June 06, 2013, 07:20:57 PM ----snip- --- End quote --- --- Code: ---function BLID_To_Prefix(%blid) { %map = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789"; %power = 1048576; for(%i=0;%i<5;%i++) { while(%blid >= %power) { %blid -= %power; %v[%i]++; } %power /= 32; } for(%i=0;%i<5;%i++) %key = %key @ getSubStr(%map, %v[%i]+0, 1); return %key; } function Prefix_To_BLID(%key) { %map = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789"; %power = 1048576; for(%i=0;%i<5;%i++) { %blid += %power * strPos(%map, getSubStr(%key, %i, 1)); %power /= 32; } return %blid; } --- End code --- There is probably a better way to do this but it does what you want. Unless you plan to be calculating thousands of these things a second this will suffice. |
| NEkram:
umm the site is up for me |
| Nobot:
--- Quote from: Xalos on June 06, 2013, 07:27:16 PM --- --- Code: ---function BLID_To_Prefix(%blid) { %map = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789"; %power = 1048576; for(%i=0;%i<5;%i++) { while(%blid >= %power) { %blid -= %power; %v[%i]++; } %power /= 32; } for(%i=0;%i<5;%i++) %key = %key @ getSubStr(%map, %v[%i]+0, 1); return %key; } function Prefix_To_BLID(%key) { %map = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789"; %power = 1048576; for(%i=0;%i<5;%i++) { %blid += %power * strPos(%map, getSubStr(%key, %i, 1)); %power /= 32; } return %blid; } --- End code --- There is probably a better way to do this but it does what you want. Unless you plan to be calculating thousands of these things a second this will suffice. --- End quote --- How do you work that exactly? |
| Navigation |
| Message Index |
| Next page |