Fix bugs reported by hsandt, closes #20 and closes #21

stat(34) uses the wrong bit operation
tostr() in hex mode shifts the upper part by too little
This commit is contained in:
gamax92 2018-06-08 22:08:28 -06:00
parent a24c02a30d
commit 69ac5fe487
1 changed files with 2 additions and 2 deletions

View File

@ -167,7 +167,7 @@ function api.tostr(val, hex)
elseif kind == "number" then
if hex then
val=val*0x10000
local part1=bit.rshift(bit.band(val, 0xFFFF0000), 4)
local part1=bit.rshift(bit.band(val, 0xFFFF0000), 16)
local part2=bit.band(val, 0xFFFF)
return string.format("0x%04x.%04x", part1, part2)
else
@ -1073,7 +1073,7 @@ function api.stat(x)
local btns=0
for i=0, 2 do
if love.mouse.isDown(i+1) then
btns=bit.band(btns, bit.lshift(1, i))
btns=bit.bor(btns, bit.lshift(1, i))
end
end
return btns