Code Monkey home page Code Monkey logo

Comments (4)

astashov avatar astashov commented on July 18, 2024

You have to declare the variable in the section above, "Variables", like this:

image

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.

tom-a-horrocks avatar tom-a-horrocks commented on July 18, 2024

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.

astashov avatar astashov commented on July 18, 2024

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.

tom-a-horrocks avatar tom-a-horrocks commented on July 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.