Using Inherited Types to change Character Gender
JDFoxx
20 Nov 2016, 07:48Hey guys.
I have only been doing Quest for two days now, so please correct me if this question is stupid.
I am trying to create a character creation sequence at the start of my text adventure, but I am stuck on the 'gender selection' part. I am using the latest version of desktop Quest for windows (as of 20/11/2016) and I was wondering if it's possible to change an Inherited Type of the 'person' object...
I think it's supposed to go something like:
switch (result) {
case ("Male") {
<inherit name = "namedmale" />
}
case ("Female") {
<inherit name = "namedfemale" />
}
default {
error ("You must input 'Male' or 'Female'. No other options will suffice.")
}
}
But to be honest I have pretty much no clue.
If anyone can help that would be really appreciated! Thanks.
The Pixie
20 Nov 2016, 09:42You cannot change an object's type during the game, so this is not going to work. The way to do it is to set an attribute on the player. I use a Boolean (or flag) called "female", which is true
if female and false if not.
By the way, a good idea to expect the player to type other things. LCase
on the result will make it lower case, so it is not case sensitive, and you can allow just "m" and "f" too very easily (or use ShowMenu...).
switch (LCase(result)) {
case ("m", "male") {
player.female = false
}
case ("f", "female") {
player.female = true
}
default {
error ("You must input 'Male' or 'Female'. No other options will suffice.")
}
}
To check the gender, test the female
attribute:
if (player.female) {
msg("You are female.")
}
else {
msg("You are male.")
}
hegemonkhan
20 Nov 2016, 09:45here's a guide on Attributes and the 'if' Script, the 'bread and butter' of programming/game-making, these two super scripts, especially when used together, let's you do 90% of everything you want to do in the game:
http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk
on to your question...
about, Object Types / Inherited Attributes:
in quest, the 'Object Type / Inherited Attribute' is a user-level group/class, I'm not sure if these are dynamic/run-time able or not (Pixie said not able to manipulate Object Types / Inherited Attributes during run-time). I'm only aware of being able to check the, Object Type / Inherited Attribute, via the 'DoesInherit' Script/Function ( http://docs.textadventures.co.uk/quest/functions/doesinherit.html )
// example of using Object Types (much better) than the further below example when/of not using Object Types):
<object name="npc_1_object">
<inherit name="character_type" />
</object>
<object name="npc_2_object">
<inherit name="character_type" />
</object>
<object name="npc_3_object">
<inherit name="character_type" />
</object>
// 'type' is used for 'Object Type' ON THE LEFT MOST SIDE ( <type name="xxx">content</type> ) in code (the, type="xxx", is the Attribute Type ---ya confusing... type is such a universal word that it's used for everything, which causes great confusion, argh), as seen below:
<type name="character_type">
<attr name="level_integer_attribute" type="int">0</attr>
<attr name="experience_integer_attribute" type="int">0</attr>
<attr name="cash_integer_attribute" type="int">0</attr>
<attr name="life_integer_attribute" type="int">0</attr>
<attr name="mana_integer_attribute" type="int">0</attr>
<attr name="strength_integer_attribute" type="int">0</attr>
<attr name="endurance_integer_attribute" type="int">0</attr>
<attr name="dexterity_integer_attribute" type="int">0</attr>
<attr name="agilty_integer_attribute" type="int">0</attr>
<attr name="speed_integer_attribute" type="int">0</attr>
<attr name="luck_integer_attribute" type="int">0</attr>
<attr name="piety_integer_attribute" type="int">0</attr>
<attr name="intelligence_integer_attribute" type="int">0</attr>
<attr name="spirituality_integer_attribute" type="int">0</attr>
<attr name="mentality_integer_attribute" type="int">0</attr>
<attr name="leadership_integer_attribute" type="int">0</attr>
<attr name="charisma_integer_attribute" type="int">0</attr>
<attr name="alignment_integer_attribute" type="int">0</attr>
<attr name="perception_integer_attribute" type="int">0</attr>
<attr name="deception_integer_attribute" type="int">0</attr>
<attr name="creativty_integer_attribute" type="int">0</attr>
</type>
// --------------------------------------------------------
vs, not using an 'Object Type / Inherited Attribute' (YUCK, as can be seen below):
<object name="npc_1_object">
<attr name="level_integer_attribute" type="int">0</attr>
<attr name="experience_integer_attribute" type="int">0</attr>
<attr name="cash_integer_attribute" type="int">0</attr>
<attr name="life_integer_attribute" type="int">0</attr>
<attr name="mana_integer_attribute" type="int">0</attr>
<attr name="strength_integer_attribute" type="int">0</attr>
<attr name="endurance_integer_attribute" type="int">0</attr>
<attr name="dexterity_integer_attribute" type="int">0</attr>
<attr name="agilty_integer_attribute" type="int">0</attr>
<attr name="speed_integer_attribute" type="int">0</attr>
<attr name="luck_integer_attribute" type="int">0</attr>
<attr name="piety_integer_attribute" type="int">0</attr>
<attr name="intelligence_integer_attribute" type="int">0</attr>
<attr name="spirituality_integer_attribute" type="int">0</attr>
<attr name="mentality_integer_attribute" type="int">0</attr>
<attr name="leadership_integer_attribute" type="int">0</attr>
<attr name="charisma_integer_attribute" type="int">0</attr>
<attr name="alignment_integer_attribute" type="int">0</attr>
<attr name="perception_integer_attribute" type="int">0</attr>
<attr name="deception_integer_attribute" type="int">0</attr>
<attr name="creativty_integer_attribute" type="int">0</attr>
</object>
<object name="npc_2_object">
<attr name="level_integer_attribute" type="int">0</attr>
<attr name="experience_integer_attribute" type="int">0</attr>
<attr name="cash_integer_attribute" type="int">0</attr>
<attr name="life_integer_attribute" type="int">0</attr>
<attr name="mana_integer_attribute" type="int">0</attr>
<attr name="strength_integer_attribute" type="int">0</attr>
<attr name="endurance_integer_attribute" type="int">0</attr>
<attr name="dexterity_integer_attribute" type="int">0</attr>
<attr name="agilty_integer_attribute" type="int">0</attr>
<attr name="speed_integer_attribute" type="int">0</attr>
<attr name="luck_integer_attribute" type="int">0</attr>
<attr name="piety_integer_attribute" type="int">0</attr>
<attr name="intelligence_integer_attribute" type="int">0</attr>
<attr name="spirituality_integer_attribute" type="int">0</attr>
<attr name="mentality_integer_attribute" type="int">0</attr>
<attr name="leadership_integer_attribute" type="int">0</attr>
<attr name="charisma_integer_attribute" type="int">0</attr>
<attr name="alignment_integer_attribute" type="int">0</attr>
<attr name="perception_integer_attribute" type="int">0</attr>
<attr name="deception_integer_attribute" type="int">0</attr>
<attr name="creativty_integer_attribute" type="int">0</attr>
</object>
<object name="npc_3_object">
<attr name="level_integer_attribute" type="int">0</attr>
<attr name="experience_integer_attribute" type="int">0</attr>
<attr name="cash_integer_attribute" type="int">0</attr>
<attr name="life_integer_attribute" type="int">0</attr>
<attr name="mana_integer_attribute" type="int">0</attr>
<attr name="strength_integer_attribute" type="int">0</attr>
<attr name="endurance_integer_attribute" type="int">0</attr>
<attr name="dexterity_integer_attribute" type="int">0</attr>
<attr name="agilty_integer_attribute" type="int">0</attr>
<attr name="speed_integer_attribute" type="int">0</attr>
<attr name="luck_integer_attribute" type="int">0</attr>
<attr name="piety_integer_attribute" type="int">0</attr>
<attr name="intelligence_integer_attribute" type="int">0</attr>
<attr name="spirituality_integer_attribute" type="int">0</attr>
<attr name="mentality_integer_attribute" type="int">0</attr>
<attr name="leadership_integer_attribute" type="int">0</attr>
<attr name="charisma_integer_attribute" type="int">0</attr>
<attr name="alignment_integer_attribute" type="int">0</attr>
<attr name="perception_integer_attribute" type="int">0</attr>
<attr name="deception_integer_attribute" type="int">0</attr>
<attr name="creativty_integer_attribute" type="int">0</attr>
</object>
on to answering your question...
the built-in 'gender' and 'article' Attributes are for determining/outputting the correct grammer (he/she/it/him/her/etc) usage.
if you want an actual 'sex' Attribute (male/female), you can create your own (as in-code scripting quick/brief examples):
player.sex_string_attribute = "male"
player.sex_string_attribute = "female"
if (player.sex_string_attribute = "male") {
// whatever script(s)
} else if (player.sex_string_attribute = "female") {
// whatever script(s)
}
show menu ("Sex?", split ("male;female", ";"), false) {
// the 'show menu', 'ShowMenu', and 'get input' all do this automatically (hidden from) for you:
// result = YOUR_TYPED_IN_OR_SELECTED_INPUT // in this case, result = "male", or, result = "female"
player.sex_string_attribute = result // effectively you're doing this: player.sex_string_attribute = result = "male" // or: "female" // and thus: player.sex_string_attribute = "male" // or: "female"
}
if you want to actually set the built-in 'gender' and/or 'article' Attributes, based upon your 'sex' selection of a character creation, I'm not that familiar with it... ( http://docs.textadventures.co.uk/quest/elements/object.html --- see 'gender' and/or 'article' and also scroll down to the bottom to see the Object Types)
you don't use the '<' and '>' symbols as those are for the aslx/xml/html 'creation' tag lines/blocks (in code)
I think... you can just do this...
switch (result) {
case ("Male") {
player.gender = "male"
}
case ("Female") {
player.gender = "female"
}
default {
error ("You must input 'Male' or 'Female'. No other options will suffice.")
}
}
I'm not sure if you can add/create/set/re-set/change an, Object Type / Inherited Attribute, during run-time, but you can try:
HK Edit: Pixie answered, no, the Object Type is not dynamic/run-time manipulatable, so ignore below.
http://docs.textadventures.co.uk/quest/scripts/set.html
switch (result) {
case ("Male") {
set (player, "namedmale", true)
}
case ("Female") {
set (player, "namedfemale", true)
}
default {
error ("You must input 'Male' or 'Female'. No other options will suffice.")
}
}
hegemonkhan
20 Nov 2016, 09:56P.S.
this may help you with some ideas on character creation stuff:
http://textadventures.co.uk/forum/samples/topic/4988/character-creation-crude-code-and-sample-game
there's a better way to do this stuff (having a single Function able to handle multiple Functions via Parameter/Argument inputs, instead of having multiple Functions as I do in the link --- don't know why this had totally escaped me at the time and/or why I couldn't do such a dynamic Function, argh), but it should give you some ideas on various things you can do and/or how to do them.
The Pixie
20 Nov 2016, 11:10If you are feeling brave, here is how to do character creation in one dialogue panel:
https://github.com/ThePix/quest/wiki/Advanced-UI-Part-04:-Dialogue-Panels
JDFoxx
20 Nov 2016, 22:14Thanks for all the replies!
It really helped!
:D