Scope issue for Summon [object] command

Durza
30 Apr 2020, 03:57

Hi, so I'm somewhat new to Quest and am having trouble implementing a summon command. I want the player to be able to summon any object in the game they have visited but am getting stuck when it comes to defining the scope. If I specify a certain room as the scope I can summon the object (move it to to the room the player is currently in), but if I try AllObject() or "world" or any other scope and I try to summon an object that not in the room the player is in then I get an error because the player can't see the object. It seems that I need a scope like NotReachable(), but I don't know how to. Thanks!


Phadion
30 Apr 2020, 04:20

This may help: https://docs.textadventures.co.uk/quest/advanced_scope.html


Durza
30 Apr 2020, 04:44

Thanks, Phaidon! I already checked out that page first, but it's possible I'm missing something. What I want is a scope like AllRooms() but I can't figure out how to do that. The only way I see it working is manually adding every room.


mrangel
30 Apr 2020, 10:15

If you want the player to be able to summon any object, you could use the scope world in a command's basic scope; that includes all objects. But this could lead to problems because that includes rooms and invisible objects.

I get an error because the player can't see the object

Where is this error coming from? The parser doesn't make any kind of checks like this.

Most of the built in commands check that the object they're being used on is reachable (the exceptions being "look at", which only checks an object is visible, and "use on", which expects your own use script to make sure the objects are in sensible places).

If your "summon" command checks if the object is visible and generates an error message, then you should probably make it not do that.

Otherwise, you have misunderstood the error message.

Can you show us the code you are using, and the actual error message you are getting?


Durza
30 Apr 2020, 18:19

Hi mrangel, I have already tried the world command because I thought that would do the job but it doesn't seem to. Earlier I got the default game unresolved text "I can't see that", but now I am getting nothing unless I add my own unresolved text in which case that shows up. Either way, the summoned object doesn't show up nor does the text that accompanies it so I'm assuming it's not working.

Here's my code:
<command name="summon"> <pattern>summon #object#</pattern> <scope>"world"</scope> <unresolved type="string"></unresolved> <script> if (game.pov = Magen Player) { MoveObjectHere (object) msg ("With a loud crack the object appears in the room") } </script> </command>

I'm guessing I'm doing something wrong in the code and the scope is just fine then?

Thanks!


Phadion
30 Apr 2020, 18:44

Get rid of the quotes around the world scope. That should do it. Like this:

<command name="summon"> 
     <pattern>summon #object#</pattern> 
     <scope>world</scope> 
     <unresolved type="string"></unresolved> 
     <script> 
          if (game.pov = Magen Player) { 
             MoveObjectHere (object) 
             msg ("With a loud crack the object appears in the room") 
          }
     </script> 
</command>

Phadion
30 Apr 2020, 18:57

Also, if you wanted to, you could specify the object in the message. Like this:

<command name="summon"> 
     <pattern>summon #object#</pattern>
     <scope>world</scope> <unresolved type="string"></unresolved>
     <script> 
          if (game.pov = Magen Player) { 
            MoveObjectHere (object) 
            msg ("With a loud crack the " + object.alias + " appears in the room") 
          } 
    </script> 
</command>

You would have to make sure the object has a specified alias though, or else it would print, "With a loud crack the appears in the room" If you're not working with aliases, you could just use object.name instead.
Hope this helps.


mrangel
30 Apr 2020, 19:18

Yep, the quotes around "world" are the only error I see with that.

You would have to make sure the object has a specified alias though

That's why it's better to use GetDisplayAlias (object) than object.alias. GetDisplayAlias returns the alias if it has one, and object name otherwise.


Durza
30 Apr 2020, 23:56

Cool, working perfectly now, thanks a lot! Syntax is so annoying lol.