I'm trying to implement a gamification system in org-mode.
Basically, I assign a number of points to a checkboxed task and when I tick the checkbox I add the number of points to a total at the top of my file.
I'm trying to write a function that does this automatically, like for example turning this:
Total points: 45 - Things to do today - [ ] Wa|sh clothes: 5
Total points: 50 - Things to do today - [X] Wa|sh clothes: 5
when the cursor is at the vertical bar.
How would I write a function that extracts the number from the end of the line and stores it in a variable, extracts the top number and stores it in a variable, adds the variables together and replaces the top number with the new total?