Page 1 of 1

[NPC Pack] Time Clocks

Posted: Fri Apr 24, 2020 6:48 am
by Akromaly
Hello there! I present my first public NPC pack for SMBX2, I decided to make those clocks you see in most of the newest Mario games, it's a simple thing and maybe they're not very polished, but I think they may be useful anyway.

The pack contains 4 different clocks that behave differently:

Green (+100 seconds) - Adds 100 seconds to current time.
Cyan (+10 seconds) - Adds 10 seconds to current time.
Red (+x seconds) - Adds a custom amount of seconds to current time, you can set it through NPC properties in the editor.
Violet (-x seconds) - Subtracts a custom amount of seconds to current time, you can set it like the red one aswell.

(Sprites are by Kopejo)

Image

Download

Re: [NPC Pack] Time Clocks

Posted: Fri Apr 24, 2020 8:01 am
by higgorgao1new
Cool

Re: [NPC Pack] Time Clocks

Posted: Sun Apr 26, 2020 9:27 am
by Emral
The code has a few rough edges you might want to revisit:
1) require is best used outside of all functions, at the top of your code. Currently you're getting a new reference to timer every frame for every onscreen clock.
2) Nothing speaks against using onPostNPCKill(npc, reason), checking for id and then checking if npcManager.collected(npc, reason) then. Compare to starman.lua's onNPCKill for reference. Doing things this way brings two benefits: 1) better performance, 2) multiplayer compatibility.
3) isinteractable would also be sufficient for getting a collectible NPC. Dunno if the side-effect of adding to the coin counter is intentional.