How to implement turn based combat?

Heyo! Some details about what you have so far for the game might be helpful for suggestion.

For example, do you walk around in the game, interact with objects etc, and then are looking to get into battles and “pause” for turn based combat? Or is everything turn based even when not in combat, eg on your turn you may move, interact with an object, then the enemies get their turn (or other things happen in the background) regardless of if you are fighting or not.


Suggestions

Design:
If it is similar to pokemon, sounds like you are entering battles separate from the rest of the exploration. Many RPGs have a separate scene appear with the characters. Characters could face each other (like pokemon) or be on a limited size battlefield, like FireEmblem, where the rules are different from normal exploration.

You can have some clickable buttons to take a specific action, and a grid on the ground for movement if that is part of your game.

Implementation:
First you may want a scene transition, either by using a plug-in manager like Monarch or by setting up your own system of collections and loading (see the Colorslide tutorial linked below)

Then @dodze suggestion of a machine that swaps between player and enemy turns makes sense. At the start of the battle, if its the players turn, nothing happens until the player clicks a button to take an action. Then you receive the action (usually in a GUI script or the game script), facilitate the selected option by sending messages from the script to the relevant game objects you want to affect, then take the enemy turn, and then return to the start of the loop.

This can often be accomplished with a LUA module which can help run the games logic internally and coordinate between different game object, although it can be a lot of frontloaded work to research and design using modules to run your game, it can save complexity in the long run.

Resources
If you haven’t done the first five tutorials on this page, definitely walk through them (maybe not movement for your RPG) Defold tutorials

Looking through the questions on this forum is a great resource as many people might have similar questions. Researching each part that you are trying to create on this forum could give you several different code examples that you can string together to accomplish what you are looking for.

If you are interested in using modules, here are the best resources I have found to help determine how you want to use modules to run your game: