(V1.0 NOW OUT) lifeCountPlus.lua: Improved life counters

Share and discuss custom LunaLua code and content packs for SMBX2.
User avatar
The Dwarven Digger
Lakitu
Lakitu
Posts: 484
Joined: Sun Oct 30, 2016 11:17 am

(V1.0 NOW OUT) lifeCountPlus.lua: Improved life counters

Postby The Dwarven Digger » Mon Jan 07, 2019 5:40 pm

Have you ever thought that having 99 lives just isn't enough for you?
Have you ever played with a friend, and disliked the way SMBX combines player life totals?
With lifeCountPlus.lua, those problems are a thing of the past!


Features
Spoiler: show
lifeCountPlus.lua allows extra customisable life counters, with options such as:
  • Customisable number of displayed digits (1-10, 3 max recommended). Affects maximum possible lives.
  • Option to enable the crowns system as featured in newer Mario games, allowing up to 11,111,111,110 lives!
  • Option for player head icons on life counter instead of standard "1-up" symbol.
  • Infinite lives option at max lives, with or without an infinity symbol.
  • Life total separation by player
  • Life total separation by character
  • Life total separation by character and player
Screenshots
Spoiler: show
Image
Image
Image
Image
Image
How to use
Spoiler: show
Insert this line into lunaworld.lua and lunaoverworld.lua (Using both enables overworld compatibility):

Code: Select all

local lifeCountPlus = API.load("lifeCountPlus")
That's it for basic set-up! For customisation, you can add some of the following (shown are default values):

Code: Select all

lifeCountPlus.doCrowns = true -- Enables/disables crowns system

Code: Select all

lifeCountPlus.maxInfinite = false -- Enables infinite lives when you reach the maximum

Code: Select all

lifeCountPlus.showInfinite = true -- Shows infinity symbol when at infinite lives

Code: Select all

lifeCountPlus.doHeads = true -- Shows player heads next to life count

Code: Select all

lifeCountPlus.separatePlayers = true -- Separates player life totals

Code: Select all

lifeCountPlus.separateCharacters = true -- Separates character life totals

Code: Select all

lifeCountPlus.showZero = true -- Shows special symbol for 0 lives

Code: Select all

lifeCountPlus.starReward = true -- Gives the player a star at certain intervals of lives. SET TO FALSE IF NOT USING 2.0

Code: Select all

lifeCountPlus.starInterval = 100 -- Sets the interval for the star reward

Code: Select all

lifeCountPlus.setDigits(3) -- Sets number of digits for life counter.
Please note that lifeCountPlus.lua overrides the standard SMBX life counter.
Accessing the standard memory offset directly will not work correctly while this library is in use.
Use only with whole episodes or stand-alone levels.
If you need to access or alter a player's life total, use one of the following functions:
  • lifeCountPlus.setLives(x, player index) for setting lives to a specific value
  • lifeCountPlus.addLives(x, player index) for adding lives
  • lifeCountPlus.removeLives(x, player index) for removing lives
  • lifeCountPlus.getLives(player index) to get a player's current life total
If player index is not provided, it will default to player 1.
Requires imagic.lua and pnpc.lua, both of which are included with SMBX 2.0 Beta 3.

Download Here!
Last edited by The Dwarven Digger on Sat Feb 02, 2019 7:35 am, edited 3 times in total.
I support: show
Image
Image
Due to a problem with my laptop, all my projects and levels have been lost. But fear not, for new ones will be arriving! (and hopefully completed)
Spoiler: show
rockythechao wrote:Image

Aero
Palom
Palom
Posts: 4724
Joined: Fri Mar 28, 2014 2:51 pm
Pronouns: she/her they/them

Re: (heavy WIP: help needed) lifeCountPlus.lua: Improved life counters

Postby Aero » Tue Jan 08, 2019 6:38 pm

I took a look at this and it may take quite a while to get an understanding of what you're doing in order to make the right changes. It'd be easier to help if you used expressive variable names instead of names like "num", "aNumber", "bNumber", "plr", and so on. I see you have comments throughout your code; this is also somewhere you could make things more expressive to where comments would be unnecessary. Also your if statements could be better encapsulated.

