Help?

CatDragon
I posted this a while ago, but I guess it was a bit too vague because I didn't say what I was planning on doing.

I want to make it so that you can do a >stand up command,but you can't do it unless you saw the chains keeping you bound to the wall off. And if i's not the same way, I also want to know how to make it so that you can't do anything else in the room until you stand up.

HegemonKhan
this is a bit advanced, if you're just starting out with quest and/or especially never done coding before.

conceptually:

you need two 'indicators/flags' (such as Boolean Attributes), which can then be checked (such as via the 'if' Script)

indicators/flags (using Boolean Attributes for this conceptual sample example):

(Room Object Name: dungeon)
Attribute Name: is_chains_seen
Attribute Type: boolean
Attribute Value: false
and/or, in scripting code: dungeon.is_chains_seen = false // your indicator/flag is initially set saying you've not yet seen the chains

(default Player Object Name: player)
Attribute Name: is_standing_up
Attribute Type: boolean
Attribute Value: false
and/or, in scripting code: player.is_standing_up = false // your indicator/flag is initially set saying that you're not yet standing up

you have+do some action (such as using the built-in 'look' Verb for your 'dungeon' Room Object) to see the chains, and for its scripting, you make it so:

dungeon.is_chains_seen = true // your indicator/flag is now set saying you've seen the chains
msg ("You look around the dungeon, seeing/realizing the chains that shackle you to the dungeon wall")


now, your 'standup' Command/Verb's scripting is set up like this:

if (not player.is_standing_up and player.parent = dungeon and dungeon.is_chains_seen) {
player.is_standing_up = true // your indicator/flag is now set to being true, you're now seen by quest as being standing up
msg ("You stand up with difficulty due to being beaten and tortured by the guards earlier.")
} else if (player.parent = dungeon and not dungeon.is_chains_seen) {
msg ("Sorry, but you need to have seen the chains before you can stand up")
} else if (player.is_standing_up) {
msg ("You're already standing up, silly.")
}


hopefully you can see/understand the above code and its logic in how it is working

then, for whatever else you want to do, 'whatever' Verb/Command, you have script like this:

if (player.is_standing_up) {
// 'whatever' Script(s) for when you are standing up
} else {
// 'whatever' Script(s) for when you're not standing up
}

HegemonKhan
P.S.

if you want to make it more advanced, you can hide/remove/show/reveal your Verb (not sure about Commands though), until you've seen the chains and/or are standing up. But, let's first get the basic functionality that you want, working first, and then if you want this functionality too, then we can work on getting this set up for you too.

CatDragon
I feel stupid for saying this but.. I have no idea what any of that means.

CatDragon
This would be so much easier if the tutorial wasn't out of date.

Marzipan
Whoops, I'd forgotten about this. Give me a few minutes.

Marzipan
Hopefully looking at the file and seeing exactly how it's done will help if you're having trouble following the explanations posted. I used a boolean here, but keep in mind that's only one way of doing this. For a simple yes/no thing, simply checking whether an object is switched on and off works as well.

Anyway, Quest has extensive documentation so I highly recommend you read through the tutorials. Setting a flag or an attribute is a pretty basic thing that allows for a lot of customization and flexibility and you won't be able to get very far making most games without it.

The tutorial may be out of date in a few aspects, but this isn't one of them. We're talking about a very simple situation here of a custom command and some if/then checks. The sections on using scripts, custom attributes, custom commands and 'More Things to Do With Objects' would've given you everything you needed for dealing with this and a thousand other situations like it. I can't really over stress the importance of you figuring out commands and if/then logic, because it's kind of one of the most necessary building blocks for writing a game.

CatDragon
But the tutorials are out of dates- The pictures shown on it look nothing like what i'm using.

CatDragon
Also.. I don't have anything that can play that.

Marzipan
....okay, so step one. Download the Quest program. To write Quest games in.

