Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • CreatiCode
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

CreatiCode Scratch Forum

  1. CreatiCode Forum
  2. Feedback
  3. Key pressed bug

Key pressed bug

Scheduled Pinned Locked Moved Feedback
5 Posts 3 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Ethan K
    wrote on last edited by
    #1

    For some reason the following code crashes the site:

    when [any] key released
    set [#] to ("0")
    repeat("10")
     if <key (#) is pressed> then
      set [type] to (#)
     end
     change [#] by ("1")
    end
    
    Tyller_T 1 Reply Last reply
    0
    • Tyller_T Offline
      Tyller_T Offline
      Tyller_
      trusted helpers
      wrote on last edited by
      #2

      @ek43680-wdmcs can you send a picture of the blocks? The get scripts for sprite is useful but doesn’t include stuff like parentheses for ordering

      <div component="post/signature" data-uid="255" class="post-signature">Check out my chat room project so you ppl can not use forums as chat rooms! https://play.creaticode.com/projects/66f2e1dcd1be43d82b886fbd?version=1 <p dir="auto">
      </div>

      1 Reply Last reply
      0
      • E Ethan K

        For some reason the following code crashes the site:

        when [any] key released
        set [#] to ("0")
        repeat("10")
         if <key (#) is pressed> then
          set [type] to (#)
         end
         change [#] by ("1")
        end
        
        Tyller_T Offline
        Tyller_T Offline
        Tyller_
        trusted helpers
        wrote on last edited by
        #3

        @ek43680-wdmcs recreating it and dissecting, the issues appears to be the change variable by block sets the variable to a number value, the set makes it a string, the change var by block works with turning numbers that are currently a string to a number and increasing (a string is what a program lets be any text incase somebody reading doesn’t know), but it turns the variable output into a number, so any string inputs (I tried fixing it with uppercase/lowercase of text and it froze it running that alone) just freeze when given a forced number value (the variable after a change by block is ran is turned from a string into a number)

        As of typing I have found that the join block fixes this, so replace the lone # in the key # pressed block with a join (#) () block and it’ll work the exact way as it would of without the join but without freezing

        <div component="post/signature" data-uid="255" class="post-signature">Check out my chat room project so you ppl can not use forums as chat rooms! https://play.creaticode.com/projects/66f2e1dcd1be43d82b886fbd?version=1 <p dir="auto">
        </div>

        CreatiCodeI 1 Reply Last reply
        0
        • Tyller_T Tyller_

          @ek43680-wdmcs recreating it and dissecting, the issues appears to be the change variable by block sets the variable to a number value, the set makes it a string, the change var by block works with turning numbers that are currently a string to a number and increasing (a string is what a program lets be any text incase somebody reading doesn’t know), but it turns the variable output into a number, so any string inputs (I tried fixing it with uppercase/lowercase of text and it froze it running that alone) just freeze when given a forced number value (the variable after a change by block is ran is turned from a string into a number)

          As of typing I have found that the join block fixes this, so replace the lone # in the key # pressed block with a join (#) () block and it’ll work the exact way as it would of without the join but without freezing

          CreatiCodeI Offline
          CreatiCodeI Offline
          CreatiCode
          wrote on last edited by
          #4

          Thanks @Tyller_

          That’s correct. Currently, the “key ( ) is pressed” block expects a string, so plugging in a variable causes it to fail. We will release a hotfix for it later today. Sorry about that.

          And joining the variable with an empty string would fix that issue for now.

          In addition, @ek43680-wdmcs , in your original code, the code is triggered by “when [any] key released” event, which needs to be changed to “when [any] key pressed”. That’s because the “when [any] key released” block runs when the key has been released already, so the “key () is pressed” block will not find any key in the “pressed” state.

          Here is the corrected program:

          5f4e86a9-d47a-478b-8061-18e438add045-image.png

           
          Here is the project:

          https://play.creaticode.com/projects/65677a359037505e69aa1bed

          CreatiCodeI 1 Reply Last reply
          0
          • CreatiCodeI CreatiCode

            Thanks @Tyller_

            That’s correct. Currently, the “key ( ) is pressed” block expects a string, so plugging in a variable causes it to fail. We will release a hotfix for it later today. Sorry about that.

            And joining the variable with an empty string would fix that issue for now.

            In addition, @ek43680-wdmcs , in your original code, the code is triggered by “when [any] key released” event, which needs to be changed to “when [any] key pressed”. That’s because the “when [any] key released” block runs when the key has been released already, so the “key () is pressed” block will not find any key in the “pressed” state.

            Here is the corrected program:

            5f4e86a9-d47a-478b-8061-18e438add045-image.png

             
            Here is the project:

            https://play.creaticode.com/projects/65677a359037505e69aa1bed

            CreatiCodeI Offline
            CreatiCodeI Offline
            CreatiCode
            wrote on last edited by
            #5

            FYI the issue with the “key ( ) is pressed” block has been fixed. Thanks for reporting the issue.

            1 Reply Last reply
            0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • CreatiCode