push #object# direction

Doctor Agon
26 Aug 2017, 19:29

Hi. Trying to set this command up in my game.

Room1 has a button that is out of reach.
Room2 has a block of stone in it.

The block of stone is to heavy to get/take, so the idea would be to move/push stone, from Room2 to Room1,
eg. [push stone north], [push stone south]

I thought I could set up a command, with a regular expression:

^push (?<object1>.*) (?<exit>north|east|south|west|northeast|northwest|southeast|southwest|in|out|up|down|n|e|s|w|ne|nw|se|sw|o|u|d)$

using Quests built in go command, scripting as follows:

if (HasAttribute(object1, "pushable")) {
  do (command, "go")
  MoveObjectHere (object1)
}

But, it doesn't like the 'do (command, "go")' bit.

Anyone have any ideas or suggestions on where I'm going wrong, or how to make this work.
Thankyou.


K.V.
27 Aug 2017, 03:06

Hello,

I just tested this out. If you type something besides a direction after PUSH OBJECT, it says "You can't go there."

Command Pattern:
push #object# #text#

if (HasAttribute(object, "pushable")) {
  HandleSingleCommand ("go " + text)
  MoveObjectHere (object)
}

Doctor Agon
27 Aug 2017, 07:55

Thanks, K.V., that's great. I was trying to make it too complicated.


Doctor Agon
27 Aug 2017, 09:29

It does work, but you have to type 'look' to check if the object has been moved. If I write a message script after the 'Call Function:Go', it still prints the message 'You move stone northeast' when its been unsuccessful.

if (HasAttribute(object, "pushable")) {
  HandleSingleCommand ("go " + text)
  MoveObjectHere (object)
  msg ( "You push the " + GetDisplayAlias(object) + " " + text + ".")
}

I'll have to check if the exit is visible before I run the script.


K.V.
27 Aug 2017, 09:54

Ah, good point!

if (HasAttribute(object, "pushable")) {
  HandleSingleCommand ("go " + text)
  if (game.unresolvedcommand = null) {
    MoveObjectHere (object)
    msg ("You push the " + GetDisplayAlias(object) + " " + text + ".")
  }
}

K.V.
27 Aug 2017, 10:31

UPDATE:

Command Pattern:
^push (?<object1>.*) (?<exit>north|east|south|west|northeast|northwest|southeast|southwest|in|out|up|down|n|e|s|w|ne|nw|se|sw|o|u|d)$

if (HasAttribute(object1, "pushable")) {
  if (game.unresolvedcommand = null) {
    msg ("You push the " + GetDisplayAlias(object1) + " " + exit.alias + ".")
  }
  HandleSingleCommand ("go " + exit.alias)
  MoveObjectHere (object1)
}

Doctor Agon
27 Aug 2017, 14:21

Thanks K.V., was tackling this problem in such a long-winded way.
Have made one adjustment to your script though.
I've removed the:

 MoveObjectHere (object1)

And put the following script before calling the 'Go' function:

object1.parent = exit.to

Also changed the message to a variable 'exit.message' as follows:

 exit.message = "You push the " + GetDisplayAlias(object1) + " " + exit.alias + "."

New updated script:

if (HasAttribute(object1, "pushable")) {
  if (game.unresolvedcommand = null) {
    exit.message = "You push the " + GetDisplayAlias(object1) + " " + exit.alias + "."
    object1.parent = exit.to
    HandleSingleCommand ("go " + exit.alias)
  }
}

The object in question is now waiting to be seen as soon as you enter the room.
Thanks for your help.


XanMag
27 Aug 2017, 15:30

