0 votes
by (880 points)
There are multiple subraces of elf,so if the player hits a button how do i make it randomly select a race of elf, and then set that as their race?

2 Answers

0 votes
by (159k points)
selected by
 
Best answer

If the information associated within your race types isn't going to change once the game has started (eg. if that data is Static) then it doesn't need to be stored within a story variable, and thus doesn't need to be tracked by the History / Save systems. In this case you should use the built-in 'global like' setup special object to define your races on.

Place the followin example within your project's Story Javascript area, it defines a setup.races object which you can use to contain each of your different race definitions.

/*
	Define the static race definitions.

	NOTE: The properties of these definitions shouldn't be changed within the game.
 */
setup.races = {
	"common elf": {
		hair: "blue",
		skin: "copper"
	},
	"wood elf": {
		hair: "green",
		skin: "brown"
	},
	"high elf": {
		hair: "gold",
		skin: "blonde"
	},
	"grey elf": {
		hair: "grey",
		skin: "grey"
	},
	"human": {
		hair: "brown",
		skin: "pale"
	}
};

You can then use the new setup.races object within a TwineScirpt based Passage to: allocate a random race-type to a variable; display the value of properties associated with a specific race-type.

/* Assign a random race to a variable. */
<<set $race to Object.keys(setup.races).random()>>

/* Print the hair colour of that race. */
Race: $race
Hair: <<= setup.races[$race].hair>>


> Also how much can you store in twine, I dont think the space that holds the passages are infinite
There are two distinct storage areas:
1. The storage area used by the Twine 2.x application to store that contents of your project(s)
2. The storage area used by a published Twine based story HTML file to store the data of it's variables.

If you are using the Desktop release of the Twine 2.x application then the contents of your project is being stored on your hard-drive, so the amount of free space left on that hard-drive is the main limit on how large that project can get.

In regards to the 2nd storage area, the default settings of the web-browser being used to view the story HTML file are what limits how much data can be stored, and that is generally limitied to 5-10 MBs.

by (880 points)
edited by
thanks for the help
0 votes
by (159k points)

You didn't incuded any examples of:
1. How you're storing the information about the "multiple subraces".
2. How you're storing the information about the "player's race".
... so you're making us guess...

Assuming that the names of the multiple subraces are just a list of String values, and that you have a story variable named $race to store the player's race in then you could use the either() function to achieve the result you want.

<<link "Random assign Elf race">>
	<<set $race to either("common", "wood", "high", "grey")>>
<</link>>

 

by (880 points)
edited by
Would I need to make a Race class for elf, then make subclasses for the different types?

Also how much can you store in twine, I dont think the space that holds the passages are infinite so if im puttng a lot in, whats the best place to hold the information?

Also if it random picked wood elf, would it also pass their characteristics, like hair/skin color, heights, ect?
by (2.5k points)
That depends of if you have other races other then elf...

If not then you're good. I would code it but I hate sugarcube with a passion.

 

And trust me, you have plenty of space.

(I also saw you grayelf, trying to sneek yourself in that expression...)
by (880 points)
edited by
Yeah, ill have other races, the starting races are just f human, orc, and elf. However, the player character can create potions that can turn them into other races, like minotaur or mimic.

Also how would i setup a bestiary within the game so the players can learn about the different races, and animals and plants and stuff?
by (2.5k points)
Make it a passage they can go back and forth to.
by (159k points)
> (I also saw you grayelf, trying to sneek yourself in that expression...)

"Grey" was an Elf subclass in the very early Dungeons and Dragons, whiich I played way back when and where this alias originally comes from. <smile>
...