Page 1 of 1

How to change the score through lua?

Posted: Fri May 07, 2021 12:59 pm
by ClearMan06
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!

Re: How to change the score through lua?

Posted: Fri May 07, 2021 4:11 pm
by Emral
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)