Hello dear community!
I have just recently picked up Quest and mostly spent my time finding out about the scripting language and reading through the tutorials and wiki.
I am planning to write an engine to support character stats and random rolls on different traits of the character, similar to a pen&paper RPG. I want to implement these functions in a gamebook-like mode though, but I found that the native Gamebook mode lacks an important funciton for this project, object handling. (As it seems, rooms are just objects in a gamebook file, maybe that's why).
For this reason, I decided to write a simple function to take over the Linking of pages and go from there, unfortunately, I couldn't get my function to work.
I would appreciate any help on this, I also think I have done things a little complicated, any tips highly appreciated.
The function is called "ShowLinks" and reads like this
Choices.Choice1 = Choice1
Choices.Choice1Room = Choice1Room
Choices.Choice2 = Choice2
Choices.Choice2Room = Choice2Room
Choices.Choice3 = Choice3
Choices.Choice3Room = Choice3Room
Choices.Choice4 = Choice4
Choices.Choice4Room = Choice4Room
Choices = NewStringList ()
list add (Choices, Choice1)
if (not Choice2 = "") {
}
list add (Choices, Choice2)
if (not Choice3 = "") {
}
list add (Choices, Choice3)
if (not Choice4 = "") {
}
list add (Choices, Choice4)
msg ("")
ShowMenu (MenuCaption, Choices, false) {
msg (result)
msg (Choices.Choice1Room)
if (result = Choices.Choice1) {
ClearScreen
MoveObject (player, Choices.Choice1Room)
}
else if (result = "Choice2") {
ClearScreen
MoveObject (player, Choice2Room)
}
else if (result = "Choice3") {
ClearScreen
MoveObject (player, Choice3Room)
}
else if (result = "Choice4") {
ClearScreen
MoveObject (player, Choice4Room)
}
}
Edit: I have found the error, which wasn't actually in the function, but the code that called it:
ShowLinks ("Do you want to...", "do A.", room1, "do B.", room1, "", "", "", "")
I had room1 written as "room1" which was the whole error, seems like I have to store it as the object, not as a string.
Edit2: Another question I had: Could I define standard values for a function, so I don't have to declare "" for the choices I don't need? I would like to make this function as flexible as possible, so supporting a variable number of choices is probably the right way to go, but writing 10 choices would require me to write something like ShowLinks ("What you want...", "do A.", room1, "do B.", room2, "do C.", room3, "", "", "", "", "", "", "", "", "", "", "", "", "", ""). This kinda eliminiates the purpose of it being easy or user-friendly.