Howdy, Stranger!

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

"Remembering" character creation options

edited June 2015 in Help! with 2.0
So I'm trying to set up a simple "create your own character" sequence to start my... RPG? I suppose. I've got the individual lines working, but I can't figure out a way to have the game remember what you previously chose.

The game is currently set so that a player chooses like so:
1) Skin color.
2) Body type.
3) Hair length.
4) Hair color.

All of these link, in order, from all of the others (ex: Light skin -> Heavyset -> Short hair -> Blue hair), but I can't find a way to preserve those options afterwards (ex: Character creation step -> You are a light skinned, heavyset warrior, with short, blue hair.) So... any ideas on how to do so? Thanks a bundle; I've tried searching for a workaround, but I've had no luck!

Also, any certain code to let the player input their own character name, and remember it for later?

(Oh, and I'd take an answer using Harlowe or SC - whichever is easier?)

Comments

  • In a word "Variables"

    The following is for SugarCube 2 and consist of five passages:

    1. StoryInit
    The special passage where all your variables should be assigned default values.
    <<set $name to "">>
    <<set $SkinColor to "">>
    <<set $BodyType to "">>
    <<set $HairLength to "">>
    <<set $HairColor to "">>
    
    2. Start
    The first passage of your story
    [[Character Creation]]
    
    3. Character Creation
    This passage contains a <<textbox>> macro where the Player enters their name, as well as the other option links. Only Skin color has been implemented.
    What is your name? <<textbox "$name" $name>>
    
    1) [[Skin color]]: $SkinColor
    2) [[Body type|Not Done Yet]]: $BodyType
    3) [[Hair length|Not Done Yet]]: $HairLength
    4) [[Hair color|Not Done Yet]]: $HairColor
    
    4. Skin color
    This passage allows a Player to select a skin color
    Please select a Skin color:
    
    [[Light skin|Character Creation][$SkinColor to "Light skin"]]
    [[Dark skin|Character Creation][$SkinColor to "Dark skin"]]
    [[Blue skin|Character Creation][$SkinColor to "Skin skin"]]
    
    5. Not Done Yet
    A filler passage so the other options in the Character Creation don't complain.
  • Perfect, thank you so much! One follow-up question: is there a way to do the same kind of name-choosing in Harlowe?
  • If you search the forums for textbox you will find this discussion, which explains that there is no built-in equivalent but includes some other people's inventive ways to implement something similar.
  • This is so well laid out, thanks a ton Elf.

    (Main follow up question) The passages that spawn off the chosen options aren't used for anything as laid out here and can be deleted right (Long hair, short, bald, white, black, blue etc.)

    If we wanted NPCs to judge on appearance by adding and ranking all the options for starting relationship values:
    Sue likes all your options and ranks you 4,4,4,4= 16
    Mary hates your options 1,1,1,1= 4

    Would that code be in those 16 blank boxes? I would think not, it seems like more work. Is it easier to have a stat page for each NPC showing their likes, or build it into one of the Story files? I guess it would depend on the number of NPC's?

    I guess I'm seeing at least 3 ways to do this and am looking to the easier path.
  • (Main follow up question) The passages that spawn off the chosen options aren't used for anything as laid out here and can be deleted right (Long hair, short, bald, white, black, blue etc.)
    The reason the Twine 2 application creates all those unneeded passages is currently the syntax highlighting and auto missing passage creation features only understand/support standard markup links, so advance link types like a Setting Link confuse it.
  • Twine2 Sugarcube

    Here is what I went with. For each NPC I'll use something like this and I put it in the Start page:

    <<if $HairColor is "Chestnut">><<set $TestSubject to +1>><</if>>
    <<if $HairColor is "Red">><<set $TestSubject to +10>><</if>>
    <<if $HairColor is "Black">><<set $TestSubject to +1>><</if>>
    <<if $HairColor is "Blonde">><<set $TestSubject to +5>><</if>>

    <<if $HairLength is "Short">><<set $TestSubject to +10>><</if>>
    <<if $HairLength is "Shaved">><<set $TestSubject to +5>><</if>>
    <<if $HairLength is "Long">><<set $TestSubject to +1>><</if>>

    It seemed to work fine at first, but now it seems to add the last category? I have like 10 different profile categories like this. I'm guessing it shouldn't be 'set' which is changing it to that number rather than adding it, but what should it be? Or, am I way off here.

    Once again, I am going for I like/love rating with no top end.

    Thanks again. You people are awesome.
  • What are you trying to do exactly? Set values to a certain thing or add numbers to values?

    If you want to set them, do:

    <<set $TestSubject to 1>>

    If you want to add them, do:

    <<set $TestSubject to $TestSubject +1>>
  • Wow, thank you! It took me forever to get as close as I did. I didn't know I need to state $TestSubject twice. So anyone following after me- doing each character option as below:

    <<if $HairLength is "Short">><<set $TestSubject to $TestSubject+10>><</if>>
    <<if $HairColor is "Black">><<set $TestSubject to $TestSubject +1>><</if>>

    will result in a total like/love rating. So, TestSubject likes Short Hair so it adds 10 to their opinion of you. They don't like dark hair, so that only adds 1. Later in the game, options made could raise or lower the number to improve your standing with the person. I wanted it to work like Mass Effects blue/red system.

    Thanks again Claretta, you're the best.
  • Just bonus FYI, you can also do:
    <<set $TestSubject += 1>>
    
  • Ah! so here = means look to the prior $, not equal as in ><=?

    I saw it like that somewhere, but didn't understand it was a shortcut and not math related.

    Thanks Sharpe.
  • No, += is a complete operator, the = isn't some kind of modifier. It means, add the value of the expression on the right-hand-side to the current value of the variable on the left-hand-side and then assign the new value to the variable on the left-hand-side.

    The following:
    <<set $var += something>>
    
    Is simply a shorter equivalent to:
    <<set $var = $var + something>>
    
    Which is another way to write:
    <<set $var to $var + something>>
    
  • edited July 2015
    Things might be easier if you stored a numeric value rather than a string:
    <<set $haircolors to ["Chestnut", "Red", "Black", "Blonde"]>>
    

    Then you set the value they choose as a number:
    <<set $haircolor to 1>>
    

    You'd display it with:
    <<print $haircolors[$haircolor]>>
    

    Then you can define a set of weights on each npc:
    <<set $mike to { $haircolorpref: [ 1, 10, 5, 1] }>>
    <<set $mary to { $haircolorpref: [ 10, 1, 5, 1] }>>
    

    There'd probably be a lot more in each npc def as well.

    Then you can write a macro in a passage called rate to work out an individuals rating:
    <<set $char to parameter(0)>>
    <<set $rating to 0>>
    <<set $rating to $rating + $char.haircolorpref[$haircolor]>>
    

    Then you'd call it as:
    <<rate $mike>>
    <<set $mike.rating to $rating>>
    

    Makes it easier to recalculate everyones rating if the player changes their appearance.
  • Yeah, Mykael I thought there would be a few ways to do it. You missed you 2 week window for input, lol. Seriously, I gave the number value thing some thought and figured with my whole two weeks of programming knowledge that the other way seemed more straightforward and easy to remember, but more had typing. In this game I don't plan on PC's changing themselves in game and I wanted to set the NPC's prefs myself to jive with the story.

    I have too much going on in this game already to change it, but I will try your way next time and I'm sure others here will benefit from your insight.

    I can't wait until someone gets a real archive of all of these things bound together, so there will be a lot more writing and less coding.

    Thanks again Mykael giving us all another option.
    -Thrown
  • No worries, all good input for later games you write.
Sign In or Register to comment.