0 votes
by (2.3k points)

I have, thanks to you good folks, got my custom character passages done. :)

The bad news is, I have a lot of skill points for the player to allocate to the character. About 650 to be exact! LOL.

<<set $pcStats to {
int: 0,
str: 0,
agi: 0,
dext: 0,
perc: 0,
stl: 0,
}
>>
<</nobr>>
<<nobr>>
Spend all points on desired characteristics: @@#points;$upgrade@@ (remaining)

<br>

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

<br>

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

<br>

Dexterity<<link "-">>
  <<if $pcStats.dext > 0>>
    <<set $pcStats.dext-->>
    <<set $upgrade++>>
    <<replace "#dexterity">>$pcStats.dext<</replace>>
    <<replace "#points">>$upgrade<</replace>>
  <</if>>
<</link>>
@@#dexterity;$pcStats.dext@@
<<link "+">>
  <<if $upgrade > 0>>
    <<set $pcStats.dext++>>
    <<set $upgrade-->>
    <<replace "#dexterity">>$pcStats.dext<</replace>>
    <<replace "#points">>$upgrade<</replace>>
  <</if>>
<</link>>

//ETC ETC//

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

<</nobr>>

Is there any way to have the points added in increments of 10? Or even entered manually for each one via a box caption etc?

Thanks

3 Answers

+1 vote
by (23.6k points)

The answer to that question is the same I gave last time. To add or substarct ten you replace for example

  <<if $pcStats.int > 0>>
    <<set $pcStats.int-->>
    <<set $upgrade++>>
    <<replace "#intelligence">>$pcStats.int<</replace>>
    <<replace "#points">>$upgrade<</replace>>
  <</if>>

with

  <<if $pcStats.int > 10>>
    <<set $pcStats.int -= 10>>
    <<set $upgrade += 10>>
    <<replace "#intelligence">>$pcStats.int<</replace>>
    <<replace "#points">>$upgrade<</replace>>
  <</if>>

Now use the same principle on the rest of the code.

by (2.3k points)
I tried that code and it decreases it by increments of 10 only, no increase by 10.

Also I can't fine-tune it to BOTH 10 and 1 increase/decrease can I?
by (23.6k points)
edited by
You can just add two links - one the original that adds/substracts by 1 and the updated one that adds/substracts by ten. Also the above of course only substracts int by ten. You'll have to change it to add somthing to int. If you don't know how to do that, then you don't understand the very code you are using and should ask questions pertaining to that.
by (2.3k points)
Yep yep and yep. I'm not a coder guy, just a story guy trying to get by. :)
by (23.6k points)
Then which part of the code do you not understand?
by (2.3k points)
edited by
I'm just working on it again and I'll be right back...
by (2.3k points)
Excellent. I got there in the end. The only thing now:

Is there some way to cap the rating at '100' and no higher?

Thanks.
by (23.6k points)

That's what you would use your <<if>> statements for. They will check whether a specific condition is reached and execute the code within accordingly:

<<if $upgrade > 0>>
...
<</if>>

for example checks whether there are any upgrade points left

<<if $upgrade >= 10>>
...
<</if>>

Will check whether there are more than ten upgrade points left.

<<if $pcStats.int < 100>>
...
<</if>>

Would check whether pcStats is smaller than 100 - basically preventing any additional points being added once that limit is reached.

You can combine these conditions using and/or:

<<if $upgrade > 0 and $pcStats.int < 100>>
...
<</if>>

<<if $upgrade >= 10 and $pcStats.int <= 90>>
...
<</if>>

 

by (2.3k points)
Thanks there Idling! You are anything BUT Idling with this wonder code!
+1 vote
by (68.6k points)

As an alternative to idling's answer.

You could take a look at the <<numberpool>> macro set add-on, which was pretty much written with what you want to do in mind.  You can find it on SugarCube's website under Downloads > Add-ons.

 

0 votes
by (300 points)
I know practically nothing of Sugarcube, but "less clicky" made me think of this, and you may find it useful

http://twinery.org/questions/4797/any-way-to-bind-keyboard-inputs-to-links-in-twine-harlowe-2-0
...