Problems with a command

I get the error "SyntaxError Unexpected end of file Line1 Column1" when I type "climb bank" during game play.

The player must be wearing rubber boots to climb the bank.

/command>
command name="ClimbBank">
pattern>climb bank
script>
if () {
if (not ListContains(ScopeReachable(), some Rubber Boots)) {
if (game.pov.parent = Stream) {
msg ("I try to climb it...and slip back down")
}
else if (Got(some Rubber Boots)) {
if (game.pov.parent = Stream) {
MoveObject (player, High Bank)
}
else if (game.pov.parent = Room 56) {
MoveObject (player, High Bank)
}
}
else {
msg ("I can't climb at the moment")
}
}
}
</script>
</command>


You seem to have a line at the beginning if () {.

If you're pasting code, you need to put a line of three backticks above and below it so that the forum won't mess up the formatting. Like this:

```
code goes here
```

(If you can't find the backtick on your keyboard, there's three of them in the instructions to the right of the forum's reply box, that you can copy and paste)

From the code you posted, I think the player can only climb if they have rubber boots inside a closed container in their inventory? (As the boots need to be in the inventory, but not in ScopeReachable)
Am I misunderstanding this?


If the player carry's or wears the rubber boots then the player is able to climb the bank to move to 'High Bank' location

This is the code that I'm trying to convert to Quest.
Climb Bank
if Rubber Boots are not available and player is in room Stream
then print msg "I try to climb and slip back down"
else
if player has Rubber Boots
or if player is wearing rubber boots and player is in room Stream
then move the player to High Bank
else
If player in room 56
then move player to room High Bank

I was looking for a 'object not available' command in Quest and 'object not reachable' was the closest I could find.


I was looking for a 'object not available' command in Quest and 'object not reachable' was the closest I could find.

You can put not in front of any boolean expression. One issue with your code is that you have all of the options inside the "boots not reachable" condition. So in order to reach the bank, they need "boots in inventory and boots not available".

Am I correct in understanding that if the player is in Room 56, they can climb whether they have the boots or not? And that they can climb the bank as long as the boots are reachable (so either in the inventory, or in the same room)?

In that case, your code would look something like:

if (game.pov.parent = Stream) {
  if (ListContains (ScopeReachable(), some Rubber Boots)) {
    MoveObject (player, High Bank)
  }
  else {
    msg ("I try to climb it...and slip back down")
  }
}
else if (game.pov.parent = Room 56) {
  MoveObject (player, High Bank)
}
else {
  msg ("I can't climb at the moment")
}

If you want to require the boots to be in the inventory, you'd change ListContains (ScopeReachable(), some Rubber Boots) to Got (some Rubber Boots)

If you want to require the boots to get to the High Bank from either room, it would be:

if (game.pov.parent = Stream or game.pov.parent = Room 56) {
  if (ListContains (ScopeReachable(), some Rubber Boots)) {
    MoveObject (player, High Bank)
  }
  else {
    msg ("I try to climb it...and slip back down")
  }
}
else {
  msg ("I can't climb at the moment")
}

One thing that seems a little awkward to me is that the player can climb a bank using boots that are reachable but not in the inventory. Some games do that, they assume the player character is smart enough to put the boots on if necessary. Which would look something like:

if (game.pov.parent = Stream or game.pov.parent = Room 56) {
  if (ListContains (ScopeReachable(), some Rubber Boots)) {
    WearGarment (some Rubber Bots)
  }
  if (GetBooplean (some Rubber Boots, "worn")) {
    MoveObject (player, High Bank)
  }
  else {
    msg ("I try to climb it...and slip back down")
  }
}
else {
  msg ("I can't climb at the moment")
}

To me that feels more natural - in an area where the boots are needed, the character automatically puts them on before climbing.


Thanks mrangel.

I'm not certain how you do an "or" in a script when using the user interface (maybe you can't).
I agree that it does not make sense that the player is able to climb the wall when carrying his boots.
I might need to add a msg "you need to wear your boots before climbing" or "you put your boots on first" if the player is carrying his boots.
In the adventure the player does not need to use his boots to go from room 56 to the High Bank.

Would this work?
if (game.pov.parent = Stream {
if (ListContains (ScopeReachable(), some Rubber Boots)) {
WearGarment (some Rubber Bots)
msg ("You put your boots on")
}
if (GetBooplean (some Rubber Boots, "worn")) {
MoveObject (player, High Bank)

}
else {
msg ("I try to climb it...and slip back down")
}
}
else {
msg ("I can't climb at the moment")
}
if game.pov.parent = Room 56) {
MoveObject (player, High Bank)
}

The if game.pov.parent = Room 56) condition should be independent of the if (game.pov.parent = Stream condition.


The if game.pov.parent = Room 56) condition should be independent of the if (game.pov.parent = Stream condition.

That doesn't look right to me.

It means that if they're in room 56, they'll see the "I can't climb at the moment" message because they're not at the stream, and then be moved to High Bank.

If that's what you intended, then that looks fine.


Hi mrangel.

I tried changing the code to this:

if (game.pov.parent = Stream) {
if (Got(some Rubber Boots)) {
MoveObject (some Rubber Boots, player)
msg ("You put some rubber boots on")
MoveObject (player, High Bank)
}
else if (game.pov.parent = Stream) {
msg ("I try to climb it...and slip back down")
}
}
if (game.pov.parent = Room 56) {
MoveObject (player, High Bank)
}
else {
}
if (not game.pov.parent = Stream) {
if (not game.pov.parent = Room 56) {
msg ("There is nothing to climb")
}
}

I don't get the error message now.
I didn't find a wear command in the user interface so I used 'move the boots to the player'.
There may be a better way to do it but I needed to make sure I didn't get the message "There's nothing to climb when either the player was at locations Stream or Room 56. If the player types in "climb bank" for any other location then the player well get the "There's nothing to climb message.

I have a lot of commands to enter so I'm doing my best to learn how to write error free scripts.

Brian


(mind going blank, getting old sighs, forgot what I write here, lol, need to do this so that my edited post gets updated/posted)


in the desktop/off-line version:

the '[EXPRESSION]' command-option (drop down bar) allows you to directly type in the code expression that you want


'AND' (conjunction) logic:

https://en.wikipedia.org/wiki/Logical_conjunction#/media/File:Venn0001.svg (the 'true and true = TRUE' is the red area where the two circles overlap/share)

https://en.wikipedia.org/wiki/Logical_conjunction

true and true = TRUE
true and false = FALSE
false and true = FALSE
false and false = FALSE

add new script -> 'scripts' category/section -> 'if' Script -> (see below, an example)

if [EXPRESSION] player.mowed_lawn and player.cleaned_room

-> then -> add new script -> 'variables' section/category -> 'set a variable or attribute' Script ->  (see below)

set variable player.currency = [EXPRESSION] player.currency + 5

-> add new script -> 'output' section/category -> 'print a message' Script -> (see below)

print [EXPRESSION] "Since you cleaned your room and mowed the lawn, you get $5"

else -> add new script -> 'output' section/category -> 'print a message' Script -> (see below)

print [EXPRESSION] "Since you did NOT clean your room and/or did NOT mow the lawn, you do NOT get $5"

'OR' (disjunction) logic:

https://en.wikipedia.org/wiki/Logical_disjunction#/media/File:Venn0111.svg (the 'false or false = FALSE' would be the outside white area of the two circles)

https://en.wikipedia.org/wiki/Logical_disjunction

true or true = TRUE
true or false = TRUE
false or true = TRUE
false or false = FALSE

add new script -> 'scripts' category/section -> 'if' Script -> (see below, an example)

if [EXPRESSION] player.mowed_lawn or player.cleaned_room

-> then -> add new script -> 'variables' section/category -> 'set a variable or attribute' Script ->  (see below)

set variable player.currency = [EXPRESSION] player.currency + 5

-> add new script -> 'output' section/category -> 'print a message' Script -> (see below)

print [EXPRESSION] "Since you cleaned your room and/or mowed the lawn, you get $5"

else -> add new script -> 'output' section/category -> 'print a message' Script -> (see below)

print [EXPRESSION] "Since you did NOT either: clean your room or mow the lawn, you do NOT get $5"

PS

a small additional concept:

(in pseudo code, for speed, I'm lazy)

'AND' (conjunction) logic:

if (NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = VALUE_OR_EXPRESSION and NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = VALUE_OR_EXPRESSION and NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = VALUE_OR_EXPRESSION and NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = VALUE_OR_EXPRESSION and NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = VALUE_OR_EXPRESSION) {
  msg ("TRUE")
} else {
  msg ("FALSE")
}

is the exact same thing/logic as nested 'IFs':

if (NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = VALUE_OR_EXPRESSION) {
  if (NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = VALUE_OR_EXPRESSION) {
    if (NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = VALUE_OR_EXPRESSION) {
      if (NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = VALUE_OR_EXPRESSION) {
        if (NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = VALUE_OR_EXPRESSION) {
          msg ("TRUE")
        } else {
          msg ("FALSE")
        }
      } else {
        msg ("FALSE")
      }
    } else {
      msg ("FALSE")
    }
  } else {
    msg ("FALSE")
  }
} else {
  msg ("FALSE")
}

Thanks hegemonkhan.

At the moment I'm using the user interface but I'm beginning to see the need to directly type code into the code editor.
Things I seem to be missing from the user interface when working on a script are:
AND
OR
WEAR
Unless you know where I can find them.

I understand the logic or OR and AND.


as far as I know there's no built-in 'and' and 'or' buttons for when doing a script

you got to use the '[EXPRESSION]' command-option, and write in the 'and' or 'or' yourself, along with the rest of the expression/script you want to do:

add new script -> 'scripts' section/category -> 'if' Script -> (see below)

if [EXPRESSION] BLAH and BLAH
// or
if [EXPRESSION] BLAH or BLAH

Thanks hegemonkhan.
I'll try that.

Brian


Log in to post a reply.

Support

Forums