It looks like you're new here. If you want to get involved, click one of these buttons!
<<set $playerName = "Unknown"; $race = "Unknown"; $age = "Unknown"; $weapon = "None"; $gold = 50; $other = "None">>
The only one that changes is the name (using the Nameinput macro I found years ago, not sure where its from sorry).Are you a Dwarf, and Elf, or Human?
[[Dwarf|Name][$race = "Dwarf"; $weapon = "Dwarven Axe"]]
[[Elf|Name][$race = "Elf"; $weapon = "Forest Bow"]]
[[Human|Name][$race = "Human"; $weapon = "Steel Sword"]]
And the one for age:
And finally, <<print $playerName>>, how old are you?
[[12 - 20 (Young)|Begin][$age = "Young"]]
[[21 - 35 (Adult)|Begin][$age = "Adult"]]
[[36 - 50 (Older Adult)|Begin][$age = "Older Adult"]]
[[50 - 70 (Old)|Begin][$age = "Old"]]
[[ 70 + (Very Old) |Begin][$age = "Very Old"]]
As I said I'm sure the problem here is very nooby and easy to fix, but I'm just staring at it blankly right now, and could use another set of eyes to tell me whats up!
Comments
Example Turn-Based RPG (Pre-Alpha v. 0.4)
Objects are Your Friends: How & Why to Use JavaScript Objects for Total Newbies
Hope they help!
Sadly I am kind of stuck until I can sort out the Character variables...I might just try rewriting them in case I've made a silly mistake I just can't see.
I created a test story using the example passages you supplied and found no problems with the variables, I have attached it so you can see if there is a difference between what I did and your own story.
It is suggested by the creator of Twine 1 that you use a StoryInit passage to setup your variables and to use the 'to' keyword instead of an equals sign when doing variable assignments.
Your code looks fine to me. Check to see that you are not using $name in one place and $Name in another, and that you didn't accidentally leave something like <<set $name = "Unknown>> at the top of the page you're loading.
B
Replace the x For the amount of different options you want avaliable, and for age you could write this-
<<set $thisIsAVariable = Math.floor(Math.random()*x)>>
You are <<print $thisIsAVariable>> Years old.
That will assign the character a random age, from 0 to whatever number you want X to be.
As for the character, it will be more complicated, but this is what I can do.
<<set $thisIsAVariable2 = Math.floor(Math.random()*x)>>
<<if $thisIsAVariable2 is "0">> You are a Dwarf.<<endif>>
<<if $thisIsAVariable2 is "1">> You are a Human<<endif>>
And you create however many races X is -1.
As for randomness, What you would do is use the same randomness, but replace the variables and X would Equal 21.
Hope I helped,
Bladezy Boo
Remember that there is a difference between actual numbers (eg 1,2,3,..) and text values/strings that look like a number but aren't (eg "1", "2",...).
A string (the text between two quotes) is just a series of characters (letters,numbers,symbols), and even though the contents may look like a word or a number, it is not actually that thing. So if I have the string value "dog" it is not an actual dog nor is a "hammer" an actual hammer, in the same way the string value "123" is not the actual number 123.
You can do mathematics on numbers and numeric variables (ones that store numbers), generally* you cant do it to strings and string variables though you can use the plus symbol to concatenate two strings. I hope this has not made you more confused! lol
* Some programming languages are 'smart' and try to convert value of one data type into another for you and this is known as "Data Type Casting". (Casting for short)
The problem is should it cast the number into a string or the string into a number? If the lang. knows the data type of the variable ($var) the result is being stored into it can use this information to determine which cast to do, but generally they default to casting everything into strings.
So "123" would be one and two and three, rather than one hundred and twenty three?
Yes.
"123" is the character "1" (one) and the character "2" (two) and the character "3" (three) joined together into a string.