How to change the score through lua?

Post here for help and support regarding LunaLua and SMBX2's libraries and features.

Moderator: Userbase Moderators

ClearMan06
Shy Guy
Shy Guy
Posts: 9
Joined: Fri Apr 16, 2021 10:23 am
Pronouns: he/him

How to change the score through lua?

Postby ClearMan06 » Fri May 07, 2021 12:59 pm

I recently started learning lua, and it goes pretty smoothly, but I have one problem I can't seem to solve:

How would one go about changing the score through the luna.lua file?

The PGE wiki says to use Misc.score():
Image
It can read the score perfectly fine, but if I try to change it with something like Misc.score() = Misc.score() + 50 then it gives me an error message:
Image
How do I use this function correctly, so that it properly changes the score value?

Thanks in advance!

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

Re: How to change the score through lua?

Postby Emral » Fri May 07, 2021 4:11 pm

You can't just.. assign to the result of a function call.
If you're on the most recent version, you can use Misc.score(n) to add n points to the score (where n is a number)


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 2 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari