Help with how to code my enemies

Hello I am new to Lua and would like some help with how to go about coding the scripts for the enemies in my game. What I need to do is setup a health counter for my player and then code a script for my enemies that allow them to do damage to my playerwhen the player is within a certain radius of my player. So I would want my player and enemy to stop their idle animation when they are in reach of each other and make my player unable to move and then enable a turn based exchange between my player and enemy where my player always wins as this is a very simple game for a project I am working on. So my player has 100 health and the enemy has 100 health with each attack from the player the player would do 50 damage to the enemy and the enemy would do 20 damage to the player so the player has to pick up health from the ground before engaging with the next enemy where if the player doesnt have enough health he will die and start again. Any pointers in the right direction to start or help and suggestions in general would be great, I am in the process of learning defold but I must submit this project by tomorrow and all i have left to code is the enemy and player fighting scripts.

That’s going to be pretty tough to be honest. Are you familiar with some other programming language?

You can use vmath.length(player_position - enemy_position) to get the distance between two points.

You change animation using sprite.play_flipbook("#spritecomp", hash(“some_animation”))

This is pretty vague.