PixelPest
Raccoon Mario
Raccoon Mario
Posts: 7112
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: (heavy WIP: help needed) lifeCountPlus.lua: Improved life counters

Postby PixelPest » Wed Jan 09, 2019 1:05 am

A few comments without reiterating any of the above which I second, however I will note that when writing mathematical functions, variables aren't usually too descriptive, however aNumber and bNumber are unnecessarily verbose, and a and b (though personally I'd go with a or b and x. You'll get more used to this as you look more at other people's code and write some yourself, however there are generally accepted abbreviations/ways to abbreviate things. You don't have to try and shorten the crap out of things, for example 'char' is often used as a short form for 'character' and is only one letter longer than 'chr' but much clearer and obvious. Similar with 'plr', as a parameter name I'd honestly go with 'p' which I think is a little more obvious and often used to shorten 'player' in LunaLua, especially since 'player' is a global constant already. You also consistently spell 'separate' which I thought I'd mention.
  • It would be worth making a number of the variables part of the API table, such as the images, so that people can use their own without modifying the provided files.
  • Please don't rename the default events. It makes it a lot harder to understand what's going on especially since some of the names of them aren't that accurate. It isn't immediately easy to distinguish between a new function and a LunaLua event going through the code and I don't see any real reason to do what you did there.
  • I'm confused by the purpose of the exp function you wrote. There's no reason for it to exist (I'm on my mobile IDE but it looks like you only have one particular application of it) and you could simply write 10 ^ digits.
  • Please use proper naming conventions for your functions (i.e. Update should be update). On a separate note I see no reason to have that function separate (the code inside it could easily just be written in the event), and you should tend to define your local variables and functions all together at the top instead of intermingling them with events

User avatar
Quantumenace
Ripper II
Ripper II
Posts: 308
Joined: Mon Dec 28, 2015 2:17 am

Re: (heavy WIP: help needed) lifeCountPlus.lua: Improved life counters

Postby Quantumenace » Wed Jan 09, 2019 1:58 pm

Fireballs activate onNPCKill when they hit; you could keep track of those.

User avatar
The Dwarven Digger
Lakitu
Lakitu
Posts: 484
Joined: Sun Oct 30, 2016 11:17 am

Re: (heavy WIP: help needed) lifeCountPlus.lua: Improved life counters

Postby The Dwarven Digger » Sun Jan 13, 2019 8:09 am

From testing I've found that if one player is dead or not touching the ground in 2 player mode, that player will gain 1-ups from Yoshi eggs (npc 96) breaking. This seems to be linked to the player's kill combo that's used for stomping enemies, since that resets when the player is on the ground, but despite ignoring npc-96 in the onNPCKill event, the player still gains 1-ups (and 2-ups). Any idea what could be causing this? The only way such a combo could be affected like this is through the onNPCKill event, so is this event triggered for the egg breaking using a different NPC id?
I support: show
Image
Image
Due to a problem with my laptop, all my projects and levels have been lost. But fear not, for new ones will be arriving! (and hopefully completed)
Spoiler: show
rockythechao wrote:Image

User avatar
CheesyYoY
Fighter Fly
Fighter Fly
Posts: 48
Joined: Wed Aug 01, 2018 7:51 pm
Flair: I exist

Re: (heavy WIP: help needed) lifeCountPlus.lua: Improved life counters

Postby CheesyYoY » Mon Jan 28, 2019 11:32 am

is there screenshots?

Image
Confirmed greatest episode of all time by me. 8-)
(you can click the image to see the post)


Discord

Spoiler: show
YoY#4811

User avatar
Quantumenace
Ripper II
Ripper II
Posts: 308
Joined: Mon Dec 28, 2015 2:17 am

Re: (heavy WIP: help needed) lifeCountPlus.lua: Improved life counters

Postby Quantumenace » Mon Jan 28, 2019 7:18 pm

By the way, they're working on a lua event for beta 4 that detects when an NPC takes damage. I don't know whether it can tell what player/object caused the damage though.

User avatar
The Dwarven Digger
Lakitu
Lakitu
Posts: 484
Joined: Sun Oct 30, 2016 11:17 am

Re: (heavy WIP: help needed) lifeCountPlus.lua: Improved life counters

