Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Is there a block that blocks objects?

A topic by Phantosler created Feb 12, 2020 Views: 131 Replies: 5
Viewing posts 1 to 3
Submitted

Making a shop like that in TWO and I wanna block the player from taking the items unless they give the shopkeep coins. Is there a block that can help with this? Can't seem to find it in the documentation....

Submitted

The short answer is no. There are a number of ways to handle this. The easiest way is to set a flag when the item has been purchased. When you get it, you make sure that the flag is set before allowing it to be taken. Let's say the object is a ring. In order to set the flag, you set it when you GIVE COINS (and the ring is implied) or BUY RING (and the coins are implied). If that's not clear, let me know and I'll post some sample code. I've got something similar in my game that I was just working on last night.

Submitted

If you could post sample could that would be lovely thank you! Im a little confused

Submitted(+1)

I'm doing this on a text editor at work, so I hope I got it right:

booleans {
   has_bought_ring : boolean "false";
}
on_command {
   : match "get ring" {
      : if (is_present "ring" && !has_bought_ring) {
         : print "\"$100 please.\"";
      }
   }
   : match "buy ring;give money" {
      : if (is_present "ring") {
         : if (is_carried "money") {
            : set_true "has_bought_ring";
            : destroy "money";
            : print "\"It's yours.\"";
         }
         : print "No money.";
      }
   }
}

I am assuming that you are in a jewelry store with a ring on display. There is a shop attendant to sell you the ring. It costs $100. You have some money in your pocket. It happens to be $100. The money is destroyed when you buy the ring so that you can't use it again. After purchasing the ring, it is left for you to take. Alternatively, replace :destroy "money"; with :swap o1 = "money" o2 = "ring"; if you want the ring to be pocketted automatically.

A sample transcript might go like this:

> GET RING

"$100 please."

> BUY RING

"It's yours."

>GET RING

[auto redescribe occurs]

Submitted

Follow up, what are the sounds played when a player tries to go a direction blocked by a barrier?

Submitted

I think it's the failure jingle. To test it, just use : failure; somewhere in your own code.