Gamebook Random Text Help

bencorman
First off, thanks for taking the time to read this.

Okay, so I'm making a gamebook with some looping pages for combat purposes. I have built a functional random list of synonyms for the main character ie: {random:Brittany:Brittany, {random:looking cheerful:smiling widely},:The {random:smiling:happy:laughing:upbeat} {random:girl:woman:lady}}

The actual list is much bigger. So it works fine in the game as part of a text box. But I'd like to, if possible, take this giant random function string of doom and find a way to A) recall this big random function list on future pages and B) Shorten it into something that takes less space on my screen when I need to use it.

Anybody know how to pull this off in a gamebook?

The Pixie
My advise is don't. Do it in a text adventure, and fake it to look like a gamebook.
viewtopic.php?f=18&t=4772

bencorman
Thanks for the suggestion. If I were to do text adventure instead of gamebook, how would I do it in a text adventure?

When I try to build a variable, this is the error message I get:
Error running script: Error compiling expression 'RandomResult7': SyntaxError: Unexpected character: {Line: 1, Column: 1

What is awesome is that the expression listed in error (In this example, RandomResult7) is randomly generated from the potential random results, and it is randomly generating correctly. Anybody have any idea how I just get that random result recalled instead of the Error running script message?

Silver
If it's just random text you want you can do it by using the text processor. Put this in the body of your text:

{random:text 1:text 2:text 3}

And replace text 1 text 2 etc with the random bits of text.

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

Silver
Actually, isn't that what you're doing already? lol

jaynabonne
bencorman, if you have a question about a particular piece of script - especially if it's one you're written that's non-trivial - it would really help if you could post what you have done. Usually error messages can be easily resolved by seeing the script in question.

HegemonKhan
from the error code:

Error running script: Error compiling expression 'RandomResult7': SyntaxError: Unexpected character: {Line: 1, Column: 1

it looks like you got a simple typo mistake:

if we made a text doc an 'yx' grid:

'lines' = y axis (vertical coordinate)
'columns' = x axis (horizontal coordinate)

so for the script block in question, find 'line1' and 'column1', as this is where your typo is at

column
123456
qwerty:1 line
asdfgh:2 line
zxcvbn:3 line

so...

line1, column1 = q
line2, column1 = a
line3, column1 = z
line2, column3 = d
line3, column6 = n

though, it can be more complicated, as you can forgot a character~symbol (typo mistake) else where, which causes an error also at other locations too (your error codes), so you may need to find the source typo error (which is not mentioned as an error code), causing the rest of the code below+right of it to be shifted, and thus the 'qausi false positive' error codes. (this won't make sense to you, unless you already understand coding... laughs, so just ignore this if you don't understand it).

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

I highly recommend this text software to everyone:

notepad++ ( http://notepad-plus-plus.org/ )

as if you copy and paste (or just write~type) code into it (or you just open your quest game file with notepad++), it'll color code it and also give the yx coordinates for where you got your pointer cursor at in the text, for easier reading, writing~typing, and trouble shooting.

for quest, at the top of the notepad++ screen (after you downloaded, installed, and opened it up), under 'languages', choose 'XML' (eXtensible Markup Language).

bencorman
I am indeed using the {random:} function from the text processor. The problem is that the functioning product it is a HUGE wall of text because it is a synonym list for the main character I'm trying to use to help make the text less repetitive. ({random:Name: Name, {random: lots of descriptions},: {random: lots of descriptions without a name}: {random: even more descriptions} {random title}}. What I'm trying to do is take that randomizing function that works in the text processor but makes it very difficult to actually then type text and all of that because I scroll past copy after copy of this massive wall of text. So I would like to link it to something smaller. A variable? A list? I don't know what the answer is. I'd like to call back to this massive working randomizer without having to reproduce it every single time.

Trying to create a variable that contains the functioning {random:} text processor code produces the error in my previous reply. So, any way to take that functioning text processor {random:} code and link it to a variable or something else that doesn't take up so much space? Or is cutting and pasting the giant {random:} wall of text over and over and over my best option?

Code:

player.brittany = {random:Brittany:Brittany, {random:smiling widely:smiling slyly:filled with enthusiasm:always optimistic:her face a mask:filled with hope:thoughts wandering:blonde hair saying in the breeze:eyes sparkling:full of joy:anger building:lost in thought},:The {random:blonde:blue eyed:blonde-haired:always optimistic:lovely:enthusiastic:smiling:beautiful:amazing:brave:hard-working:long-haired:willful:chosen:annointed:athletic:quick-witted:tricky:nimble:naturally gifted} {random:heroine:huntress:fighter:slayer:battler:girl:woman:beauty}}

Error:

Error running script: Error compiling expression 'The willful beauty': SyntaxError: Unexpected character: {Line: 1, Column: 1

What is really frustrating is that it spits out a correctly functioning random expression in the error message every single time. I just wish it actually spit out the expression itself.

Silver
When you have a script that you use repeatedly you instead create a function. Then you call upon that function as and when needed. I'm not entirely sure how it works myself. But it would be calling exactly the same script with exactly the same text which I'm sure isn't what you want.

Tbh, I don't think you're ever going to get around working with walls of text given what it is you want to do. There's other ways of working with variables but I'm not that far advanced with Quest yet to have a grasp of it. One of the coders might know though.

jaynabonne
What you really want is either:
1) a text processor option that calls a function (and injects the resulting string), or
2) the ability for the text processor to recurse on replaced strings, so you could set an attribute to that monster string and then invoke the string in text processor markup but then have the text processor kick in again on the replaced string. (Probably not the best way to describe that.)
Neither exists at the moment.

The only way I can think to do it is to construct the text with script, which is a real pain.

Actually, that's only true if you need and want multiple instances within the same body of text. If you only have one instance per move, then you could set up an "on room entry" script to randomly generate the string into a variable and then just use the variable in your text.

bencorman
Thanks for the quick replies, everyone. Really appreciate your help. I edited my previous post to contain the code that I am trying to use, but it sure sounds like I have to reproduce the massive wall of text every time. If anyone ever figures out how not to do that, please feel free to let me know.

Silver
I'm toying with the idea of doing something similar. But just having between a few and half dozen alternatively written paragraphs to keep things interesting. Randomly generating all the individual nouns and adjectives sounds like a place beyond Hades tbh.

Especially as you would then need to start creating millions of scenery objects to suit. Or at least those working with a parser would. :mrgreen:

jaynabonne
Well, I put together a working solution. It includes a library (TextProcessorScript.aslx) with an override for the text processor output function to allow an object attribute to be a delegate that returns a string value. (It can't be a standard script attribute since scripts can't return values. For that, you have to use a delegate.) The library defines a delegate called "TextProcessorFunction", which returns a string.

The sample code has a delegate attribute on the player object which (I believe) reproduces in code what you were doing in your text processor macro. The delegate name is "rname" (for "random name"), and you can inject it into your text at any point by using "{player.rname}". It will then substitute in a randomly generated string.

Unfortunately, gamebook mode doesn't allow attributes to be edited (or even seen) in the GUI editor, so you'll have to use Code View to see what I've done. If you would like, if you post your game file, I could do the edits to get this in place. At the very least, you need to include the library in your game and then set things up as I did in the sample.

If you try this out, both files need to be in the same folder.

Note that the library can be used in any game, even text adventure games (as opposed to gamebooks).

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

Support

Forums