Postby The Dwarven Digger » Tue Jan 29, 2019 2:26 pm

Quantumenace wrote:
Mon Jan 28, 2019 7:18 pm
By the way, they're working on a lua event for beta 4 that detects when an NPC takes damage. I don't know whether it can tell what player/object caused the damage though.
Sounds like it might help fix the egg issue, but idk how the game handles the egg breaking, since it doesn't appear to go through onNPCKill. Might still be useful elsewhere though.
CheesyYoY wrote:is there screenshots?
I was going to add some when I reach an "official release" point where I've ironed out as many of the major bugs as possible, but I can put some on here now if you wish.
I support: show
Image
Image
Due to a problem with my laptop, all my projects and levels have been lost. But fear not, for new ones will be arriving! (and hopefully completed)
Spoiler: show
rockythechao wrote:Image

User avatar
The Dwarven Digger
Lakitu
Lakitu
Posts: 484
Joined: Sun Oct 30, 2016 11:17 am

Re: (V1.0 NOW OUT) lifeCountPlus.lua: Improved life counters

Postby The Dwarven Digger » Sat Feb 02, 2019 7:37 am

Version 1.0 is finally released! Took about a month working on and off to get all the bugs ironed out, but it's all completed now! Check OP for details.
I support: show
Image
Image
Due to a problem with my laptop, all my projects and levels have been lost. But fear not, for new ones will be arriving! (and hopefully completed)
Spoiler: show
rockythechao wrote:Image

User avatar
1di_Scroll
Charged Spiny
Charged Spiny
Posts: 1886
Joined: Fri Apr 20, 2018 9:28 pm
Flair: C'est la vie... profitez-en!
Contact:

Re: (V1.0 NOW OUT) lifeCountPlus.lua: Improved life counters

Postby 1di_Scroll » Sat Feb 02, 2019 8:54 am

This looks very useful!

lan vuhoang
Spiny
Spiny
Posts: 28
Joined: Wed Jul 03, 2019 7:31 am

Re: (V1.0 NOW OUT) lifeCountPlus.lua: Improved life counters

Postby lan vuhoang » Thu Oct 17, 2019 11:39 pm

The life counter don't decrease when you dies. Now I always have infinite lives.
I support:
Spoiler: show
Image
Image
Image
Image
Image

User avatar
Cedur
Bowser
Bowser
Posts: 6805
Joined: Tue Jun 28, 2016 10:14 am
Pronouns: he/him

Re: (V1.0 NOW OUT) lifeCountPlus.lua: Improved life counters

Postby Cedur » Sun Mar 29, 2020 8:45 am

So I want to play a few episodes with 3-digit lives using this script, but I got error messages. I copied it into the world folder and wrote
Spoiler: show
local lifeCountPlus = API.load("lifeCountPlus")

lifeCountPlus.setDigits(3)
Since it says that "imagic" and "pnpc" are required, I copied these into the folder too. Am I missing something?
Image
More Supports: show

Image
Image

Still using the legacy editor? Get SMBX2 and PGE, it will improve your experience significantly. Here's why. And remember, Yoshis are tools to be used and discarded.

ShadowStarX (06/14/18) wrote: South Korea is easy deal

User avatar
CJ_RLushi
Tweeter
Tweeter
Posts: 155
Joined: Wed Dec 25, 2019 11:39 pm
Flair: Intention is what matters
Pronouns: he/him

Re: (V1.0 NOW OUT) lifeCountPlus.lua: Improved life counters

Postby CJ_RLushi » Sun Mar 29, 2020 11:43 am

You don't need to copy them into the folder, they just get loaded, even thought PNPC is deprecated so you should remove it, Enjl has a tutorial on how to do it, also, it has the same weird problem that NSMBWalls had with the DrawBox thing, i think i have a fixed version but i don't know where.

BTW, it's better to use require rather than API.load right?
My episode lol:
Image

User avatar
SPEEDIE
Blooper
Blooper
Posts: 177
Joined: Sat Nov 03, 2018 6:22 pm
Flair: I'm back.
Contact:

Re: (V1.0 NOW OUT) lifeCountPlus.lua: Improved life counters

Postby SPEEDIE » Tue Apr 21, 2020 8:57 am

