Login
Remember
IF Answers
Ask a Question

# I want to make a verb that requires to things at once. How do I do this this? [internet version]

0 votes
114 views
asked Aug 27 in Authoring by Plink333

Specifically, I want it to be that the player can only skin the wolf if:
1. The wolf is dead
AND
2. The player has a stone

Using flags, I can make the wolf dead, and I can make it so that the wolf must be dead for skinning. I can also make it so that a stone is needed for skinning. The problem is, I cannot make it so that BOTH of these is required. Any help is welcome, thanks in advance

-- Plink333

- quest
- text-processor
- if-script

## 1 Answer

0 votes
answered Aug 27 by TM123 (1 point)
edited Aug 27 by TM123

Here's one way to do it.
On the wolf's skin verb, set it to "run a script"
click on the "code view" icon that looks like a page and paste this in. change the attribute names (player.hasstone and wolf.isdead) to the ones you are using. If they are both true, it prints "You skin the wolf." It also moves a wolfskin object to the player's inventory (from a 'nowhere' room) and changes the wolf's "look" description.

switch (true) {
case (not wolf.isdead and not player.hasstone) {
msg ("You can't skin the wolf!")
}
case (wolf.isdead and not player.hasstone) {
msg ("You need a stone to skin the wolf.")
}
case (not wolf.isdead and player.hasstone) {
msg ("The wolf won't allow you to skin it.")
}
case (wolf.isdead and player.hasstone) {
msg ("You skin the wolf.")
AddToInventory (wolfskin)
wolf.look = "This is the skinned corpse of a wolf."
}
}

Otherwise, if you have the script worked out, to require two conditions:
if (wolf.isdead and player.hasstone) {script}
You could have three conditions with another "and", and there are other things you can do like:
if (not wolf.isalive and (player.hasstone or player.hasknife)) {script}

commented Aug 27 by hegemonkhan (161 points)
edited Aug 27 by hegemonkhan
TM123 already covered most of it, except this option too: nested 'ifs', see below:
if (wolf.isdead) {
if (player.hasstone) {
// blah script~s
} else {
// blah script~s
}
} else {
if (player.hasstone) {
// blah script~s
} else {
// blah script~s
}
this method above, is the same as the 'non-nested ifs' method below:
(this is the equivalent of TM123's use of the 'switch' Script~Function~whatever. The 'if' and the 'switch' are the same thing, just different designs~formats)
if (wolf.isdead and player.hasstone) {
// blah script~s
} else if (wolf.isdead and not player.hasstone) {
// blah script~s
} else if (not wolf.isdead and player.hasstone) {
// blah script~s
} else if (not wolf.isdead and not player.hasstone) {
// blah script~s
}
---------
sometimes, depending on your design, one method may be easier to use, understand, and get working correctly, than the other method.
------------------------
bitwise (logic) operators:
AND: and (quest uses), &, &&, etc?
OR~XOR: or (quest uses), |, ||, etc?
NOT: not xxx = xxx (quest uses), <> (quest uses), !, !=, etc? Pretty self explanatory: not or not equals
--------------
variable1 bitwise_logic_operator variable2 --> result (returned value)
AND:
true and true --> TRUE
true and false --> FALSE
false and true --> FALSE
false and false --> FALSE
OR~XOR:
true or true --> TRUE
true or false --> TRUE
false or true --> TRUE
false or false --> FALSE
----------------------------
a 'AND' example:
if (x=1 and y =1) --> TRUE --> { ...then do these script~s... ]
// if: x=0, y=1 --> x:(0 = 1):false and y:(1=1):true --> FALSE
// if: x=1, y=1 --> x:(1=1):true and y:(1=1):true --> TRUE
// if: x=1, y=0 --> x:(1=1):true and y:(0=1):false --> FALSE
// if: x=0, y=0 --> x:(0=1):false and y:(0=1):false --> FALSE
// 'AND' requires *ALL* variable conditions to be true for the 'if' expression to be TRUE (for it to run its scripts)
a "OR~XOR' example:
if (x=1 or y =1) --> TRUE --> { ...then do these script~s... ]
// if: x=0, y=1 --> x:(0 = 1):false and y:(1=1):true --> TRUE
// if: x=1, y=1 --> x:(1=1):true and y:(1=1):true --> TRUE
// if: x=1, y=0 --> x:(1=1):true and y:(0=1):false --> TRUE
// if: x=0, y=0 --> x:(0=1):false and y:(0=1):false --> FALSE
// 'OR~XOR' only requires a minimum of one of its variable conditions to be true, for the 'if' expression to be TRUE (to run its scripts)
//
// or to say it differently:
//
// 'OR~XOR' is *ONLY* FALSE (it doesn't run its script~s), when all variable conditions are false.

## Related questions

- In a Gamebook, how do I fix that the text processor is not working properly on my version of Quest (I think)?
- Quest Gamebook: Return to a previous page with multiple links, and make link already chosen inactive
- Help! I need to use a candle as a light source in rooms in my Quest text adventure game
- How do you hide a verb and then make it visible under certain conditions?
- How to make a verb like "put ____ in ____" ?

...