Differing Male and Female Genders

Heya Guys and Girls

Trying a new thing: Character creation.

So far, I've got naming fine. Changing the player's alias. And I have a switch menu letting the player choose between male or female as a gender. This works for me, i.e

Show Menu With Caption: What sex are you?
Options from list/dictionary: Split ("Male;Female". ";")
Pick Male
Set variable: player.gender expression: result
Print Expression: player.alias + " is " + player.gender = John is Male

However, when I try

If object attribute equals Object: Player Attribute: gender = Male

I get

Error running script: Error compiling expression 'player.gender = Male': Unknown object or variable 'Male'

Can anyone tell what I'm doing wrong? Is there a better way? I tried changing the attribute to Sex in case I was conflicting something but had no luck there, either.

Here's my code with text walls omitted.

  <asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="Awakening of Randomgame">
    <inherit name="theme_retro" />
    <gameid>14e25117-f85d-4ee7-a089-48a3aa768fbb</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
    <defaultwebfont>Quicksand</defaultwebfont>
    <defaultbackground>FireBrick</defaultbackground>
    <autodescription />
    <showdescriptiononenter />
    <showlocation type="boolean">false</showlocation>
    <showpanes type="boolean">false</showpanes>
    <autodescription_description_newline />
    <autodescription_youcango_newline />
    <autodescription_youcansee_newline />
    <autodescription_youarein_newline />
    <command_newline />
    <attr name="autodescription_youarein" type="int">0</attr>
    <subtitle>An erotic and demonic adventure</subtitle>
    <author>Serban Kline</author>
    <showtitle type="boolean">false</showtitle>
    <start type="script"><![CDATA[
      msg ("What is your name?")
      msg ("")
      get input {
        player.alias = result
        msg ("{player.alias}. You remember your name, but what about your body. You look down.")
        msg ("")
        ShowMenu ("What sex are you?", Split ("Male;Female", ";"), false) {
          player.gender = result
          msg (player.alias + " is " +  player.gender)
          if (player.gender = Male) {
            msg ("Even in your groggy state, it’s pretty hard to miss you’re a boy.<br/>")
          }
          else if (player.gender = Female) {
            msg ("Even in your groggy state, it’s pretty hard to miss you’re a girl. ")
          }
          else {
            msg ("Apparently there is no gender?")
          }
        }
      }
    ]]></start>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <usedefaultprefix />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
      <inherit name="male" />
      <eyecolour type="string"></eyecolour>
      <skincolour type="string"></skincolour>
      <haircolour type="string"></haircolour>
      <sex type="string"></sex>
    </object>
  </object>
</asl>

very simple issue/fix

fix: put 'Male' in double quotes: "Male" // (in code) if (player.gender = "Male") { /* scripting */ } // (GUI/Editor) If object attribute equals Object: Player Attribute: gender = "Male"

anything not in double quotes (that is not a number and not a special/reserved word, such as 'true', 'false', and 'this'), is seen to be an Object, so, quest is looking for an Object called/named 'male', which you don't have, and thus the error.

anything in double quotes is a String, which IS what you want it to be: a String Value.

for example:

game.integer_attribute = 46 // the, 46, is an Integer Value
vs
game.string_attribute = "46" // the , "46", is a String Value

--

game.string_attribute = "HK" // the , "HK", is a String Value
vs

// created/added/existing 'HK' Object:
<object name="HK">
</object>

game.object_attribute = HK // NO error, and the, HK, is an Object (reference/pointer) Value

vs

game.object_attribute = HK // ERROR! There is no 'HK' Object existing!

computers are stupid, so you got to tell them what they're working with and also you got to match up those things for it to be able to do stuff with them

in programming, this is known as Data Types, and in quest, there's quite a few of them:

Integer (non-decimal numbers)
Double (decimal numbers)
Boolean (true/false)
String (text, a collection/sequence of various characters/symbols, but not all of them are allowed/useable)
Object (reference/pointer to that Object)
Script (actions/events)
Lists (a collection of strings/text or Object references/pointers, as individual items)
Dictionaries (basically, an input-output function)
Inherited (deals with Object Types)


mis-matched Data Types is bad:

for some examples:

you can't store an Integer Value into a String Attribute:

game.string_attribute = 88
// fix 1: game.string_attribute = ToString (88)
// or
// fix 2: game.string_attribute = "88"

you can't (math/arithmetic) add a String Value and an Integer Value:

game.integer_attribute = 33 + "hi"
// fix: game.integer_attribute = 33 + 21


ask if you need any help with anything, or anything explained further.


p.s.

you can take a look at these links too on character creation:

http://textadventures.co.uk/forum/samples/topic/4988/character-creation-crude-code-and-sample-game (lots of redundant functions that can be combined into a single function that can handle all of them, wasn't thinking clearly at the time, lol, but it gives you some ideas on character creation stuff)

http://textadventures.co.uk/forum/quest/topic/3348/noobie-hks-help-me-thread#22036 (here's the starting post of when I myself was trying to learn the character creation too, hehe)

http://textadventures.co.uk/forum/quest/topic/3348/noobie-hks-help-me-thread (my thread back when I was learning quest and programming for my very first time ever)


P.S.S.

also, in your code:

    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
      <inherit name="male" />
      <eyecolour type="string"></eyecolour>
      <skincolour type="string"></skincolour>
      <haircolour type="string"></haircolour>
      <sex type="string"></sex>
    </object>

you got the 'sex' String Attribute, but for your character creation coding, you're using 'gender' as your String Attribute. Choose one of them to be your String Attribute: (actually, let's replace 'gender' with 'sex', because see below)

(personally, I'd use 'sex', as 'gender' is already a built-in String Attribute/feature of quest, dealing with using the correct grammer based upon male/female/neither: him/her/it/etc, via: player.gender, and if you use 'gender' for your male/female state, you over-ride/over-write it from being able to use its built-in functionality of: him/her/it/etc)

see these links on 'gender' and 'article' (I always get them confused, lol):

http://docs.textadventures.co.uk/quest/attributes/article.html
http://docs.textadventures.co.uk/quest/attributes/gender.html
^^^^^^
http://docs.textadventures.co.uk/quest/elements/object.html
^^^^^^^
http://docs.textadventures.co.uk/quest/elements/


fixed up your code, using 'sex' instead of 'gender', to preserve 'gender' for if you need the usage of he/she/him/her/it/etc (I'll never get memorized what gender handles vs what article handles, lol: he/she vs him/her)

  <asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="Awakening of Randomgame">
    <inherit name="theme_retro" />
    <gameid>14e25117-f85d-4ee7-a089-48a3aa768fbb</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
    <defaultwebfont>Quicksand</defaultwebfont>
    <defaultbackground>FireBrick</defaultbackground>
    <autodescription />
    <showdescriptiononenter />
    <showlocation type="boolean">false</showlocation>
    <showpanes type="boolean">false</showpanes>
    <autodescription_description_newline />
    <autodescription_youcango_newline />
    <autodescription_youcansee_newline />
    <autodescription_youarein_newline />
    <command_newline />
    <attr name="autodescription_youarein" type="int">0</attr>
    <subtitle>An erotic and demonic adventure</subtitle>
    <author>Serban Kline</author>
    <showtitle type="boolean">false</showtitle>
    <start type="script"><![CDATA[
      msg ("What is your name?")
      msg ("")
      get input {
        player.alias = result
        msg ("{player.alias}. You remember your name, but what about your body. You look down.")
        msg ("")
        ShowMenu ("What sex are you?", Split ("Male;Female", ";"), false) {
          player.sex = result
          msg (player.alias + " is " +  player.sex)
          if (player.sex = "Male") {
            msg ("Even in your groggy state, it’s pretty hard to miss you’re a boy.<br/>")
          }
          else if (player.sex = "Female") {
            msg ("Even in your groggy state, it’s pretty hard to miss you’re a girl. ")
          }
          else {
            msg ("Apparently there is no gender?")
          }
        }
      }
    ]]></start>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <usedefaultprefix />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
      <inherit name="male" />
      <eyecolour type="string"></eyecolour>
      <skincolour type="string"></skincolour>
      <haircolour type="string"></haircolour>
      <sex type="string"></sex>
    </object>
  </object>
</asl>

Thanks a million hegemonkhan, elegant response to my question and really fixed things up for me! I'd seen quotation marks used on things before but didn't fully understand the purpose. Each time I use quest and make something I seem to be learning a new feature, making things more and more complex. Very satisfying. I've been using some of the guides, it's where I got the idea from, and then most other things I try and work out by trial and error.

Again, thanks for the help!


So on here I'm pretty sure you can go by a gender neutral option if you just edit the pronouns.

I don't think you said anything about that, I just wanted to say it.


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

Support

Forums