It looks kind of blurry in Beta 4, why could this be?

Image


Image
If something sounds too good to be true, it probably is.
Check out my YouTube channel for high quality SMBX let's plays and other stuff.
https://www.youtube.com/channel/UCncGyz ... EqBqNJyyTQ

Check out my website for computer related fun..
https://speediegamer.github.io/spd.archive

Join my SMBX discord server for exclusive updates and much more.
https://discord.gg/fahyrvk
Finished Projects:
Image
Ongoing Projects:
Blade of Justice
4lin3r

User avatar
CJ_RLushi
Tweeter
Tweeter
Posts: 155
Joined: Wed Dec 25, 2019 11:39 pm
Flair: Intention is what matters
Pronouns: he/him

Re: (V1.0 NOW OUT) lifeCountPlus.lua: Improved life counters

Postby CJ_RLushi » Tue Apr 21, 2020 5:49 pm

Thats because of imagic stuff, i know that in nsmbwalls forum there is a fix, since both of them had the same problem, take a look at the replies.
viewtopic.php?f=101&t=18037
My episode lol:
Image

lan vuhoang
Spiny
Spiny
Posts: 28
Joined: Wed Jul 03, 2019 7:31 am

Re: (V1.0 NOW OUT) lifeCountPlus.lua: Improved life counters

Postby lan vuhoang » Tue Apr 28, 2020 4:36 am

Update this, especially since Beta 4 is released and SMBX2 Final is in development.
Also, fix the bug with the life counter not decreasing that I reported earlier and the loading bugs.
Also also, pnpc is outdated and isn't included with Beta 4, so find some way to not require it.
I support:
Spoiler: show
Image
Image
Image
Image
Image

User avatar
Cedur
Bowser
Bowser
Posts: 6805
Joined: Tue Jun 28, 2016 10:14 am
Pronouns: he/him

Re: (V1.0 NOW OUT) lifeCountPlus.lua: Improved life counters

Postby Cedur » Tue Apr 28, 2020 5:05 am

too bad the author hasn't been online for a few months. I'd also wish to know how to make this work!
Image
More Supports: show

Image
Image

Still using the legacy editor? Get SMBX2 and PGE, it will improve your experience significantly. Here's why. And remember, Yoshis are tools to be used and discarded.

ShadowStarX (06/14/18) wrote: South Korea is easy deal

User avatar
CJ_RLushi
Tweeter
Tweeter
Posts: 155
Joined: Wed Dec 25, 2019 11:39 pm
Flair: Intention is what matters
Pronouns: he/him

Re: (V1.0 NOW OUT) lifeCountPlus.lua: Improved life counters

Postby CJ_RLushi » Tue Apr 28, 2020 10:48 am

I mean i kind of got it, but i dont know if posting a fix without permission is even allowed, i just removed everything related to imagic and pnpc, and then hid the life counter with hudoverride.
My episode lol:
Image

JamesR624
Bob-Omb
Bob-Omb
Posts: 20
Joined: Wed Aug 09, 2017 4:24 pm

Re: (V1.0 NOW OUT) lifeCountPlus.lua: Improved life counters

Postby JamesR624 » Wed Jul 22, 2020 8:36 am

CJ_RLushi wrote:
Tue Apr 28, 2020 10:48 am
I mean i kind of got it, but i dont know if posting a fix without permission is even allowed, i just removed everything related to imagic and pnpc, and then hid the life counter with hudoverride.
How did you do that exactly? It seems imagic is a major part of the code. Did you replace all instances with something else or?

User avatar
Cedur
Bowser
Bowser
Posts: 6805
Joined: Tue Jun 28, 2016 10:14 am
Pronouns: he/him

Re: (V1.0 NOW OUT) lifeCountPlus.lua: Improved life counters

Postby Cedur » Wed Jul 22, 2020 12:52 pm

Dunno if I'm understanding this right but what was the point of hiding the life counter when the point of this script is to enable 3-digit lives?
Image
More Supports: show

Image
Image

Still using the legacy editor? Get SMBX2 and PGE, it will improve your experience significantly. Here's why. And remember, Yoshis are tools to be used and discarded.

ShadowStarX (06/14/18) wrote: South Korea is easy deal


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 8 guests