Twine Version: 2.5.1 (browser)
Story Format: Sugarcube 2.36.1
Hello, everyone. Before I get to my problem, I must beg for any mercy you can show me.
I used to build some basic HTML websites for some forum-based roleplay games I played in high school, but never caught onto JavaScript and gave up relatively quickly. Fast forward 25 years, I’ve found a new interest that has brought me back to coding.
My wife and I are fans of fiction/fantasy/history, and I am a fan of interactive/survival/non-linear games, so during a conversation we were talking about old-school choose-your-adventure books and the challenge of semi-text-based games like Oregon Trail.
This, clearly, led me to Twine.
Now, some more quick context: I don’t actually have a computer at the moment. I haven’t had a need, and considering that I am just using my current project to learn, it’s not a priority. So, I have been building everything from a mobile device. I’m aware of the risks of losing my data.
Now to my problem, I have been scavenging pieces of code and trying to learn new things as I go, albeit slowly and not altogether competently, imho. Many guides are either not what I’m looking for (such as the Sugarcube Documentation, which did not exactly address an easily accessible solution, not dumbed down to a level I can understand, or outdated. Even many forums are shut down or Read Only.
So, apologies for being so late to the party.
I’ve found that using $object.properties ( has been the best (most common) way to code a player and the details that entails. However, every example I can find has been a single Variable for the player name. My thought was to have the first and last name be separate variables so that they can be called back separately, which is where my problem stems from.
Here’s my $player code from my StoryInit passage:
<<set $player = {
name : "",
health : 100,
xp : 0,
money : 0,
race : "",
gender : "",
str : 0,
int : 0,
per : 0,
cha : 0,
hyg : 0,
men : 0,
arm : "",
dmg
}>>
I used Text Boxes to create the player’s name on my Character Creation passage:
First Name: <<textbox "$pfname" "John">>
Last Name: <<textbox "$plname" "Doe">>
What I want to do, is assign $pfname and $plname to $player.name to prevent having to use both codes constantly, but being able to do so when it’s necessary.
The only method I have found to even print $player.name with both first and last names leaves a , between them: (StoryInit passage)
<<set $player.name = ["$pfname"], [$plname] >>
What would be the correct way to go about doing this? I’m also interested in any resources for RPG elements that anyone has access to. Thank you in advance for any help you can provide.