Advertisement
Killer2091

Untitled

Sep 11th, 2023
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Define configuration
  2. local map = "all_star"
  3. local start_position = {x = 0, y = 0}
  4. local farm_positions = {
  5.     {x = 100, y = 100},
  6.     {x = 200, y = 200},
  7. }
  8.  
  9. -- Function to farm
  10. function farm()
  11.     for _, position in ipairs(farm_positions) do
  12.         -- Move to the position
  13.         local character = player.get_character()
  14.         character.move_to(position.x, position.y)
  15.  
  16.         -- Attack
  17.         local target = enemy.find_nearest(position)
  18.         if target then
  19.             character.attack(target)
  20.         end
  21.     end
  22. end
  23.  
  24. -- Function to find a target
  25. function find_target()
  26.     -- Find the nearest enemy
  27.     local target = enemy.find_nearest(player.get_character().x, player.get_character().y)
  28.  
  29.     -- Attack if found
  30.     if target then
  31.         player.get_character().attack(target)
  32.     end
  33. end
  34.  
  35. -- Function to start the game
  36. function start_game()
  37.     -- Start the game
  38.     local game = game.get_current_game()
  39.     game.start()
  40. end
  41.  
  42. -- Main function
  43. function main()
  44.     -- Set the character's position
  45.    local character = player.get_character()
  46.    character.set_position(start_position.x, start_position.y)
  47.  
  48.    -- Loop the game
  49.    while true do
  50.        -- Farm
  51.        farm()
  52.  
  53.        -- Find a target
  54.        find_target()
  55.  
  56.        -- Start the game if it's not started yet
  57.         if game.get_current_game().state == "waiting" then
  58.             start_game()
  59.         end
  60.  
  61.         -- Sleep for 1 second
  62.         os.sleep(1)
  63.     end
  64. end
  65.  
  66. -- Start the game
  67. main()
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement