Page 4 of 4 FirstFirst ... 234
Results 31 to 39 of 39

Thread: Need Help With Coding

  1. #31
    Member maderito's Avatar
    Join Date
    Oct 2011
    Location
    New Haven, CT
    Posts
    20

    Default

    Your avgX() function needs reworking. In the loop below, the variable "times" (originally an array) is set to a new value (and possibly no value) each iteration of the loop. Shift returns a value from an array, not an array.

    for (i=0; times.length > x; i++){
    var times = times.shift(); }

    Also, I'm not sure you've set up your number sort function correctly. See this and set up the numerical sort method exactly as shown.

    And there may be other problems in the function - I'm sure you'll figure it out.
    Sub 45' and improving

  2. #32
    Premium Member theZcuber's Avatar
    Join Date
    May 2011
    Location
    Central NY, US
    WCA Profile
    2012PRAT02
    Posts
    1,792

    Default

    Quote Originally Posted by maderito View Post
    Your avgX() function needs reworking. In the loop below, the variable "times" (originally an array) is set to a new value (and possibly no value) each iteration of the loop. Shift returns a value from an array, not an array.

    for (i=0; times.length > x; i++){
    var times = times.shift(); }

    Also, I'm not sure you've set up your number sort function correctly. See this and set up the numerical sort method exactly as shown.

    And there may be other problems in the function - I'm sure you'll figure it out.
    Oops, I forgot that x.shift() only returns the number
    The number function is set up just as it should be, it's just that the needed function is at the top of the code, and only on one line (so it's hard to find )

    I just changed it, and the average itself still works great. It's just that it will not take the last 5, but rather the first 5 times.
    RPG (CFOP and Roux) - CubingStats
    WCA - CubingUSA - canadianCUBING - UKCA
    RPG and CubingStats can be useful, try them out!

  3. #33
    Premium Member theZcuber's Avatar
    Join Date
    May 2011
    Location
    Central NY, US
    WCA Profile
    2012PRAT02
    Posts
    1,792

    Default

    I forget what I did to make it work (I did it during school), but it works now! I've also added in an avg12, 50, and 100, so that's great!

    Now how do I make it so that when I sort the array, it treats DNF as the worst (highest) number?

    Again, the URL is http://ztimer.tk/
    RPG (CFOP and Roux) - CubingStats
    WCA - CubingUSA - canadianCUBING - UKCA
    RPG and CubingStats can be useful, try them out!

  4. #34
    Premium Member theZcuber's Avatar
    Join Date
    May 2011
    Location
    Central NY, US
    WCA Profile
    2012PRAT02
    Posts
    1,792

    Default

    Alright. Now that I have the avgX function fully working, I've been trying to debug other things, which are listed below.

    When sorting numbers, DNF is not treated as the worst time.
    The scramblers are not working (3-11 are custom made, Megaminx, Pyraminx, and Clock WCA, so I'm not sure why)

    After I get these few things working, then I'll attempt to make it so you can add comments, as well as adding an inspection feature (with automatic +2s and DNFs). After I get that, then I'll officially release it!
    RPG (CFOP and Roux) - CubingStats
    WCA - CubingUSA - canadianCUBING - UKCA
    RPG and CubingStats can be useful, try them out!

  5. #35

    Default

    Am I imagining things, or are you bumping this thread by deleting and reposting that post over and over again?
    Last edited by Stefan; 02-21-2012 at 10:45 AM.

  6. #36
    Premium Member theZcuber's Avatar
    Join Date
    May 2011
    Location
    Central NY, US
    WCA Profile
    2012PRAT02
    Posts
    1,792

    Default

    Progress over the last day is amazing. Not only did I implement the inspection (with auto +2s/DNFs), I also had a very simple fix to sort the DNFs at the end. While doing that, the scramblers I've coded have magically fixed themselves (other than the ones that weren't working anyway, like the Mega and Pyra).

    If you have any requests for things to implement into the timer, ask soon, as it'll be completely released after I get the scramblers working!
    RPG (CFOP and Roux) - CubingStats
    WCA - CubingUSA - canadianCUBING - UKCA
    RPG and CubingStats can be useful, try them out!

  7. #37
    Premium Member theZcuber's Avatar
    Join Date
    May 2011
    Location
    Central NY, US
    WCA Profile
    2012PRAT02
    Posts
    1,792

    Default

    Does anybody know if, in Javascript, it's possible to use a variable when requesting another variable?

    Example:
    var cid = 1
    var cname = cid(cid value)[1]

    Is this possible, or am I SOL
    RPG (CFOP and Roux) - CubingStats
    WCA - CubingUSA - canadianCUBING - UKCA
    RPG and CubingStats can be useful, try them out!

  8. #38
    Super-Duper Moderator Lucas Garron's Avatar
    Join Date
    Jul 2007
    Location
    Where the rolling foothills rise
    WCA Profile
    2006GARR01
    YouTube
    LucasGarron
    Posts
    2,832

    Default

    Quote Originally Posted by theZcuber View Post
    Does anybody know if, in Javascript, it's possible to use a variable when requesting another variable?

    Example:
    var cid = 1
    var cname = cid(cid value)[1]

    Is this possible, or am I SOL
    Yes, it is, but it's generally considered a bad idea. If you can, you should try to write your code so this is not necessary.
    garron.us | cubing.net | twisty.js | ACube.js | Mark 2 | Regs | Show people your algs: alg.garron.us

  9. #39
    Premium Member theZcuber's Avatar
    Join Date
    May 2011
    Location
    Central NY, US
    WCA Profile
    2012PRAT02
    Posts
    1,792

    Default

    Could somebody look this over? I'm not too sure why, especially considering I just rewrote the line that's throwing the error. Here's the error that Chrome is giving me: Uncaught SyntaxError: Unexpected token ;

    Link: http://cubesites.webs.com/rpgbeta.html
    RPG (CFOP and Roux) - CubingStats
    WCA - CubingUSA - canadianCUBING - UKCA
    RPG and CubingStats can be useful, try them out!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •