Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Trying to figure out error MSG

    Help
    5
    13
    416
    Loading More Posts
    • 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.
    • K
      kendog400 F last edited by Martin

      I have here a program that deals cards...
      I trying to print on the screen the value of the card and the suit at line 15
      but all I get is varible doesent exist......
      can anyone see what I did wrong ?

      clear(darkGreen)
      image = loadImage ("Kenney/boardgames")
      suits = ["clubs", "diamonds", "hearts", "spades"]
      array cards [52}
      getPack ( )
      shufflePack ( )
      
      for i = 0 to 5  loop   // this will flip the 5 cards to the screen
      sprite = cards [ i ]
      size = getSpriteSize (sprite)
      setSpriteLocation (sprite, i % 13 * (size.x + 30) +50, int (i / 13 ) * (size.y + 5) + 200)
      setSpriteVisibility(sprite, true)
      //--------------------------------------------------------------------------
      // Tried to put print command here
      drawText(30,150, 80 black, valueNo)  // tried to print value
      drawText(40,150, 80 black, suitNo)    //  tried to print suit
      //--------------------------------------------------------------------------
      drawSprites ( )
      update ( )
      sleep(0.7)
      repeat
      
      function shufflePack ( )
         cardIndex1 =  random (52)
         cardIndex2 =  random (52)
         card1 = cards [cardIndex1]
         card2 = cards [cardIndex2]
         cards [cardIndex1] = card2
         cards [cardIndex2] = card1
        repeat
      return void
      
      function getPack ( )
      values = [ [0,"2"], [1,"3"], [2,"4"], [3,"5"], [4,"6"], [5,"7"], [6,"8"], [7,"9"], [8,"10"], [12,"A"], [9,"J"], [11,"K"], [10,"Q"], ]
      imageNo = 0
       for suitNo = 0 to 4 loop
         for valueNo = 0 to 13 loop
         cardNo = suitNo * 13 values[valueNo] [0]
         sprite = createSprite ( )
         cardImage = getImage (imageNo)
         setSpriteImage(sprite, cardImage)
         setSpriteVisibilty(sprite, false)
         setSpriteDepth(sprite, cardNo)
         size = getSpriteSize(sprite)
         setSprieOrgin(sprite, -size,x/2, -size.y/2)
         scale = 1.5
         setSpriteScale ( sprite, {scale, scale} )
           sprite.value = values [valueNo] [1]
           sprite.suit = suits [suitNo]
           sprite.imageNo = imageNo
           cards [cardNo] = sprite
           imageNo + = 1
           if imageNo = 39 then
           imageNo + = 1   endif
         repeat
        repeat
      return void
      
      function getImage (imageNo)
      cardImage = createImage(140, 190, false, image_rgb)
      setDrawTarget (cardImage)
      drawSheet(image, imageNo + 15, {0, 0, 140, 190} )
       update ( )
      return cardImage
      //..........................................................................
      
      1 Reply Last reply Reply Quote 0
      • Martin
        Martin Fuze Team last edited by

        Yeah, you're missing comma's after the 80's in these commands:

        drawText(30,150, 80 black, valueNo) // tried to print value
        drawText(40,150, 80 black, suitNo) // tried to print suit
        

        At least that

        1 Reply Last reply Reply Quote 2
        • Martin
          Martin Fuze Team last edited by

          Also, valueNo and suitNo don't exist at the top level, only within a function later down so as far as the program goes, it knows nothing about them.

          1 Reply Last reply Reply Quote 2
          • Dave
            Dave Fuze Team last edited by Dave

            It looks to me like you're using valueNo and suitNo in your print statements when you want to be using the custom properties you've assigned to the sprites already:

            In your getPack() function, you have:

                 sprite.value = values [valueNo] [1]
                 sprite.suit = suits [suitNo]
                 sprite.imageNo = imageNo
            

            As @Martin pointed out, the valueNo and suitNo variables are local to the functions that create them. But, since you're using them to assign information to the custom properties sprite.value and sprite.suit, then storing them in the cards array, you should use those properties in your print statements:

            drawText(30,150, 80, black, sprite.value) // I've added the missing commas Martin pointed out
            drawText(40,150, 80, black, sprite.suit)
            

            I thought at first these would have to be cards[i].value and cards[i].suit but since beforehand you write sprite = cards[i], this should be correct.

            1 Reply Last reply Reply Quote 2
            • K
              kendog400 F last edited by

              Working perfectly now.....Thanks again !

              1 Reply Last reply Reply Quote 1
              • Dave
                Dave Fuze Team last edited by

                Excellent! Very glad to hear it :)

                1 Reply Last reply Reply Quote 0
                • K
                  kendog400 F last edited by

                  I've been trying to frend you (Dave) but it says frend not found.
                  Is your # 5130-4176-1902 ?

                  1 Reply Last reply Reply Quote 0
                  • K
                    kendog400 F last edited by

                    It seems that if you friend waldron your friend screens turns grey,
                    so now I want to friend fuze team members to stay safe....

                    pianofire 1 Reply Last reply Reply Quote 0
                    • pianofire
                      pianofire Fuze Team @kendog400 last edited by

                      @kendog400 That should have been fixed

                      1 Reply Last reply Reply Quote 0
                      • K
                        kendog400 F last edited by

                        Do you know Dave (Fuze Team) friend code ?

                        pianofire 1 Reply Last reply Reply Quote 0
                        • pianofire
                          pianofire Fuze Team @kendog400 last edited by

                          @kendog400 He doesn't seem to have published it.

                          1 Reply Last reply Reply Quote 0
                          • Martin
                            Martin Fuze Team last edited by

                            As @pianofire says the issue with Waldron’s shares has been found and fixed. If you’ve tried again today and it’s not working please do let us know.

                            1 Reply Last reply Reply Quote 1
                            • waldron
                              waldron F last edited by

                              5139 4176 1902 thats daves, i shouldnt have any issues now been clear for 6 days!!!!!

                              1 Reply Last reply Reply Quote 1
                              • First post
                                Last post