Character creation questions (again)

The Pixie
So you have a whole set of attributes that can be certain values, such as race or hair colour, and you want to present them to the player as choices. Some choices will affect later options, and some values can change later in the game.

I devised this library for Neonayon to do just that.

Add the libary to your game (right click in the left pane, select "Add library", navigate to QuestionLib, save and click "Reload"). Then create a new room called "questions", and in there create an object for each attribute.

Setting Up Questions

Say you have a race attribute, create an object called "race". Give it an alias, which will be the question the player will be asked, perhaps "What race are you?". You can also add a description; this will appear before the question, so can be used to explain the options.

Now go to the "Questionaire" tab, and set this object tobe a "Question". A whole bunch of settings will appear. The most important is the list at the top; this is where you enter all the options for this attribute. Let us say for race you want to be able to handle human, elf, lizardman, feline, gnoll and orc.

Now suppose, you only want the player to be able to choose the first four options. No problem, set the "from" value to 0, as you want the first option to be available, and set the "to" to 4, because you do not want the fifth item (which is number 4 in the list, as it starts from 0). Alternatively, you could set "to" to -2, to skip the last two entries.

Later I want to ask about hair color, but lizardmen and felines do not have hair, so we can use the optional script here.
if (player.race = "feline") {
haircolour.show = false
furcolour.show = true
}
if (player.race = "lizardman") {
haircolour.show = false
scalescolour.show = true
}

You could also use the script to adjust which options are shown. If you have a question about height, you could offer the player smaller height options for a dwarf (remember, the numbers are the indices of the options, not the actual height; setting "from" to 0 indicates to the end of the list).
if (player.race = "dwarf") {
height.to = 0
height.from = 4
}
if (player.race = "giant") {
height.to = 12
height.from = 0
}

You may prefer to not give the player a choice about an attribute. Perhaps rank starts at zero, and increases as the game progresses. Untick the Show box, and enter a value in the "Default" box. The furcolour and scalescolour attributes would also have "Show" unticked.

Be aware that Quest gets confused if you use apostrophes in inline menu choices, so ensure you have none in any of your options. I have had to do heights as "5.6" rather than "5'6" to get around this.

You can ask as many questions as you like. Each question automatically gets a "random" option.

To start the question asking process in your game, just call AskQuestion (probably the start script on the game object is the best place).

When the process is done, it will call a function called QuestionCallBack. This does nothing by default, but you can write your own version to have something happen when the process has completed.

Changing Values

Each attribute is stored as both a string and an integer (a whole number), so for example:
player.race = "human"
player.race_as_int = 0

If you want to change a value, you need to make sure both get changed. The best way is to use the built-in functions:
Increase
Decrease
Adjust
SetTo

Increase and Decrease will raise or lower the attribute by one, while Adjust allows you to change it by as much as you like.
Increase("height")
Decrease("height")
Adjust("height", -2)

The SetTo functions lets you set the attribute to a certain value:
SetTo("race", "orc")

All four functions return a Boolean value, true if the change was successful, false otherwise. It will fail if you try to go beyond the allowed range (if you try to decrease the attribute when it is already at the lowest, or increase it when at the highest) or use SetTo with an unrecognised value. The demo game has a GROW command, which looks like this:
if (Increase("height")) {
msg("You grow two inches!")
}
else {
msg("You are tall enough already")
}

In the demo, once you have created your character, you can type X ME to see what you look like. You can also try GROW and ORC.



This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums