[NPC Pack] Time Clocks

Share and discuss custom LunaLua code and content packs for SMBX2.

Moderator: Userbase Moderators

Akromaly
Bronze Yoshi Egg
Bronze Yoshi Egg
Posts: 428
Joined: Sun Mar 12, 2017 8:07 am
Flair: anemoia
Contact:

[NPC Pack] Time Clocks

Postby Akromaly » Fri Apr 24, 2020 6:48 am

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

higgorgao1new
Koopa
Koopa
Posts: 17
Joined: Wed Feb 12, 2020 2:59 pm
Flair: Higgorgao1
Pronouns: he/him

Re: [NPC Pack] Time Clocks

Postby higgorgao1new » Fri Apr 24, 2020 8:01 am

Cool

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: [NPC Pack] Time Clocks

Postby Emral » Sun Apr 26, 2020 9:27 am

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.


Return to “LunaLua”

Who is online

Users browsing this forum: Halzk, S_Koopa0, Turtle Guy and 5 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari