0 votes
by (120 points)
Hello there, I was wondering if I could make it to where players can select a way to improve their attribute system?
Like, they go into "New Game" They pick Male or Female, then after that selection, they can choose what attribute skill, they could improve upon? For example; get 21 points, or 11 points (undecided) There will be arrows, to increase or decrease their wanted attribute tree, & when they select it, 1, 2, 3, will appear.
I hope this is making sense, lol. I have a video, but unsure of where I can put it to show you what I mean.

2 Answers

+1 vote
by (23.6k points)

First set up everything in your StoryInit passage:


<<set $upgrade to 21>>

<<set $pc to {
gender: "male",
str: 0,
agi: 0,
int: 0,
}>>

Then you can have your character creation screen look something like this:

<<nobr>>

Gender: @@#gender;male@@. - 
<<link "Change">>
  <<if $pc.gender == "male">>
    <<set $pc.gender to "female">>
  <<else>>
    <<set $pc.gender to "male">>
  <</if>>
  <<replace "#gender">>$pc.gender<</replace>>
<</link>>



<br><br>

Points to spend: @@#points;$upgrade@@

<br>

<<link "-">>
  <<if $pc.str > 0>>
    <<set $pc.str-->>
    <<set $upgrade++>>
    <<replace "#strength">>$pc.str<</replace>>
    <<replace "#points">>$upgrade<</replace>>
  <</if>>
<</link>>
@@#strength;$pc.str@@
<<link "+">>
  <<if $upgrade > 0>>
    <<set $pc.str++>>
    <<set $upgrade-->>
    <<replace "#strength">>$pc.str<</replace>>
    <<replace "#points">>$upgrade<</replace>>
  <</if>>
<</link>>

<br>

<<link "-">>
  <<if $pc.agi > 0>>
    <<set $pc.agi-->>
    <<set $upgrade++>>
    <<replace "#agility">>$pc.agi<</replace>>
    <<replace "#points">>$upgrade<</replace>>
  <</if>>
<</link>>
@@#agility;$pc.agi@@
<<link "+">>
  <<if $upgrade > 0>>
    <<set $pc.agi++>>
    <<set $upgrade-->>
    <<replace "#agility">>$pc.agi<</replace>>
    <<replace "#points">>$upgrade<</replace>>
  <</if>>
<</link>>

<br>

<<link "-">>
  <<if $pc.int > 0>>
    <<set $pc.int-->>
    <<set $upgrade++>>
    <<replace "#intelligence">>$pc.int<</replace>>
    <<replace "#points">>$upgrade<</replace>>
  <</if>>
<</link>>
@@#intelligence;$pc.int@@
<<link "+">>
  <<if $upgrade > 0>>
    <<set $pc.int++>>
    <<set $upgrade-->>
    <<replace "#intelligence">>$pc.int<</replace>>
    <<replace "#points">>$upgrade<</replace>>
  <</if>>
<</link>>

<br><br>

<<link "Continue">> 
  <<if $upgrade == 0>>
    <<goto "NextPassage">>
  <<else>>
    <<replace "#message">>
      @@color:red;Spend all remaining points before continuing.@@
    <</replace>>
  <</if>>
<</link>> @@#message;@@

<</nobr>>

 

by (120 points)
Okay, so I am new to this. As you can tell, lol.
So the passages I've created, so far...
"Introduction, Play Game, New game, Male or Female, Attribute System"
Now, if I select the Passage Male, or Female I enter this code here? Or do I enter that in the Attribute System passage?
by (120 points)
& when I tried entering that code, everything was in red. Like it won't accept the coding...
Am I doing something wrong?
by (23.6k points)

All your variables and the like should be set up in a passage called "StoryInit" - that's where the first part of my answer has to go:

<<set $upgrade to 21>>

<<set $pc to {
gender: "male",
str: 0,
agi: 0,
int: 0,
}>>

With the code above you won't need any Male or Female passage - everything could go in a single character creation passage of your choice.

by (120 points)
Alright, but why is my coding in Red?
Even when i type it out instead of copy and paste, it's Red. Like it won't work.
I know I am doing something wrong, but I am really 'new' to this. I know a small bit of coding knowledge, but not a whole lot. I wanted to expand my knowledge by just saying F it & just go straight into it. I was hoping Twine would help expand my knowledge. But as you can tell I am just out right confused.
by (2.3k points)
Did you highlight the actual code itself or all the screen contents accidentaly?

What version of Sugar Cube are you on? I'm on 2.21 and the code displays fine.

Good luck.
by (23.6k points)

Now let's take a closer look at the other elements.

<<nobr>><</nobr>> prevents any linebreaks made in between them from being shown. To do a break anyway you can enter <br>

$pc.str

The above references str property of the player character object ($pc) we have created in StoryInit. When we test the game entering the above we will see 0, which is the initial value we gave to this property. To add and substract from this property we use the <<set>> macro:

<<set $pc.str++>> \*This adds one to the property*\

<<set $pc.str-->> \*This substracts one from the property*\

<<set $pc.str+=3>> \*This adds three to the property*\

<<set $pc.str-=3>> \*This substracts three from the property*\

We can have the player add or substract from the property with the help of a link:

<<link "+">><<set $pc.str++>><</link>>

This creates a link that looks like a simple plus sign. When clicked the link won't send thje player anywhere. Instead it will add one to $pc.str. Since we only want one to be added to the property as long as the player still has upgrade points available, we use an <<if>> statement checking whether $upgrade is greater than 0 firs and then substrac one from $upgrade as well since the player spend an upgrade point:

<<link "+">>
  <<if $upgrade > 0>>
    <<set $pc.str++>>
    <<set $upgrade-->>
  <</if>>
<</link>>

Now we want to make the player see the change they made by clicking the link. For this we create a span with a specific id we can reference:

@@#strength;This text will be shown.@@

In the end game the above will just show "This text will be shown." - but invisibly to us that string will now have the specific id "strength" attached to it. We can use the <<replace>> macro to change everything within this span:

@@#strength;This is the old text.@@

<<link "New Text">>
  <<replace "#strength">>
    This will be the new text.
  <</replace>>
<</link>>

Combined with our link that adds one to the players strength ($pc.str) we can now show the player how the amount of their upgrade points and the strength of their character change when they press the "+" link:

Uprade points available: @@#points;$upgrade@@
Current strength: @@#strength;$pc.str@@

<<link "+">>

<<if $upgrade > 0>>
  <<set $pc.str++>>
  <<set $upgrade-->>
  <<replace "#strength">>$pc.str<</replace>>
  <<replace "#points">>$upgrade<</replace>>
<</if>>

<</link>>

Now we can use the same principle to substract points and then do the same for any of the other stats we have. Finally -to make sure the player can only move on once they have spend all their points- we have the Continue link check with another <<if>> whether $upgrade is zero before sending them to the next passage using the <<goto>> macro.

by (23.6k points)
Are you using the right storyformat? Click the name of your story in the lower left and then click "Change Story Format". If you have chosen anything other than sugarcube 2, change that.
by (2.3k points)
Well said. Is there a way to get the stats to increase / decrease in increment-units of 10 instead of single digits?
by (23.6k points)

I've already shown how that would work above:

<<set $pc.str++>> \*This adds one to the property*\

<<set $pc.str-->> \*This substracts one from the property*\

<<set $pc.str+=10>> \*This adds ten to the property*\

<<set $pc.str-=10>> \*This substracts ten from the property*\

 

0 votes
by (63.1k points)

I strongly suggest the <<numberpool>> macro set, which can be downloaded from here under addons. It includes docs and examples in the download. 

At a glance, @idling's answer looks totally fine, just reinventing the wheel a bit, as this macro set handles everything for you and was largely designed for creating these sorts of stat-point spending screens. 

by (120 points)
Okay so I have no idea what I am doing, I installed the sugarcube, How do I add it onto Twine? I have little coding knowledge. I wanted to improve upon it by just F it & gave Twine ago, since I prefer hands on knowledge anyway I figured this would be the best route to go.
As you can tell, I am quite confused. lol.
by (63.1k points)
The instructions to install and use the macro set are included in the download as (I believe) an html file. If you have specific questions feel free to ask, but I suggest reading that first and trying something, since at this point, without knowing where your hang-up is, all I can really do is copy paste that info.
by (120 points)
There is no installation guide, there is the LICENSE, ICON & format files that come with it.
by (63.1k points)
As I said in my post: scroll down to addons and download the <<numberpool>> macro set, not the format itself.
by (120 points)
Yahs woopsies, that was my bad lol
...