For what it is worth... I put this in a room of mine in X1. It was when I first started coding Quest games so... I'm not 100% it works perfectly, but I have had no complaints about it. =)
I would, of course, add a move object script to move the 'desk' into the room to the east.

   <command name="move desk east">
      <pattern>push desk east; move desk east; pull desk east; push desk e; move desk e; pull desk e</pattern>
      <script>
        firsttime {
          msg ("With great effort, you slide the sheriff's desk toward the east.  It is now directly under the access panel.")
          SetObjectFlagOff (desk, "unmoved")
        }
        otherwise {
          msg ("You've already moved the desk once and once is enough!")
        }
      </script>
    </command>
    <command name="bad move desk">
      <pattern>move desk #text#; pull desk #text#; push desk #text#</pattern>
      <script>
        msg ("It will do you no good to move the desk in that direction.")
      </script>
    </command>
    <command name="desk moved once">
      <pattern>move desk #text#; push desk #text#; pull desk #text#</pattern>
      <script>
        if (not GetBoolean(desk, "unmoved")) {
          msg ("You've already moved the heavy desk once and once is enough.")
        }
      </script>
    </command>
    <command name="move desk">
      <pattern>move desk</pattern>
      <script>
        msg ("You need to indicate which direction you would like to move the desk.")
      </script>
    </command>
    <command name="push desk">
      <pattern>push desk</pattern>
      <script>
        msg ("You need to indicate which direction you would like to push it.")
      </script>
    </command>
    <command name="pull desk">
      <pattern>pull desk</pattern>
      <script>
        msg ("You need to indicate which direction you would like to pull the desk.")
      </script>
    </command>

Doctor Agon
27 Aug 2017, 18:18

Thanks HK. That's the next job, creating a 'push #object#' script telling the adventurer, they need to specify a direction. Not sure if I need to set it as a command, so any object can be pushed or as a verb on the object in question. Maybe both. Hoping to pick up any permutations [push; pull; move] in Regex. But then, I don't know how to change the message, I can't put 'You push the stone east', when you've typed 'move'. Does the expression command handle

exit.message = "You ^(push|pull|move)$ the " + GetDisplayAlias(object1) + " " + exit.alias + "."

K.V.
27 Aug 2017, 19:15

@XM

