Displays position, angle, etc.
local function draw_text(x, y, msg)
gui.text(x, y, msg)
end
local function signed(abs, sign)
return (sign == 0 and 1 or -1) * abs
end
local function get_info()
info = {}
info.cam_x = mainmemory.read_u16_be(0xB8)
info.cam_y = mainmemory.read_u16_be(0xB6)
info.pos_x = mainmemory.read_u16_be(0xD8)
info.pos_y = mainmemory.read_u16_be(0xD6)
info.pos_z = mainmemory.read_u8(0xEC)
info.vel_x = signed(mainmemory.read_u16_be(0x0162), mainmemory.read_u8(0x0167))
info.vel_y = signed(mainmemory.read_u16_be(0x0160), mainmemory.read_u8(0x0164))
info.angle = mainmemory.read_u8(0xE8)
info.rot_speed = mainmemory.read_u8(0xE5)
info.rot_dir = mainmemory.read_u8(0xE7)
return info
end
local function draw()
info = get_info()
draw_text(0, 0, string.format("CAM:(%d,%d) POS:(%d,%d,%d) ANG:%d (%s)",
info.cam_x, info.cam_y,
info.pos_x, info.pos_y, info.pos_z,
info.angle, (info.rot_dir == 0 and "+" or "-")
))
if info.vel_x ~= 0 or info.vel_y ~= 0 then
draw_text(0, 14, string.format("VEL:(%.3f,%.3f)",
info.vel_x / 256.0, info.vel_y / 256.0
))
end
draw_text(193, 397, string.format("%d", info.rot_speed))
end
local function main()
event.onframeend(draw)
end
main()