Jump to content

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.

Link to comment
Share on other sites

  • 3 weeks later...

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')

http://twinery.org/cookbook/conditionalstatements/harlowe/harlowe_conditionalstatements.html

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...