Pulp Card Type game

Hey guys!!

I’m working on my first time ever coding and I’m having some difficulty!

How would I go about coding my player to be able to use a to select a tile and move it to a new place, then place it in a new spot?

The idea is a solitaire type game where you place cards below other cards that meet certain number conditions like being 1 above or below the number.

Has anyone else tried to do something like this and had success?

Thanks!!

whenever the user presses A, an event inside the "player" script called "comfirm" is run

if you go over to the left and click on Scripts, use to top left dropdown to access the script named player. (some places in pulp, if you change the name of the player tile, it will change this script's name to match and other places, it will still say "player" so watch out for that.

in the script, of there is a section that starts with on confirm do this is where you want to be working. if there isn't, just go down to the bottom of whatever is (or isn't) there and type that in, press enter a couple of times (don't let it autocorrect "do" to be "dock") and if it doesn't do it for you, add a line that says end below.

between the on confirm do and its matching end, you'll need to add some code to do what you want. something like this

on confirm do
  new_grabbbed_tile = name event.px,event.py
  if grabbed_tile!=0 then
    tell event.px,event.py to
      swap grabbed_tile
    end
  end
  grabbed_tile = new_grabbed_tile
end

this will let the user swap any tile at any time so you may want to put some conditions in there for when this is allowed

1 Like

Hey there!

This is fantastic!!

I’m definitely going to try this out soon and see how it goes!

I also really appreciate how you described things in a way I could understand!

I do have another question though, the part in the script you wrote out that says, name, would I just put the text name or the name of a tile?

oh nope, name is a built in function

basically, anytime you say a = name x,y it will take the name of the tile at position x,y on the screen and save it to the a variant

in the case of what I wrote, it takes the name of the tile at event.px,event.py and saves it to a variable named new_grabbed_tile. event.px and event.py are special values that will always match the player's location. new_grabbed_tile is just a made up variable name so we can have a way to hold on to what tile is being selected. you could have picked any variable name.

I suppose I should say what this does exactly

as the user pressed buttons on the dpad, they will move the player around (this is just the default behavior of a Pulp game) and when they press A, this script will run and will

  1. save the name of the tile the player is on
  2. if there was a tile grabbed before this, change the tile they are on to whatever was last saved
  3. make the new saved tile name the saved one for next time

I hope that is what you're asking for or is close enough

1 Like

Okay, I finally got it to work!

Here is my current working code!

heldtile = name event.px,event.py
if holding == 0 then
tell event.px,event.py to
swap selectedtile
end
end
selectedtile = heldtile

(im not sure how to make the code look like you've done yours!)

But now i'm going to try and work at having things happen based on what tiles are around the other placed tiles.

Thank you!

if you want to have formatted code in a reply here, you have to put three tick marks above and below it. tick marks as in the backwards looking apostrophe, it is usually the key above tab and to the left of 1 on your keyboard. This guy `
So you put three of them, press enter, paste code, press enter, put three more ticks and it will keep your indents and make everything spaced like code

1 Like