Something like this may work (it is untested, so you should correct it if necessary).
-- Get the map coordinates of the cursor.
local map_meta = sol.main.get_metatable("map")
function map_meta:get_cursor_coordinates()
local camera = self:get_camera()
local mouse_x, mouse_y = sol.input.get_mouse_position()
local cam_screen_x, cam_screen_y = camera:get_position_on_screen()
local cam_x, cam_y, _, _ = camera:get_bounding_box()
local pos_x = mouse_x - cam_screen_x + cam_x
local pos_y = mouse_y - cam_screen_y + cam_y
return pos_x, pos_y
end
-- Make the hero face the cursor.
local hero_meta = sol.main.get_metatable("hero")
function hero_meta:face_the_cursor()
local hero = self
local pos_x, pos_y = hero:get_map():get_cursor_coordinates()
local dir = hero:get_direction4_to(pos_x, pos_y)
hero:set_direction(dir)
end
You still have to import the script that contains these functions, and initialize a timer that will call "hero:face_the_cursor()" when necessary, as mentioned above. If we do all the work for you, you will not learn, so I will be leaving you here. Good luck!