Not able to save

ok, thanks

I understand what your code is doing but what would you put inside the add to pile block, I had some if statements so depending on "i" you would go to a different set of coordinates but it isn't working, none of the sprites are going anywhere except for the computer sprite where I'm running it. I haven't added the other positions, just trying to get it working for the one

You can simplify the "add card to pile" block like so:


Like shown in the comment, you add the x-coordinates for each pile into the first sublist (the first lightly colored one) and the y-coordinates in the other sublist.

I tried that but with just a go to block with a set of cordinates, why wouldn't that work

Do you have the a script pic of the "go to position 1" block? That may clear up the confusion once I know what it does.


What does "position 1" do?

its just a go to block with a set of cordiantes

You can just take the code from "position 1" and move it into "go to position 1", and create a dropdown list for the "go to position" block.

I noticed you have many sprites for each card (you can reduce the file size greatly by having one sprite with all the card costumes): The easy way to do this is to use the "tell" block. This'll tell the sprite to actually go there. Here's the new and improved script:


Again, you could have an if block for each pile, but this would be more efficient.


This isn't the entire block; you also have to push CARD onto the list of cards on the pile. You can either make seven variables PILE1 through PILE7, or you can have one variable PILES that's a list of seven lists.

Two things you didn't know: the TELL block and the fact that you can compute the XY coordinates from the pile number. (I'm just guessing about the numbers 50, 250, and 50; use whatever numbers you like.) Computing the coordinates avoids the need for the seven IF blocks.

The empty input slot in the multiplication block is intentional; the variable PILE will be put in there because of the WITH INPUTS in the TELL block.

Still not working, have that exact same thing, also bclot, I have to have that many sprites, i don't know of a way to be able to show that many costumes at the same time with one sprite, also I would have to remake much of my program.

For some reason, only the computer sprite is going to the position, not the correct sprite

Want to post your current ADD TO PILE block?


Well one problem is that with that formula for X, all the sprites will end up offscreen past the right edge. x=250, x=310, x=370, ...

But I don't know how the computer sprite would do the command instead of the card sprite. Maybe for debugging you could put a SHOW VARIABLES (card) at the beginning of the ADD TO PILE block, and HIDE VARIABLES (card) at the end. And I guess WAIT 0.1 SECS after the SHOW so it actually appears on the stage. Then you can make sure CARD is really a card.

I meant -250. I'll try that debugging

It's working now, I ran it only within the computer sprite instead of having all of them running it. I don't know why I had them all running it before, but it works now

I added this if statement to make it so that if the card was on top, it goes to the face costume of the card, otherwise it goes to the back. Its not working though, is it something I did wrong with the = statement?Solitaire%20script%20pic
I also tried it with pil=1 ect. until pile=7 with or statements connecting them, and it still didn't work.

What your code does is tell the selected card sprite to go to its pile location. But the if statement here does not do what you intend to do. First, or statements return true or false values, so the = statement here would return a true or false value depending on whether or not the integer is equal to "true" (integers are not equal to true or false values, this would return a false value). I would recommend instead using "if (numbers 1 to 7) contains (pile)".
The if statement will not detect if a card is on top, it'll just detect if the pile is one of those numbers. I'm not sure how exactly you're going to pull it off, but looking at some card game projects on Scratch, those ones detect how many cards are in the pile or pull off some tricks that involve costume numbers and the amount of cards in a pile.

I did this to fix it

but it doesn't put the right cards face up. I used this in my previous layout block and it put the right cards face up.