__a wrote:EXAMPLE CODE of 'pnpc.lua':
I believe it works perfectly. Not sure if the code is perfect, though.
This may help new users of lunalua to understand 'pnpc.lua'.
You know you don't need to manually create a hitbox for the player. You can just use the player in place of a collider and the library will do that automatically. The same is true of NPCs. Line 86 can just be:
Code: Select all
if(colliders.collide(player, v)) then
Also your "round" function is flawed. You return the rounded remainder, so it will only ever return 0 or 1. I'm also not sure why you define "npc.dir" when you then put it inside the "data" table and only ever refer to it from there.
I wouldn't recommend using this code to learn from, as it's rather messy, using outdated functions like "findnpcs", and contains a lot of unnecessary code.