Closed hkzorman closed 6 years ago
@BrunoMine Have you found any further issues with the newest code? If not, I think I will merge this into master by tomorrow.
I have not tested everything consistently, I'm running tests, I'll still go a little deeper in creating programs (I intend to do this now)and maybe improve documentation, but I think the most important part is okay.
Cool! I can postpone the merge until Sunday or Monday, that is fine!
To complete the OS metaphor, I have added timers and callbacks (wrapped in a Monitor
API).
Examples are in idle.lua
Apparently these two problems persist. Pause the action queue when attacking lock the use of the bed Do you want to fix them before you merge it?
attack
program.beds
node to check for NPC usage.@BrunoMine from this comment https://github.com/hkzorman/advanced_npc/pull/48#issuecomment-385223075 is then this good to merge?
The log cleanup is not complete but this can wait. Will merge this tomorrow.
Yeah, sounds great.
Merged!
This PR is a complete re-write of the actions/tasks functionality into the Execution API.
The API follows a simple OS-based model where tasks performed by NPCs are encapsulated in the concepts of
instructions
andprograms
.Instructions
are "small", "atomic" actions performed by a NPC (like rotating, standing, etc.) andprograms
are a "collection" of instructions with logic on what to execute and what not (for example, walking to a specific position). The NPC executes different programs in order to be able to perform tasks (e.g. going to sleep on a bed).The execution environment of Advanced NPC is based on processes, which are instances of a program. Processes have an internal instruction queue and execution context for storing variables; they can be interrupted and their state upon interruption is stored for later restoration. Processes can also be enqueued into a process queue which is managed by a process scheduler (which runs roughly each second). The process scheduler has the responsibility of determining what is the next process to be executed.