Comments (4)
You have to declare the variable in the section above, "Variables", like this:
The reason I'm not allowing to declare a state variable in a finish day script is that the variables could be used not only in "Finish Day Script", but also in "Reps" and "Weight" fields of exercises, and they have the state that is stored through workouts. And regular (not state) variables that would only exist in the scope of "Finish Day Script" are not available, unfortunately.
But, the actual bug here is that you can use state variable inside the if/else without declaring it in the "Variables" section! I'll look into that, thanks a lot for reporting! :)
Also, there're some docs about scripting: https://www.liftosaur.com/docs/docs.html#state-variables-and-finish-day-script
from liftosaur.
Thanks, don't know how I missed that Add Variable button!
One other thing I noticed: When adding a new exercise to a routine, the default Finish Day Script does a comparison between arrays, i.e. completedReps >= reps
in:
// Simple Exercise Progression script '5lb,1'
if (completedReps >= reps) {
state.successes = state.successes + 1
if (state.successes >= 1) {
state.weight = state.weight + 5lb
state.successes = 0
state.failures = 0
}
}
After looking up how inequality operators work on arrays in javascript, it ocurred to me that this can indicate 'success' when most sets are failed:
reps = [5, 5, 5]
completedReps = [6, 1, 1] // First set was AMRAP
completedReps > reps // evaluates to true
It's unlikely to have an AMRAP on the non-last set so it's probably not a big issue. My choice of default would be the javascript equivalent of the python snippet:
all(cr >= r for cr,r in zip(completedReps, reps))
... but I have no idea what that looks like in JS :).
Thanks!
from liftosaur.
It's not JS though, it's Liftoscript!
A super-duper simple language made specifically for the app. https://www.liftosaur.com/docs/docs.html#language-reference
Syntax is similar to JS though.
completedReps >= reps
is essentially the same as comparing each element of completedReps
and reps
, i.e. completedReps[0] >= reps[0] && completedReps[1] >= reps[1] && ...
etc. Just a little syntax sugar :)
So, if:
reps = [5, 5, 5]
completedReps = [6, 1, 1]
then completedReps >= reps
would return false
, because second and third sets didn't reach the required minimum threshold of 5 reps.
Another difference of Liftoscript from Javascript is that you can specify the weight units. I.e. something like:
state.weight = state.weight + 10lb
would increase the weight variable by 10lb or by ~5kg, depending on whether you use kg or lb units.
from liftosaur.
Oh that's excellent! I saw the weight information in the language reference, but I think content about the array comparison is missing. I'll have a shot at adding it in a PR :).
from liftosaur.
Related Issues (11)
- Alternative Login and/or Self-Host HOT 3
- Add Volume statistics HOT 6
- Notification issues
- Copy from previous program HOT 2
- No LICENSE file HOT 1
- After the new update, closing the app with an on-going workout deletes that particular workout HOT 2
- App upgraded but features now are behind paywall HOT 4
- Cannot import data/program HOT 1
- Cannot redeem code/buy subscription without GPS
- Squat Form for the Squat Image is Funny HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from liftosaur.