I can confirm that your script works, sir! (I've moved that particular desk a few times recently.)


@Doc

    exit.message = "You push the " + GetDisplayAlias(object1) + " " + exit.alias + "."

Does this permanently change what it prints when using this exit? (Even when not pushing the object the next time?)


Thanks for this, too: GetDisplayAlias(object1)

I've been using GetDisplayName and changing the indefinite article attribute from 'a' to 'the' after examining certain objects for the first time. This is MUCH easier!


Doctor Agon
27 Aug 2017, 19:52

Hi K.V., I had a look at the 'Go' command. The command uses exit.message as part of it's scripting. Also, I put it where it is, because if it comes a line or two later, if the check box on 'room descriptions' is ticked to clear screen, the message doesn't get seen. I'm also assuming that each time the player moves in the game, the variable 'exit.message' is reset to a blank string. I'm just using a piece of coding that already exists. If you look at a room's exit object, it will read:
To: room2
Type: south
Alias: south
At the bottom of the page, it reads 'Print message when used', that's the exit.message.


K.V.
27 Aug 2017, 20:02

@Doctor Agon

Cool!

By the way: I wasn't questioning your methods. I'm just trying to learn stuff!

(I know you probably didn't take it that way. Just making sure, though! 😏)


Doctor Agon
27 Aug 2017, 22:01

No, that's ok K.V. Still learning stuff myself. That's why I like the forum, bouncing ideas back and forth. Before you posted your first message, I did copy and paste the whole 'Go' command into my 'push object' script, but your way was so much neater. I forgot about the 'HandleSingleCommand' function.


Doctor Agon
28 Aug 2017, 07:50

Still trying to work something out with this. But, I don't know if it's possible.
I've set up my command pattern as a 'regular pattern' as follows:

^(push|pull|move) (?<object1>.*) (?<exit>north|east|south|west|northeast|northwest|southeast|southwest|in|out|up|down|n|e|s|w|ne|nw|se|sw|o|u|d)$

I've read through the page on 'pattern matching': http://docs.textadventures.co.uk/quest/pattern_matching.html
The script for the command is still the same as posted previously

if (HasAttribute(object1, "pushable")) {
  if (game.unresolvedcommand = null) {
    exit.message = "You push the " + GetDisplayAlias(object1) + " " + exit.alias + "."
    object1.parent = exit.to
    HandleSingleCommand ("go " + exit.alias)
  }
}
else {
  msg ("You cannot move the " + GetDisplayAlias(object1) + " " + exit.alias + ".")
}

Is there a way I can change the 'exit.message' to reflect how the object was moved:
You push/pull/move the stone north


K.V.
28 Aug 2017, 08:34
if (StartsWith(player.currentcommand, "push")) {
  cmdverb = "push"
}
else if (StartsWith(player.currentcommand, "pull")) {
  cmdverb = "pull"
}
else if (StartsWith(player.currentcommand, "move")) {
  cmdverb = "move"
}
if (HasAttribute(object1, "pushable")) {
  if (game.unresolvedcommand = null) {
    object1.parent = exit.to
    msg ("You " + cmdverb + " the " + GetDisplayAlias(object1) + " " + exit.alias + ".")
  }
  HandleSingleCommand ("go " + exit.alias)
}
else {
  msg ("You cannot move the " + GetDisplayAlias(object1) + " " + exit.alias + ".")
}

Dcoder
28 Aug 2017, 08:48

Never mind, KV beat me to it.


Doctor Agon
28 Aug 2017, 17:46

That's awesome guys. Thankyou. I need to re-write a few scripts now, I think.


Doctor Agon
30 Aug 2017, 18:37

Many thanks again to K.V. for helping me get this to work.
But I have been experimenting with the following, but it keeps coming up with 'I can't see that'

^(?<text>push|pull|move) (?<object1>.*) (?<exit>north|east|south|west|northeast|northwest|southeast|southwest|in|out|up|down|n|e|s|w|ne|nw|se|sw|o|u|d)$

I've also just seen Pixie's post on this thread: http://textadventures.co.uk/forum/quest/topic/zhzl_m8hd0qoookndtqrqq/inheriting-commands-from-the-direct-parent-object-is-it-possible#cfcaaa88-ecd0-426e-87af-5d08179f297e

Is it possible to do it, and if so, what am I doing wrong.

if (HasAttribute(object1, "pushable")) {
  if (game.unresolvedcommand = null) {
    exit.message = "You " + text + " the " + GetDisplayAlias(object1) + " " + exit.alias + "."
    object1.parent = exit.to
    HandleSingleCommand ("go " + exit.alias)
  }
}

The Pixie
30 Aug 2017, 18:48

I had a play around myself (which inspired the comment on the other thread). If you type PUSH CRATE N, Quest will match that to the built-in PUSH command and to your custome comand, and will pick the built-in one as it scores higher, as it matches "PUSH " outside the capture groups, rather than the two spaces. Having done that, it will complain that it cannot see a "CRATE N". I cannot think of a way around that.


jmnevil54
30 Aug 2017, 19:20

I would just change the spelling.

Tell me how this is different from the regular "push" command?

In my experience, Push is different from push, which is different from PUSH. But I forgot if that was the command thing or the name.


Doctor Agon
30 Aug 2017, 20:32

I've even tried disabling the built-in verb as it says in: http://docs.textadventures.co.uk/quest/pattern_matching.html

You will need to disable the built-in verb. You can do that in the desktop version only, by copying  the verb into your game, and then typing a load of nonsense into the pattern. The player will never  type in that nonsense, so the verb will never get matched.

Never mind.


K.V.
31 Aug 2017, 03:06

My script worked every time I tried it, but I only had 2 rooms I was going back and forth between...

Does it not work for you guys at all?


K.V.
31 Aug 2017, 03:11
You can click here to see old, partly correct stuff. (But I'd just skip down to this post instead, were I you.)

Here's my example game. (It can see the thing.)


Here's the code for the command:

  <command name="push it">
    <pattern type="string"><![CDATA[^(push|pull|move) (?<object1>.*) (?<exit>north|east|south|west|northeast|northwest|southeast|southwest|in|out|up|down|n|e|s|w|ne|nw|se|sw|o|u|d)$]]></pattern>
    <script>
      if (StartsWith(player.currentcommand, "push")) {
        cmdverb = "push"
      }
      else if (StartsWith(player.currentcommand, "pull")) {
        cmdverb = "pull"
      }
      else if (StartsWith(player.currentcommand, "move")) {
        cmdverb = "move"
      }
      if (HasAttribute(object1, "pushable")) {
        if (game.unresolvedcommand = null) {
          object1.parent = exit.to
          msg ("You " + cmdverb + " the " + GetDisplayAlias(object1) + " to the " + exit.alias + ".")
        }
        HandleSingleCommand ("go " + exit.alias)
      }
      else {
        msg ("You cannot move the " + GetDisplayAlias(object1) + " " + exit.alias + ".")
      }
    </script>
  </command>

Of course, I may be misunderstanding what y'all are doing, and my script only works because I'm only using it as I intended it to be used...

Wait...

Is it because I don't have an object in the game with a 'push' verb set up?

It is; isn't it?

(Going to test it out....)


Learning is fun!!!


Nope. Still works. Both things respond accordingly.


> push thing s
You push the thing to the south.

You are in a room2.
You can see a thing.
You can go north.

> push thing n
You push the thing to the north.

You are in a room.
You can see a thing and a cart.
You can go south.
This is only an example game.

push thing s

> push cart
You push it. You push it real good.


I'm not messing with exit.message either, though. (I still wonder if that would print the 'you push the ...' message even when you didn't push the object later in the game...)


This works just as well. (Not the exit. message theory...)

Command
RegEx:
^(push|pull|move) (?<object1>.*) (?<exit>north|east|south|west|northeast|northwest|southeast|southwest|in|out|up|down|n|e|s|w|ne|nw|se|sw|o|u|d)$

if (StartsWith(player.currentcommand, "push")) {
  cmdverb = "push"
}
else if (StartsWith(player.currentcommand, "pull")) {
  cmdverb = "pull"
}
else if (StartsWith(player.currentcommand, "move")) {
  cmdverb = "move"
}
if (HasAttribute(object1, "pushable")) {
  if (game.unresolvedcommand = null) {
   exit.message = "You " + cmdverb + " the " + GetDisplayAlias(object1) + " " + exit.alias + "."
    object1.parent = exit.to
    //msg ("You " + cmdverb + " the " + GetDisplayAlias(object1) + " to the " + exit.alias + ".")
  }
  HandleSingleCommand ("go " + exit.alias)
}
else {
  msg ("You cannot move the " + GetDisplayAlias(object1) + " " + exit.alias + ".")
}

Doctor Agon
31 Aug 2017, 06:44

Sorry, K.V. That script worked great, and I am using it. I was just wondering/experimenting if there was a another way of tackling the issue.


K.V.
31 Aug 2017, 06:58

Oh, no reason to be sorry. It's all gravy!


The difference I see between mine and Pixie's example on the other post is that I'm not using <text>:

^(push|pull|move)

That's That may be why I can "see that"...

So I guesss there's no chance for Quest to override #text# with the PUSH command's priority level thingy, or something?


(The only thing that upsets me worse than 'you can't see that' is Error: Missing )!!!)


The Pixie
31 Aug 2017, 07:05

@KV, we were trying to put the verb into a text variable, so with ^(?<text>push|pull|move) at the start, rather than ^(push|pull|move).

@Doctor Agon, good idea on disabling the verb, that works for me (I should have thought of that as I wrote the page you linked to!). I changed the pattern to "pushzzzzzzz #object#". Make sure the name is not changed.


Doctor Agon
31 Aug 2017, 08:03

Pixie, It still says it can't see it.


The Pixie
31 Aug 2017, 08:37

This works for me:

<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="mapping">
    <gameid>80ea4099-1f83-4b05-a6bc-63af4d951ca2</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
    <gridmap type="boolean">false</gridmap>
    <start type="script">
    </start>
  </game>
  <verb name="push">
    <pattern>pushzzzzzzz #object#</pattern>
    <property>push</property>
    <defaulttemplate>DefaultPush</defaulttemplate>
  </verb>
  <object name="room">
    <inherit name="editor_room" />
    <attr name="grid_label">The Room</attr>
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <exit alias="south" to="kitchen">
      <inherit name="southdirection" />
    </exit>
    <object name="crate">
      <inherit name="editor_object" />
      <pushable />
    </object>
  </object>
  <object name="region1">
    <inherit name="editor_room" />
    <object name="kitchen">
      <inherit name="editor_room" />
      <exit alias="north" to="room">
        <inherit name="northdirection" />
      </exit>
    </object>
  </object>
  <command name="push dir">
    <pattern type="string"><![CDATA[^(?<text>push|pull|move) (?<object>.*) (?<exit>north|east|south|west|northeast|northwest|southeast|southwest|in|out|up|down|n|e|s|w|ne|nw|se|sw|o|u|d)$]]></pattern>
    <script>
      if (HasAttribute(object, "pushable")) {
        object.parent = exit.to
        msg ("You " + text + " the " + GetDisplayAlias(object) + " " + exit.alias + ".")
        player.parent = exit.to
      }
      else {
        msg ("You can't " + text + " it.")
      }
    </script>
  </command>
</asl>

K.V.
31 Aug 2017, 08:49
Click here to view this long, old post -- which has old code and such. Or click this to see the code that really works: http://textadventures.co.uk/forum/quest/topic/guvemyyxheio3tiogk6m9q/push-object-direction#aaafd696-5bf9-407d-a044-6dde4218282e

This totally works (note the verb patterns are RegEx):

UPDATED GAME CODE AFTER WRITING ALL THE NOTES BELOW. THIS CODE WORKS!


<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="mapping">
    <gameid>80ea4099-1f83-4b05-a6bc-63af4d951ca2</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
    <gridmap type="boolean">false</gridmap>
    <start type="script">
    </start>
  </game>
  <verb name="push">
    <pattern type="string"><![CDATA[^(?<text>push) (?<object>.*)$]]></pattern>
    <property>push</property>
    <defaulttemplate>DefaultPush</defaulttemplate>
  </verb>
  <object name="room">
    <inherit name="editor_room" />
    <attr name="grid_label">The Room</attr>
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <exit alias="south" to="kitchen">
      <inherit name="southdirection" />
    </exit>
    <object name="crate">
      <inherit name="editor_object" />
      <pushable />
    </object>
  </object>
  <object name="region1">
    <inherit name="editor_room" />
    <object name="kitchen">
      <inherit name="editor_room" />
      <exit alias="north" to="room">
        <inherit name="northdirection" />
      </exit>
    </object>
  </object>
  <command name="push dir">
    <pattern type="string"><![CDATA[^(?<text>push|pull|move) (?<object>.*) (?<exit>north|east|south|west|northeast|northwest|southeast|southwest|in|out|up|down|n|e|s|w|ne|nw|se|sw|o|u|d)$]]></pattern>
    <script>
      if (HasAttribute(object, "pushable")) {
        object.parent = exit.to
        msg ("You " + text + " the " + GetDisplayAlias(object) + " " + exit.alias + ".")
        player.parent = exit.to
      }
      else {
        msg ("You can't " + text + " it.")
      }
    </script>
  </command>
  <verb name="pull">
    <property>pull</property>
    <pattern type="string"><![CDATA[^(?<text>pull) (?<object>.*)$]]></pattern>
    <defaulttemplate>DefaultPull</defaulttemplate>
  </verb>
  <verb name="move">
    <property>move</property>
    <pattern type="string"><![CDATA[^(?<text>move) (?<object>.*)$]]></pattern>
    <defaulttemplate>DefaultMove</defaulttemplate>
  </verb>
</asl>
HIDDEN TEXT: All the 'notes' I took while making this work. --- #### NOTE:

Before I added PUSH as a verb to the crate (which doesn't have a description, by the way, and you can't pick it up and I don't even know why! I have worked in a parts house, and we had crates, and you could pick some of them up... and if you couldn't, you could see WHY you couldn't pick them up!!!)

Anyway, it just printed the default "You can't push it." before I added PUSH as a verb to the crate. It still let me push it south. I just added the verb to see what would happen.


UPDATE

PULL says 'I can't see that.'


Making a PULL and MOVE verb...


UPDATE

How did you make PULL without it throwing an 'already exists' error?

Oh, you make the verbs in Code View.


I've got PULL working by setting up the verb the same way, but MOVE throws an error:

> move crate
Error running script: Error compiling expression 'TypeOf(object, this.property)': FunctionCallElement: Could find not function 'TypeOf(Element, Object)'

/> move crate s
You move the crate south.

You are in a kitchen.
You can see a crate.
You can go north.


Got it!

Just needed to add <property>. (Why is this, Pixie?)

  <verb name="move">
    <property>move</property>
    <pattern type="string"><![CDATA[^(?<text>move) (?<object>.*)$]]></pattern>
    <defaulttemplate>DefaultMove</defaulttemplate>
  </verb>
  <verb name="pull">
    <property>pull</property>
    <pattern type="string"><![CDATA[^(?<text>pull) (?<object>.*)$]]></pattern>
    <defaulttemplate>DefaultPull</defaulttemplate>
  </verb>

mapping

You are in a room.
You can see a crate.
You can go south.

> pull crate
You can't pull it.

> pull crate s
You pull the crate south.

You are in a kitchen.
You can see a crate.
You can go north.

> push crate
You can't push it.

> push crate n
You push the crate north.

You are in a room.
You can see a crate.
You can go south.

> move crate
You can't move it.

> move crate s
You move the crate south.

You are in a kitchen.
You can see a crate.
You can go north.


K.V.
31 Aug 2017, 09:29

@Doctor Agon and The Pixie,

I just butchered you guys' codes.

I have absolutely nothing else to do, and I don't like my peoples not being able to do something!

JS.fistBump  ()


Now, I'm off to research properties...


jmnevil54
31 Aug 2017, 12:00

Just type Push #obect# instead of "push #object#".


K.V.
31 Aug 2017, 17:32

@jmnevil54,

You just helped me find something I'd have never thought of!

If there is a period ending your command, it is no longer NORTH, now it is NORTH..

(I thought the capital P was getting me at first, but the caps are irrelevant...)


> pull the crate north.
I can't see that. (the crate north.)

> pull the crate north
You pull the crate north.

You are in a room.
You can see a crate.


So my links to push/pull/move in a direction said 'You can't see that.'

{command:Push the crate.} 

{command:Push the crate south.}

{command:Pull the crate.} 

{command:Pull the crate south.}

{command:Move the crate.} 

{command:Move the crate south.}

> Pull the crate.
I can't see that. (the crate.)

> Pull the crate
This is the crate's pull message.


Putting a period after the word that ends the sentence always throws a 'You can't see that' error,

even in a newly created game with no custom verbs or commands.

...unless you allow input of multiple commands in one line separated by "."

So, I learned something about Quest today.


K.V.
31 Aug 2017, 18:41

This works perfectly (for me; of course, I always say that!), and all three verbs are set up on the crate, too:


http://play2.textadventures.co.uk/Play.aspx?id=kzg9ek_f4eq6uorpckkbvq


View Pixie's Code (slightly altered)
<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="pushpullmove">
    <gameid>5cf7d8f8-462d-4d4a-b107-243ceb85991e</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
  </game>
  <verb name="push">
    <pattern type="string"><![CDATA[^(?<text>push) (?<object>.*)$]]></pattern>
    <property>push</property>
    <defaulttemplate>DefaultPush</defaulttemplate>
  </verb>
  <object name="room">
    <inherit name="editor_room" />
    <attr name="grid_label">The Room</attr>
    <description><![CDATA[<br/>{command:Push the crate}{colour:blue:.} <br/><br/>{command:Push the crate south}{colour:blue:.} <br/><br/>{command:Pull the crate}{colour:blue:.} <br/><br/>{command:Pull the crate south}{colour:blue:.} <br/><br/>{command:Move the crate}{colour:blue:.} <br/><br/>{command:Move the crate south}{colour:blue:.} ]]></description>
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <exit alias="south" to="kitchen">
      <inherit name="southdirection" />
    </exit>
    <object name="crate">
      <inherit name="editor_object" />
      <pushable />
      <push>You push the crate a little. Nothing special happens.</push>
      <pull>You pull the crate towards you a little. Nothing special happens.</pull>
      <move>You move the crate a little to the {random:right:left}. Nothing special happens.</move>
      <search>You search it.</search>
    </object>
  </object>
  <object name="region1">
    <inherit name="editor_room" />
    <description><![CDATA[<br/>{command:Push the crate}{colour:blue:.} <br/><br/>{command:Push the crate north}{colour:blue:.} <br/><br/>{command:Pull the crate}{colour:blue:.} <br/><br/>{command:Pull the crate north}{colour:blue:.} <br/><br/>{command:Move the crate}{colour:blue:.} <br/><br/>{command:Move the crate north}{colour:blue:.} ]]></description>
    <object name="kitchen">
      <inherit name="editor_room" />
      <description><![CDATA[<br/><br/>{command:Push the crate}{colour:blue:.} <br/><br/>{command:Push the crate north}{colour:blue:.} <br/><br/>{command:Pull the crate}{colour:blue:.} <br/><br/>{command:Pull the crate north}{colour:blue:.} <br/><br/>{command:Move the crate}{colour:blue:.} <br/><br/>{command:Move the crate north}{colour:blue:.} ]]></description>
      <exit alias="north" to="room">
        <inherit name="northdirection" />
      </exit>
    </object>
  </object>
  <command name="push dir">
    <pattern type="string"><![CDATA[^(?<text>push|pull|move) (?<object>.*) (?<exit>north|east|south|west|northeast|northwest|southeast|southwest|in|out|up|down|n|e|s|w|ne|nw|se|sw|o|u|d)$]]></pattern>
    <script>
      if (HasAttribute(object, "pushable")) {
        object.parent = exit.to
        msg ("You " + text + " the " + GetDisplayAlias(object) + " " + exit.alias + ".")
        player.parent = exit.to
      }
      else {
        msg ("You can't " + text + " it.")
      }
    </script>
  </command>
  <verb name="pull">
    <property>pull</property>
    <pattern type="string"><![CDATA[^(?<text>pull) (?<object>.*)$]]></pattern>
    <defaulttemplate>DefaultPull</defaulttemplate>
  </verb>
  <verb name="move">
    <property>move</property>
    <pattern type="string"><![CDATA[^(?<text>move) (?<object>.*)$]]></pattern>
    <defaulttemplate>DefaultMove</defaulttemplate>
  </verb>
</asl>

If I use a RegEx pattern for the verbs, it acts right.

Is this because Quest has to translate push to (?<text>push)and #object# to (?\<object>.*) first when it's a command pattern, so the PULL that already exists as a RegEx takes priority, seeming how it exists first? (Did that make sense?)

(I'm trying to figure out how libraries alter the order games load with a Start Script and a User Interface Initialisation Script set up too... Today is 'Order of Operations' day (or whatever terminology I should be using... priority?).)


jmnevil54
31 Aug 2017, 19:03

Okay. Thanks. I don't think I did that, but thanks.


Doctor Agon
31 Aug 2017, 21:00

Got this working now. Many thanks again K.V. and Pixie. Now got two ideas for doing the same job.
My Greek slave 'Oudeis', can finally go on the road to freedom.


K.V.
31 Aug 2017, 21:56

Yeah, you did jmnevil54.


If you hadn't said that, I wouldn't have tried entering a complete sentence:

> Push the crate.
I can't see that. (the crate.)


So you indirectly taught me this:

{command:Push the crate.}     //<!--- Quest can't see 'crate.' -->
{command:Push the crate}{colour:blue:.} //<!-- This works! -->

I never even considered the period being a part of the captured text!

That may not be relevant to Doc's problem, but it definitely saved me from making numerous errors in the future!


@Doctor Agon

I was unaware of the gravity of the situation!

Happy to help! (It was all you guys, though. I just plugged the RegEx in instead of the Command Pattern. I didn't even have a reason to try that... just trying stuff out...)


Doctor Agon
31 Aug 2017, 23:53

@K.V.

I'm not messing with exit.message either, though. (I still wonder if that would print the 'you push the ...' message even when you didn't push the object later in the game...)

It did print the exit.message later in the game. Didn't realise. Simple solution.
Added the line

exit.message = null

after calling the 'Go' command.

I've spent more time trying to move the stone block than anything else. I just need to stand on the thing now, immobilise the slave 'Oudeis' so they can't move while they're up there. And continue their road to freedom.


K.V.
01 Sept 2017, 01:00

👍

K.V. likes this.


jmnevil54
01 Sept 2017, 01:24

Oh... Now I see it....

I already knew you couldn't put/enter periods (mostly) into text adventures/Quest. I thought it was common knowledge. I might not have played that many text adventures until joining this site, but I've seen people play them and most of all heard gamers talk about them. Most old games had limited hardware space, so they only had room for certain commands, with no room for error. Hence, why you can't type periods without also naming the object with a period.

This also creates the problem of "extinguish light", or "guess the verb," besides programmers forgetting to put in common synonyms.

Did you know if you have a monster named Unknown Giant Monster, you can type in attack giant monster or attack monster and Quest will understand your command? I learned that recently, on accident.