Sign in to follow this  

How to display text based on variables

Recommended Posts

I'm trying to make a puzzle game with Twine, and I want to know something that requires a single line of code but have to learn the whole language to figure out what to do. Let's say that at some point the player gets an axe. I'd set a variable "axe" to 1. Then, later in the game, there's a tree in the player's way. I want to have it so that the option to chop down the tree only appears when the player has the axe. So, if "axe"=1, an option to cut the tree appears. I tried googling it but I couldn't find what I'm looking for. Also, let me know if my assumptions are completely wrong. If I don't get help, I'll have to take a stupid course just to do one thing.

Share this post

Link to post
Share on other sites

You're almost certainly best of asking this in the Twine forums (I think they also have a Discord channel) to find out how to do it in that platform.

In general programming you're talking about applied logic, specifically you're after a conditional. As this is (primarily) a javascript board the following is a JS example:

// Create a variable, we're also initialising it here because we are pros
var axe = 1

// Conditional
if (axe === 1) {
  // This is an example of a function call, it just does 'something'
  setOption('Cut down the tree with an axe')

// Here is another function call
setOption('Punch the tree')

Twine has its own syntax (three by the looks of it) for doing the same as the above, in fact, I'm not sure I've ever heard of a programming language that can not do it.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.