HegemonKhan
If you can, downloading quest onto your computer (assuming you have one of course), makes everything so much easier. If you do download quest, then you can play/study Marzipan's and/or others' games (I highly recommend playing XanMag's tutorial game).

---------

learning Attribute usage and the 'if' Script, is the first major thing you must learn, after the basics of using quest. As these two things, especially when used together, let's you do 90% of everything that you want to do in/for your game.

-------

this will probably further confuse you, sighs, but here it is, a guide I made on using Attributes and the 'if' Script:

viewtopic.php?f=18&t=5559

--------

have you gone through most of the tutorial ??? as this does help you get a general understanding of the basics, and a bit into using Scripts and Attributes.

CatDragon
Do I have to restart my game, since I've been using the browser version? Not that there's much to redo-

CatDragon
And i'm assuming that the reason the tutorial looked different is because it wasn't made for the web version

HegemonKhan
I'm not sure... Ive not really done much with online games.... if you can, download your own game... otherwise, just remake the game if it's not too much work, or if it is really important, you can always ask Alex for help.

others can answer this question of yours better than I can.

-----

HK edit:

the online/web version of quest is much more limited. It doesn't have all of the nice features/functionality as does the actual download of quest to your computer/desktop.

HegemonKhan
do you at least get the concept of 'indicators/flags' ???

for example:

a light switch in your house, different things happen when it is flipped on/up vs off/down, right?

if (house.lightswitch.flipped_on = true) { msg ("The house is illuminated by the lights in the ceiling") }
else if (house.lightswitch.flipped_on = false) { msg ("The house is dark without its lights turned on") }

----

if (animal.type = "lion") { msg ("Oh $#$@!, the lion gobbles you up!") }
else if (animal.type = "zebra") { msg ("Ahhh, look at the beautifullly striped zebra!") }

what happens when: animal.type = "lion", ???
what happens when: animal.type = "zebra", ???

Marzipan
CatDragon wrote:Do I have to restart my game, since I've been using the browser version? Not that there's much to redo-


You can download your game and open it in the program to keep working on it.

Really though, one thing that worked out pretty well from me when I was learning the basics was to make several little files testing out and teaching myself various things, so that I had working demos at hand whenever similar situations would come up in my real game. Things like a quest journal that would update itself at certain events, or a container that could hold different levels of water, or a flashlight or a shotgun with ammo. (Amusingly enough, those last three all use the same basic principle. Just telling the game to track how often or for how many turns you can use an item.)

CatDragon
I kinda get it. DO you know what page on the tutorial i'd be able to find all this on?

HegemonKhan
here's some tutorial page links for you:

http://docs.textadventures.co.uk/quest/ ... butes.html
http://docs.textadventures.co.uk/quest/ ... ripts.html
http://docs.textadventures.co.uk/quest/ ... mands.html
http://docs.textadventures.co.uk/quest/ ... jects.html

and here's the guides section (it's a bit hidden on the doc):

http://docs.textadventures.co.uk/quest/guides/

-----------

let's make a simple sample game to learn Attributes and the 'if' Script, alright?

create a new game, and choose 'text adventure' of course

we're going to create two Verbs, 'stand_up' and 'lay_down', which will (require and) toggle a created Boolean Attribute 'is_standing_up' for this simple sample game.

let's create the Boolean Attribute on the 'player' Player Object:

'player' Player Object -> 'Attributes' Tab -> Attributes (the bottom box I believe) -> Add -> (see below)

(Object Name: player)
Attribute Name: is_standing_up
Attribute Type: boolean
Attribute Value: false // if you want to start laying down // or Attribute Value: true // if you want to start standing up

and, if this will work as I hope it will, let's create a Status Attribute, for us to see the 'is_standing_up' Boolean Attribute's Value in the pane on the right side during game play:

'player' Player Object -> 'Attributes' Tab -> Status Attributes (the top box I believe) -> Add -> (see below)

(Object Name: player)
Attribute Name: is_standing_up
Attribute Field (Value): Standing: !
// hopefully it'll work, displaying in the 'status' pane on the right side:
// Standing: true
// or
// Standing: false

now, let's create our two Verbs:

1. 'room' Room Object -> 'Verbs' Tab -> Add/Create/Name your own -> (see below)

Verb Name: stand_up
Verb Script: (see below)

