Boxes and ladders? Better with JavaScript? I'm only using the website
farleyknight
02 Jun 2016, 12:34Hey all,
New to using Quest. I'm a programmer and I've done games in the past, but I'm bored and wanted to try out creating text adventure games. It's definitely different from the Inform engine in some ways. Specifically I noticed that there aren't built in mechanics for boxes and ladders like there are in Inform.
For example, standing on a box or a ladder should make some objects accessible. There are 'features' for edible or switchable but no 'standable'. I started using my own flags for standing on things, but I can see this getting kind of hairy. Like, if I had a ladder and a box, and I only used object flags, I would have to do a lot of drop down selecting to ensure that they cannot both stand on the ladder and on the box at the same time.
I noticed others talking about using JavaScript for complex interactions, which I'm all about. However it seems to only be robustly available on Windows. The website just provides the smallest text area to add JavaScript. And I would imagine it's probably not easy to debug that script from the website.
How do others implement "standing on" functionality? Is anyone else using JavaScript heavily while on the website?
Thanks!
- Farley
New to using Quest. I'm a programmer and I've done games in the past, but I'm bored and wanted to try out creating text adventure games. It's definitely different from the Inform engine in some ways. Specifically I noticed that there aren't built in mechanics for boxes and ladders like there are in Inform.
For example, standing on a box or a ladder should make some objects accessible. There are 'features' for edible or switchable but no 'standable'. I started using my own flags for standing on things, but I can see this getting kind of hairy. Like, if I had a ladder and a box, and I only used object flags, I would have to do a lot of drop down selecting to ensure that they cannot both stand on the ladder and on the box at the same time.
I noticed others talking about using JavaScript for complex interactions, which I'm all about. However it seems to only be robustly available on Windows. The website just provides the smallest text area to add JavaScript. And I would imagine it's probably not easy to debug that script from the website.
How do others implement "standing on" functionality? Is anyone else using JavaScript heavily while on the website?
Thanks!
- Farley
The Pixie
02 Jun 2016, 13:13Quest has nothing built-in, but here is a quick guide to doing it yourself:
viewtopic.php?f=18&t=3997&p=26814&hilit=reach#p26814
JavaScript is basically for do fancy stuff in the UI. It is not easy getting data from JavaScript back into quest.
viewtopic.php?f=18&t=3997&p=26814&hilit=reach#p26814
JavaScript is basically for do fancy stuff in the UI. It is not easy getting data from JavaScript back into quest.
farleyknight
02 Jun 2016, 16:45Is it possible to import that code sample into the website? Or is it only possible on the Windows client?
The Pixie
03 Jun 2016, 08:46No... And you cannot edit attributes directly, or add new types either... Or overwrite existing functions and templates. I am afraid that that means that technique will not work. Sorry, I should have checked that before posting.
I would suggest an attribute on the player that holds what he is stood on, rather than flags on the objects, but have a flag on the thing on the shelf that indicates if it has been taken off the shelf.
On the Script tab of the game object, put this in for script to run when entering a room, so the player is not still stood on something when going somewhere else.
For the book, set it to be scenery. Then, on the Inventory tab, set the Take behaviour to be a script:
For the shelf, set its description to be a script:
Then add two new commands (if off-line, I would recommend verbs, but verbs have issues on-line too). The first line of the first script needs to include every object the player can stand on; I have assumed objects called "stool" and "ladder".
Command pattern
stand on #object#;stand #object#;get on #object#;up on #object#
standon
Command pattern
get off #object#;off #object#;down from #object#;get down from #object#
getoff
I would suggest an attribute on the player that holds what he is stood on, rather than flags on the objects, but have a flag on the thing on the shelf that indicates if it has been taken off the shelf.
On the Script tab of the game object, put this in for script to run when entering a room, so the player is not still stood on something when going somewhere else.
player.stoodon = null
For the book, set it to be scenery. Then, on the Inventory tab, set the Take behaviour to be a script:
if (GetBoolean(book, "takenfromshelf")) {
msg ("Taken.")
book.parent = player
}
else if (player.stoodon = null) {
msg ("The shelf is too high, you canot reach the book.")
}
else {
msg ("Taken.")
book.parent = player
book.takenfromshelf = true
}
For the shelf, set its description to be a script:
if (GetBoolean(book, "takenfromshelf")) {
msg ("The shelf is empty.")
}
else {
msg ("On the shelf you can see a book.")
}
Then add two new commands (if off-line, I would recommend verbs, but verbs have issues on-line too). The first line of the first script needs to include every object the player can stand on; I have assumed objects called "stool" and "ladder".
Command pattern
stand on #object#;stand #object#;get on #object#;up on #object#
standon
if (not object = stool and not object = ladder) {
msg ("You cannot stand on " + GetDisplayName (object) + "!")
}
else if (player.stoodon = object) {
msg ("You are already on it!")
}
else {
if (not player.stoodon = null) {
msg ("First you get down from " + GetDisplayName (player.stoodon) + ".")
}
if (not object.parent = game.pov.parent) {
msg ("You put down " + GetDisplayName (object) + " on the ground.")
object.parent = game.pov.parent
}
msg ("You stand on " + GetDisplayName (object) + ".")
player.stoodon = object
}
Command pattern
get off #object#;off #object#;down from #object#;get down from #object#
getoff
if (player.stoodon = object) {
msg ("You get off " + GetDisplayName (object) + ".")
player.stoodon = null
}
else {
msg ("You are not on it!")
}