Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Basic stat system

I want to make a stat system, if you chose right, you get +1 in that stat. and if you want have high enough stat you cannot chose that option later in the story.


  • You do that by setting a variable and then adding to it. Literally adding to it. Like with a plus sign.

    So your starting health is "whatever," right? But then you go either "whatever" plus one, or even "whatever" minus one for an injury.

    However... if I can make a suggestion:
    You have to be specific in your questions in order to get help.
    In no particular order:
    1. Story format.
    2. Some code examples, perhaps.
    3. Concrete questions.

    Also, we want to see some effort. At least a search of the forums.

    PS, I'm not really a jerk, I just play one on TV.


    Good luck.
  • Since you asked a SugarCube 2.x question in another thread, I'm going to assume that's still the case. However, you should always specify the story format (via the tags, at least).

    If I'm understanding what you want to do, then you should probably start by looking at the <<click>> macro or setter links.

    Beyond that, however, I'm unsure exactly what you want (some clarification would help).

    Are you looking for a way for the player to explicitly upgrade stats (e.g. a level up screen) or, perhaps, a way for the player to implicitly upgrade stats (e.g. choosing to bash down a door might raise strength). The OP sounds like the former, but I'm unsure.
  • The following will work in all the different Twine 1 story formats, it consists of four passages named StoryInit, Start, Go to the Gym, and Next Day.

    1. StoryInit
    This is a special passage where you should initialize all your $variables
    We are going to use $strength to track the characters current strength.
    <<set $strength to 0>>

    2. Start
    What would you like to do today?
    [[Go to the Gym]]

    3. Go to the Gym
    The following check the characters $strength and if it is currently below 2 (two) then the Free Weights option is shown, this option when clicked will increase the characters $strength by 1 (one) and then send the Reader to the Next Day passage.
    What sort of exercise would you like to do?
    <<if $strength lt 2>>
    	[[Free Weights|Next Day][$strength to $strength + 1]]
    [[Jogging|Next Day]]

    4. Next Day
    A filler passage to allow the Reader to visit the Gym again.
    After working out you go home, have a sleep and then get up ready for a new day.
    What would you like to do today?
    [[Go to the Gym]]

    note: If you are using the SugarCube story format then you could change the Go to the Gym passage to use some of its built-in features as suggested by @TheMadExile
    What sort of exercise would you like to do?
    <<if $strength lt 2>>
    	[[Free Weights|Next Day][$strength to $strength + 1]]
    	<<click "Bench Press" "Next Day">><<set $strength to $strength + 1>><</click>>
    [[Jogging|Next Day]]
  • Wow. This is well above and beyond the call. Thank you for so much effort in the explanation. And this isn't even my post!

    I swear between you and TheMadExile I don't know who is more helpful.

    Wait a minute.

    Why do we never see the two of you in the same room at the same time..........?
  • Personally I would say @TheMadExile, besides him being very helpful he did after all create a feature rich and extendable story format.
  • edited June 2015
    Hands down my favorite format.
  • edited June 2015
    I think if Twine 1.4.2 had a few extra workflow developments SugarCube would be more or less the equivalent of Ren'Py for making visual novels.

    My Twine story now looks like it should have been made in Ren'Py, but it does everything I need so there's no reason to switch.

    Not really on topic, but since we're talking about the merits of SugarCube, there you go.
  • @Claretta
    Wow. I hadn't heard of Ren'Py before. It reminds me exactly of CoraBlue's stuff in Twine. Is that who built Ren'Py?
  • edited June 2015
    No no. CoraBlue is just a forum member who did some interesting CSS things and posted them here.

    Ren'Py is maintained by a completely different community - like the Twine for visual novels. I just find that with a few modifications, Twine gets just as good visual novel results.
  • I would have to agree considering I couldn't distinguish between CoraBlue's Twine engine and Ren'Py.
    But we should be careful before @Sharpe moves us to "Chit-Chat." I imagine it's like sitting at the kid's table!
  • Speaking of CoraBlue, they've actually demoed two different frameworks. The most recent had strong VN styling, while the older one had strong classic-Final Fantasy/RPG Maker game styling.
  • Oh wow. Is there a website I can find it at?
  • Not that I know of, no. AFAIK, the RPG framework was only ever posted to these forums and the original download links are now defunct. Unfortunately, I seem to have lost my copy (or I never grabbed one), so I can't help you out. I think @Sharpe was rumored to still have a copy.
  • Im sorry running SugarCube v2.0.0-beta.4:
    This is what im trying to do:

    I want to display in StoryCaption, so I have made the passage StoryCaption where I want to display how much strength I have.

    <<display $strength>>


    <<set $strength to 0>>

    But when im trying to run the game I get the error message Error: <<display>>: passage "1" does not exist
    What Are im doing wrong ?
  • The <<display>> macro is used for including other passages, not printing the values of $variables.

    Simply to print the value of a $variable, just include the $variable in your text. For example:
    Strength: $strength
    If you ever need to print something more complex (e.g. the result of an expression), then you'd use the <<print>> macro.
  • @TheMadExile and @greyelf you are a life saver :D
  • How do I use the macro not to choose a <<choose>> when you have to lit $strength ?
  • edited June 2015
    Please use full words. Non-standard abbreviations (e.g. "lit" instead of "little") aren't helpful.

    Assuming you meant, how do you do something like the examples greyelf gave to check for too little strength, rather than too much, then you'd use the gt/ gte operators (greater-than/greater-than or equal; see: <<if>> macro, which lists all of the TwineScript conditional operators). For example:
    <<if $strength gt 2>>
    	do something if $strength is greater-than 2
    <<if $strength gte 2>>
    	do something if $strength is greater-than or equal to 2
    If you wanted to do something in either case, then you'd need to add as <<else>> clause to your <<if>>. For example
    <<if $strength lt 2>>
    	do something if $strength is less-than 2
    	do something else if $strength is greater-than or equal to 2
    <<if $strength gt 2>>
    	do something if $strength is greater-than 2
    	do something else if $strength is less-than or equal to 2
    And there's also <<elseif>>, which go after the opening <<elseif>>, but before the <<else>> (if you have one). For example:
    <<if $strength lt 3>>
    	do something if $strength is less-than 3
    <<elseif $strength lt 6>>
    	do something else if $strength is less-than 6,
    	but not less-than 3 since that would have matched previously
    <<elseif $strength lt 9>>
    	do something else if $strength is less-than 9,
    	but not less-than 6 since that would have matched previously
    	do something else if $strength is greater-than or equal to 9
Sign In or Register to comment.