The use of "Random" and "Has Seen Page" code in Conversations (Gamebook)

Okay, I don't know if there are other ways to do this but this is what I want to do. In the game that I am working on, the player can choose to converse with the character's teammates and can earn points if conversation flows well.

I was thinking of preparing different responses for each teammates (which is where I will use the "Random" code). The reply of the teammate that popped at random will lead the player to a different page so I can mark the convo that the player has seen (the "Has Seen Page" code comes in).

Ex. Player has 3 teammates idle. Player approaches Teammate A.
Teammate A has (5 topics for convo prepared. The Random code will flash whichever answer that will lead player to another page).
Teammate A responds with Sports.
Teammate A and Player talked about Sports. (this will now be saved as the Player's memorable times with Teammate A).

In future chapters, Player can bring it up again or talk about it. Out of the 5 topics, I have to make sure that the topic is consistent. If Sports was the first thing they talked about, Sports should be the topic to pop out in future pages. Is it possible? If so, how do I do it? Please help me.

Thank you in advance!


Is my question confusing? Please let me know so I can rephrase it.
I really need help regarding this matter. Thank you.


I'm no expert or perfect coder, but here's how I would do it. You are saying that the player would approach Teammate A, select a Sports option, and thus this topic must remain consistent. What I would do is use a boolean (flag). When the player is sent to a page, use the "set flag on" script and set a "Sports" flag or whatever label would work for you. Then later on, you can use {if sportsTopic:} in your text or the "if" in script.

If you don't know what I mean by script, when you are writing your page there is an option for "Page Type." Select "Script + Text" and you will be able to access the scripts. Do not worry about losing whatever you have in the description of the page, it will not be deleted.

The way it works would be like this:

Player talks to teammate on Page1
Player receives Sports topic. This topic takes them to SportsPage.
In the script of SportsPage, the flag "Sports" is set to true. The text describes the conversation as normal.
In another future page, {if Sports:} is used and will show text only if the player has "Sports" set to true. (Using script version of "if" may make it easier for long sections of text.)

Hopefully that helps, let me know if you have any questions!

-Ninjagorulz


Oh I see. Okay I will give it a try and report back how it works. Thank you!


I tried it. It worked! :D Thank you thank you, thank you so much!!! Thank you very much!

Question
I have a new question. We have Name, Page Type, Script and Description right?
In the "description" part, I can type {random:} to put a list or series of words to randomize. I was hoping to use this to randomize topics in the conversation but it does not work in the "Script -> Print message" part. Just in the "Description". Is there another way to do this?


the 'text processor commands' are a quick/easy way to do various things

http://docs.textadventures.co.uk/quest/text_processor.html

the reason it is "quick/easy" is that you can put it directly into strings, for example:

msg ("{random:Hi:Hello:Howdy}, my name is HK, what is your name?")

in the GUI/Editor:

add new script -> 'output' section/category -> 'print a message' Script -> (see below)

// let me know if this works or not (I don't know if the '[MESSAGE]' command-option works/allows for text processor commands or not):
// (the '[MESSAGE]' command-option allows for doing ONLY TEXT, but, again, I don't know about the text processor commands)

print [MESSAGE] {random:Hi:Hello:Howdy}, my name is HK, what is your name?

// this should work:
// (the '[EXPRESSION]' command-opion allows for: ONLY TEXT, ONLY VARIABLE, or for both TEXT and VARIABLE: it allows for anything/everything)

print [EXPRESSION] "{random:Hi:Hello:Howdy}, my name is HK, what is your name?"

--------

the 'description' String/Script Attribute of the Page Objects is nearly the same as the 'msg' Script/Function, in regards to strings:

'description' as a String Attribute:

{random:Hi:Hello:Howdy}, my name is HK, what is your name?
// or (if the above doesn't work):
"{random:Hi:Hello:Howdy}, my name is HK, what is your name?"

'description' as a Script Attribute:

add new script -> 'output' section/category -> 'print a message' Script -> (see below)

// let me know if this works or not (I don't know if the '[MESSAGE]' command-option works/allows for text processor commands or not):
// (the '[MESSAGE]' command-option allows for doing ONLY TEXT, but, again, I don't know about the text processor commands)

print [MESSAGE] {random:Hi:Hello:Howdy}, my name is HK, what is your name?

// this should work:
// (the '[EXPRESSION]' command-opion allows for: ONLY TEXT, ONLY VARIABLE, or for both TEXT and VARIABLE: it allows for anything/everything)

print [EXPRESSION] "{random:Hi:Hello:Howdy}, my name is HK, what is your name?"

--------------

further explanation of the '[MESSAGE]' vs '[EXPRESSION]' command-options within/used-by the GUI/Editor:

--------------

using the '[MESSAGE]' command-option:

ONLY TEXT:

print [MESSAGE] Hi
// NO error
// displays:
// Hi

print [MESSAGE] "Hi"
// NO error
// displays:
// "Hi"

ONLY VARIABLE:

game.greeting = "Hi"
print [MESSAGE] game.greeting
// ERROR!
// or it displays literally:
// game.greeting

TEXT and VARIABLE:

game.greeting = "Hi"
print [MESSAGE] game.greeting + ", my name is HK, what is your name?"
// ERROR!
// or it displays literally:
// game.greeting + ", my name is HK, what is your name?"

------

using the '[EXPRESSION]' command-option:

ONLY TEXT:

print [EXPRESSION] "Hi"
// NO error
// displays:
// Hi

print [EXPRESSION] "\"Hi\""
// NO error
// displays:
// "Hi"

// the '\' (backslash) is known as an 'escape' character in programming, which has another character immediately following it (NO space between them), and which, creates an 'escape command', displaying (or doing) whatever is specified by that following character:

https://en.wikipedia.org/wiki/Escape_character

\' displays the single quotation
\" displays the double quotation
\\ displays the backslash
etc etc etc

\n does the 'new line' action (causes the "cursor" to go to the beginning/left-side of the next line)
\t does a [TAB] key keyboard action
etc etc etc

so, conceptually, it's like this:

print [EXPRESSION] " [\"] Hi [\"] "

the outer double quotes make the stuff inside of them, a string (text that can be displayed)

and the [\"] escape commands (without my brackets surrounding them), tells quest to display these double quotes, otherwise quest would see them as the same command-programming double quotes as the outer double quotes, which will royally confuse and mess up quest in trying to do/understand the code line

ONLY VARIABLE:

game.greeting = "Hi"
print [EXPRESSION] game.greeting
// No error
// displays:
// Hi

TEXT and VARIABLE:

game.greeting = "Hi"
print [EXPRESSION] game.greeting + ", my name is HK, what is your name?"
// NO error
// displays:
// Hi, my name is HK, what is your name?

Using {random:} should work in the message. When you want to set up different links to appear, you will want to use {page:} inside your random sections. Such as:

{random:{page:Page2:Sports}:{page:Page3:Not Sports}:{page:Page4:Writing}}

This will pick random links to display, and works in the message script. The buttons on the right just help to make those commands, however they can be used in any text. It would be a good idea to look at this page to find more text processor commands: http://docs.textadventures.co.uk/quest/text_processor.html . Learning different commands and their format is helpful, though you don't have to memorize them. The page provides the format and what they do!

The full message code in the script area will look like this:

msg ("{random:{page:Page2:Sports}:{page:Page3:Not Sports}:{page:Page4:Writing}}")

Just be careful to keep track of your brackets! It won't crash your game if they don't match up, but it will show any text you have inside the broken brackets. Such as if you wrote {random:Hi:Hello:Greetings:{if fun:Howdy}then this would appear wherever it is in your text:

{random:Hi:Hello:Greetings

Howdy will not show up if fun is not active, because it's brackets are closed. The random function is not closed, and it will show it's contents.

And I'm very happy to help! Quest can be very overwhelming sometimes! Hopefully this makes more sense for you, I can see hegemonkan is doing their best to help, but that wall of code can be a little confusing. Thank you for answering though hegemonkan!

Feel free to ask more questions! I'm here to help!

-Ninjagorulz


Thank you very much Ninjagorulz! It works now! Thank you thank you thank you!
Also, the flag thing that you said had been a big help to develop the game and now this, thank you very much!

I have one last question though. How do I use a turn script? And a counter?


Counters are relatively easy. They are pretty much just dumbed-down variables. Either use the graphical user interface and select "set counter" to define one, or directly writte the script:

SetCounter ("XYZ", #)

With XYZ being the counters name, and # the intial value (usually 0).

Now you can increase, decrease or change them by using

IncreaseCounter ("XYZ")
DecreaseCounter ("XYZ")
ChangeCounter ("XYZ", #)

which are accesible through the UI too. The first two will add or subtract 1 to the counter XYZ. The last one adds the value # (which can also be negative).

In all the previous cases, you can also substitute # for an expression, meaning a variable, or an objects value, as long as they return an integer.

Turnscripts are the hardier part, and you probably refer to the documentation first: http://docs.textadventures.co.uk/quest/tutorial/using_timers_and_turn_scripts.html

A few things to keep in mind though:

In gamebook mode, having a turnscript for only one room (e.g. page) is nonsense. Also, you should store them as part of the player object, since gamebook allows you only to manipulate three types of objects: pages, the player and the game. The first one are useless, and you really don't want to fuss around with the game if possible.


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

Support

Forums