run as script -> add new script -> scripts -> 'if' Script -> [EXPRESSION] -> if [EXPRESSION] player.is_standing_up
then,
-> add new script -> output -> 'print a message' Script -> [MESSAGE] -> print [MESSAGE] You're already standing up, silly.
else,
-> add new script -> variables -> 'set a variable or attribute' Script -> [EXPRESSION] -> set variable player.is_standing_up = [EXPRESSION] true
-> add new script -> output -> 'print a message' Script -> [MESSAGE] -> print [MESSAGE] You're now standing up.

2. 'room' Room Object -> 'Verbs' Tab -> Add/Create/Name your own -> (see below)

Verb Name: lay_down
Verb Script: (see below)

run as script -> add new script -> scripts -> 'if' Script -> [EXPRESSION] -> if [EXPRESSION] player.is_standing_up
then,
-> add new script -> variables -> 'set a variable or attribute' Script -> [EXPRESSION] -> set variable player.is_standing_up = [EXPRESSION] false
-> add new script -> output -> 'print a message' Script -> [MESSAGE] -> print [MESSAGE] You're now laying down.
else,
-> add new script -> output -> 'print a message' Script -> [MESSAGE] -> print [MESSAGE] You're already laying down, silly.

-------

and now, you can test/play your game, being able to use the two Verbs to toggle between/back-and-forth of you being standing up vs laying down.

The Pixie
You need a way for the game to know whether the player is stood up or not. The way to do that is with an attribute, which is just a value that is connected to a name and a thing. The name and thing can be anything, but this is tracking if the player is stood up, so let us say the thing is the player, and the name is "is_standing_up". It is a bit like a record in a database; a person's address is an attribute of that person, with "address" being the name, and the actual address is the value. If the person moves house, the value will change, but the attribute is still called "address".

Either the player is stood up or not, so the type of attribute to use is a flag, which can be on or off (also called a Boolean, which can be true or false).

Flags start the game off (or not there at all, but the effect is the same), so this is why the flag is "is_standing_up" rather than "is_lying_down".

Oh, and we also need one for the chains, let us call it "has_sawn_chains".

So on to Quest, and your STAND UP command. It wants to look like this:
standup.png

The first point is that is will accept STAND or STAND UP; try to cover as many options as you can.

The script is a big if/elseif/else block. The general strategy for commands is to handle the failures first. Is the player already stood up? If so, give a message. Is the player still chained up? If so, give a message. If we get to the end, all is good, and the command is successful, and the flag is set so next time around we know the player is stood.

You will need a SAWN CHAIN command, and that will also have to turn on the "has_sawn_chains" flag (and should first check it has not already been done).

Marzipan
And honestly, while sawing the chains might be a good basis for a puzzle, sometimes it's best and saves a lot of hassle for the player and author both to just assume the character will automatically do things like stand up when trying to exit a room.

XanMag
In X2, I had a situation where the player was being squished by a really fat and dead guard. The only command I wanted to work was lift guard or move guard. This is basically what I did. You could, to alleviate this problem with coding, simply make a new room titled 'somewhere chained to a wall'. In this room you could make a couple of commands. One the handles ALL inputted that deals with movement (n;ne;nw;se;s;se;sw;w;e;d;u;north;northeast, etc...) and print a script that says "You try to wiggle out of your predicament, but the chains are preventing you from doing so." Add another command for anything else #text# and print a message like "You try to do that, but the chains make it impossible to do much of anything of the sort." Add another command for saw chain (saw chain; cut chains; saw chains with knife;cut chains with knife, etc...) and print a message "You saw and saw and saw and eventually the chains break free." Here, you add another script that moves the player to the room where the chains are located. When you move the player, the commands for the specific "room" where the player was chained no longer exist.

In essence, it appears to the player that the room is ONE room, but in code it is two. This allows you to have specific commands for when the player is chained and when the player is not. That way, you would not need to fiddle with all of the above.

The Pixie
You need to consider what happens if the player drops something in one room; will it stil be there in the other? If this is right at the start of your game before he can get anything, that may not be an issue, but you do need to think carefully.

XanMag
You can also account for dropping objects in another command, too. drop #text# or drop #object# (not sure of the proper syntax there) results in a print message stating "Seeing as you are chained to a wall, dropping that is nearly impossible as well as unnecessary."

Bottom line, try stuff, if it doesn't work, ask! :)

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

Support

Forums