Assigning a character's gender.
mhoffman
16 Jul 2016, 15:38I've assigned a the character's gender with:
show menu ("Are you a boy or a girl?", Split ("Boy;Girl", ";"), false) {
player.gender = result
Now when the character access a computer, what they see differs whether they're a boy or a girl.
I'm having trouble with that.
I want two different messages that will be received by either gender.
Thank you for any help you can provide.
The Pixie
16 Jul 2016, 21:55The simplest way is to use the text processor, as described here:
http://docs.textadventures.co.uk/quest/text_processor.html
Here is a quick example:
You turn on the computer. 'Good day, {if player.gender=boy:sir}{if player.gender=girl:madam}, how are you today?' you read on the screen.
hegemonkhan
17 Jul 2016, 05:36also, without using the text processor commands:
http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk
here's a sample game code for you:
create a new Text Adventure Game and save it.
close/quit out of it and quest
right click on your game file and open it (this is your entire/full game code) with (PC) notepad or (Apple) text editor
highlight all of it and delete it
highlight and copy my code below
paste my code into your game file and save it (your game file), then close the game file.
open it up in the GUI~Editor, and study it, and you can also play it too (not much to actual play of course, but you can see it hopefully working correctly, lol).
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="sample game">
<gameid>f63f45df-3dba-4dfe-b427-6a76381afd2a</gameid>
<version>1.0</version>
<firstpublished>2016</firstpublished>
<attr name="sex_stringlist_attribute" type="simplestringlist">male;female</attr>
<attr name="start" type="script">
show menu ("Sex?", game.sex_stringlist_attribute, false) {
game.pov.sex_string_attribute = ToString (result)
}
</attr>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
<object name="computer">
<attr name="parent" type="object">room</attr>
<attr name="activate" type="script">
msg ("Welcome user, (analysis complete), Name: " + game.pov.name + ", Sex: " + game.pov.sex_string_attribute + ".")
if (game.pov.sex_string_attribute = "male") {
msg ("(changing to a feminine human voice) What do you want me to do for you?")
} else {
msg ("(changing to a masculine human voice) What do you need me to do for you?")
}
</attr>
<attr name="displayverbs" type="simplestringlist">activate</attr>
</object>
<verb>
<property>activate</property>
<pattern>activate</pattern>
<defaultexpression>You can't activate that!</defaultexpression>
</verb>
</asl>