Advanced Gamebook Functions (Going where no GB has gone b4)

Entropic Pen
For the season of giving thanks I want to give thanks to Alex (and company) for making the Quest Engine. If it wasn't for Quest, I would've given up on my dreams of making games a long time ago. And to thank him and the community I'm publishing code that can advance the field of game books starting with this little number: A random page link order function.

This script will print out a list of links in a random order which will remove the redundancy of "oh yeah I have to select the first link... first link... second link... first link again... then third link", making gamebooks more tedious in a way that adds a level of awesomeness in my opinion.

UPDATE 12/7/13: Now the process is in one function with THREE parameters that'll save space both in game data and script blocks. Note that the parameters must be delimited lists, the delimiter is a parameter which you can choose. If a page name or link text has the delimiting character in them the function will process it as separate values.

Notes: I made this script as easy-to-implement as possible, but if you have any questions please ask me.

Entropic Pen
We're going where no gamebook has gone before by making a TA-GB hybrid!

Why? Well as simple as gamebooks are to make, they lack the luxuries of objects, variables, and functions as would TA's have. Here is a small demo of a TA/GB Hybrid to build off of, what you make of it is up to you:

INCLUDES:
- A function that can output a list of pages with the option to randomize the items or not
- Another function that can turn a delimited string into a stringlist with the items in random order
- An example of the "Reaction/Combat System" that is used in the Videogame Master series
- NEW: A function that can take a pre-made stringlist and randomize the items (an example of it is in the demo)

Entropic Pen
Don't you just hate doubles? Those pesky little variable types keep crashing your game in any place you need Integers. "If only there was a way to turn a double into an integer!" - a stereotypical woman in a commercial. Well now you can with Entropic Enterprises' new DOUBLE-TO-INTEGER Function 2000(Trademark Pending):

1) Create a "double_to_integer" function that will return an "Integer", and have "double" as one of the parameters.

2) Then insert this code into the function:

strdouble = ToString(double)
split_double = Split(strdouble,".")
strinteger = ListItem(split_double,0)
integer = ToInt(strinteger)
return (integer)


3) To use this function, simply do this:

// a pesky double variable
dbltest = 2.17
// this will turn dbltest into an integer
inttest = double_to_integer(dbltest)
//
msg("Double Value: " + dbltest)
msg("Integer Value: " + inttest)


Okay, so it just takes the numbers in front of the decimal place and returns it as a number, but I found it to be extremely useful.

jaynabonne
You can also do this using the already existing floor function:

inttest = floor(dbltest)

Entropic Pen
Back again to post more bits of code, and this one to me has been the most useful in both "Entropic Adventure" and the "Videogame Master" series. It's a function that returns a random item from a stringlist:

Name: rand_string
Parameters: list
Return Type: String

int_rand = GetRandomInt(0,ListCount(list)-1)
str_return = ListItem(list,int_rand)
return (str_return)


Implementation:

sttringlist = Split("herp,derp,merp",",")
rand_str = rand_string(stringlist)
msg ("Result: " + rand_str)


I mainly use this to create randomized phrases, or pick out a scenario for a event with the use of switch statements.

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

Support

Forums