How to implement varying names

Dan The Man
(Just for the record, I am very new to this game, so please excuse my ridiculously noobish behaviour)

I have started creating a gamebook-type quest game, in which the player becomes a head of state of an important country (which he chooses at the very beginning). Now, I wanted to include the same basic scenario, and that the difference between each country will lie purely in the aesthetic (aka in the text).
I was inspired by the Issue-mechanics on NationStates, where the name of your country, your title, your capital city, your religion, etc is generated based on your preferences.

I tried to do the same here, trying to things like; "'HeadOfState, there are labour day riots from CityA to CityB' said PersonalSecretary" (in which case HeadOfState=Chancellor, CityA=Hamburg, CityB=Stuttgart and PersonalSecretary=Ingrid if the player earlier chose the "Germany" option, and HeadOfState=Mr President, CityA=Los Angeles, CityB=Chicago and PersonalSecretary=Lauren if he chose the "USA" option, etc).

The problem is, I have no idea how to implement that. I tried looking into the tutoeial, but I'm afraid it's a little too complex for me to comprehend at this stage (plus, it doesn't seem to treat the Gamebook-mode).

I'm sure it's probably something very basic and easily answered, so can anyone of you guys help me out on this one?
Thanks a lot in advance!

jaynabonne
The easiest way to do this is with the text processor: http://docs.textadventures.co.uk/quest/ ... essor.html

When outputting text, you can specify object attributes inline in the text. For example, you can output this string:

{player.title}, there are labour day riots from {player.CityA} to {player.CityB}.

The bits inside the {}'s in this case refer to attributes on the player, which you can set up with (for example):

player.title = "Chancellor"
player.CityA = "Hamburg"
player.CityB = "Stuttgart"

You can actually store the attributes on any available object (another reasonable on e would be the "game" object), but the player at least makes some sense in this case. :)

You can use scripting commands to set attributes on an object in response to what the user selects (use a page type that has scripting).

HegemonKhan
Take a look at these links:

1. http://docs.textadventures.co.uk/quest/
2. http://docs.textadventures.co.uk/quest/ ... ation.html
3. http://docs.textadventures.co.uk/quest/types/
4. http://docs.textadventures.co.uk/quest/scripts/if.html
5. http://docs.textadventures.co.uk/quest/ ... input.html
6. http://docs.textadventures.co.uk/quest/ ... _menu.html
7. http://docs.textadventures.co.uk/quest/ ... witch.html

as I think the only way to create~set~add Attributes in the Gamebook version is to use the 'start' script.

in the GUI-Editor:

code syntax structure: Object_name.Attribute_name = Value_or_Expression

run as script -> add a script -> variables -> set a variable or attribute -> example: game.leader_name_string = "king", or maybe you can also use too: player.leader_name_string = "king"

and then for your pages dynamic text (scripts~variables~attributes+text), you *can* (thanks for this change Jay) use the 'if' script (in-code example):

'start' script:

msg ("What country?")
get input {
// quest engine automatically sets the variable: result = your_input_during_game_play
game.country_string = result
if (game.country_string = "united states of america") {
game.leader_title_string = "president"
game.leader_name_string = "obama"
} else if (game.country_string = "germany") {
game.leader_title_string = "chancellor"
game.leader_name_string = "merkle" // however her name is spelled, lol
}
}

or, if you want to use the 'switch' script instead of multiple 'if' scripts (though multiple 'ifs' has more available functionality):

msg ("What country?")
get input {
// quest engine automatically sets the variable: result = your_input_during_game_play
game.country_string = result
switch (game.country_string) {
case ("united states of america") {
game.leader_title_string = "president"
game.leader_name_string = "obama"
}
case ("germany") {
game.leader_title_string = "chancellor"
game.leader_name_string = "merkle" // however her name is spelled, lol
}
}
}

your page dynamic text (script+text):

msg ("Your country is " + game.country_string + ", and so your leader is " + game.leader_title_string + " " + game.leader_name_string + ".")
// outputs for germany choice: Your country is germany, and so your leader is chancellor merkle.
// outputs for usa choice: Your country is united states of america, and so your leader is president obama.


writing in the dynamic texts is very confusing, it's not easy to do so, but there's a secret trick to writing them: breaking them into 2 chunks:

A. + Object.Attribute +
B. " text "

msg ("Your country is " + game.country_string + ", and so your leader is " + game.leader_title_string + " " + game.leader_name_string + ".")

the chunks:

"Your country is "
+ game.country_string +
", and so your leader is "
+ game.leader_title_string +
" (space) "
+ game.leader_name_string +
"."

jaynabonne

and then for your pages dynamic text (scripts~variables~attributes+text), you need to use the 'if' script (in-code example):


You don't *need* to use scripting for the actual text output. That's the beauty of the text processor and why it was created - so people could do this type of thing without scripting!

Dan The Man
Where can I find objects in Gamebook mode, and how exactly can I implement the player attributes in them?
Also, how can I ensure that e.g. the player receives the Germany attribute once he goes on the Germany option (again, in gamebook mode)?

jaynabonne
The player object already exists. You can see it in the left pane of the editor. What you need to do is have your "Germany choice page" be a page that has script as well as text (set the Type to "Script + Text"). Then when the player selects Germany, just add script to see the various attributes on the player. Similarly for the page you go to if you pick (for example) the US. I hope that helps. If not, if you're using the desktop editor (not the online one), you can post your game so we can see where to hook it in.

HegemonKhan
my bad, sorry for using 'need', as Jay pointed out, there's the text professor too (I need to get familiar with this myself still) that you can use. Though, if you're interested in learning how the scripting works, then take a look at my post, if you're ready for it.

jaynabonne
Let's run through how this would be setup in your game book, just to be clear. (You don't normally use the "get input" style query in a game book, since you can't type anything - there is no input field). Hopefully, this will help.

I assume you're going to have some initial page with a question like "What country would you like to run?" and choices for the various countries leading off to their own pages, a page for Germany, one for the US, etc. At some point, once the selection is done, you'd like it to come back together to a common start page.

Let's take Germany as the example. The rest will be similar. Let's assume you have a start page (once the country selection is made) called "GameStart". You can call it what you like, but we need to call it something for this example.

- On your "Germany selected" page, click the Type dropdown and select "Script" (not "Script + Text" as I said before, unless you wish to have some confirmation that they selected Germany - more on that at the bottom).
- Click "Add new script" and scroll down to "Variables/Set a variable or attribute". In the box after "Set variable", enter player.title. After "expression", enter "Chancellor", including the quotes. Do the same for each other variable you wish to set for Germany.
- Click "Add new script" again, and then click "Pages/Move player to page". Then select "GameStart" (or whatever it's called) for the page to go to.

This means that the "Germany selected" page will run some script and then take you off to the *real* page that the user should see next.

If you do actually want to have the Germany page have some text on it, then select the Type as "Script + Text", enter the script commands to set the variables, but don't add the Move player script. Then just have a link or whatever you want to take the player where you wish them to go.

Dan The Man
Yes!

It worked!

Thanks a lot for everything. :D

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

Support

Forums