Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Define configuration
- local map = "all_star"
- local start_position = {x = 0, y = 0}
- local farm_positions = {
- {x = 100, y = 100},
- {x = 200, y = 200},
- }
- -- Function to farm
- function farm()
- for _, position in ipairs(farm_positions) do
- -- Move to the position
- local character = player.get_character()
- character.move_to(position.x, position.y)
- -- Attack
- local target = enemy.find_nearest(position)
- if target then
- character.attack(target)
- end
- end
- end
- -- Function to find a target
- function find_target()
- -- Find the nearest enemy
- local target = enemy.find_nearest(player.get_character().x, player.get_character().y)
- -- Attack if found
- if target then
- player.get_character().attack(target)
- end
- end
- -- Function to start the game
- function start_game()
- -- Start the game
- local game = game.get_current_game()
- game.start()
- end
- -- Main function
- function main()
- -- Set the character's position
- local character = player.get_character()
- character.set_position(start_position.x, start_position.y)
- -- Loop the game
- while true do
- -- Farm
- farm()
- -- Find a target
- find_target()
- -- Start the game if it's not started yet
- if game.get_current_game().state == "waiting" then
- start_game()
- end
- -- Sleep for 1 second
- os.sleep(1)
- end
- end
- -- Start the game
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement