Command scope for not in specific room

When creating a custom command, what do you type into the scope bar for everywhere except one specific room?


hmmm. Are you trying to make sure the command doesn't work if the player is in a specific room... or
are you trying to make sure the command scopes everything in the game except the objects of a specific room?

I think if you wanted to make the command simply not work in a specific room, I'd not change the scope, but make the command script include "if not player.parent=specific room" or howsoever that's correctly typed.

If you're trying to make sure that a room or room's objects are removed from the results of the scope, I think you'd have to do something like finding the list and removing it from the results...

I'm still pretty beginner at this, so I don't know exactly what to do there, but I'd try browsing "using lists" and also maybe this old post from Pixie with examples of useful functions, some of them involve manipulating data from lists: https://textadventures.co.uk/forum/samples/topic/5614/some-useful-functions

Those are my guesses. Maybe there is a simple way to remove something from a scope though?


If you're trying to make sure that a room or room's objects are removed from the results of the scope, I think you'd have to do something like finding the list and removing it from the results...

In this case, I would give the command scope world (all objects), and then remove the ones you don't want.
You can do this by giving the command a script attribute named changecommandscope, which would contain something like this:

foreach (obj, GetAllChildObjects (room_to_exclude)) {
  if (ListContains (items, obj)) {
    list remove (items, obj)
  }
}

(the change commandscope script gets a special variable items listing all the items in scope; which you can modify using list add and list remove)

In case you're interested in other weird scopes, it might be worth knowing that you can put a changecommandscope script attribute on any command, or the player, or the room (including rooms containing the current room). It gets passed the following variables so it can decide how to modify the scope:

  • items - The list to modify
  • command - The command object
  • variable - A string like "object" or "object2", in the case of commands with multiple targets
  • objtype - The type of object it's trying to get scope for (usually "object" or "exit")
  • matched - A dictionary containing objects already matched for this command (so you can make the scope of object2 depend on which object was chosen for object1 or similar)

I don't know if I understand change commandscope scripts yet, and I do want to understand those things, but luckily my problem was a lot simpler. I was being allowed to edit everything in the commands except scope. Finally it just started working again, without telling me why.


Mr. Angel, I'd love to learn more about this!

Is it possible to share an example with these variables labled. (I'm still not exactly clear on what it means to "pass" a variable, but I have a vague sort of sense that it's something we do all the time as we make scripts. Like inputting parameters by putting them in the parenthesis of a function.

Please and thanks for any additional info!


If the variables are passed to the script, that just means they can be assumed to exist as local variables to the script. The same as the parameters of a function.


and you pass them by putting them in parenthesis?

or is passing script variables like we do at the top sometimes?

s = isthisusuallyavariablename?

I think I'm starting to get it.


You pass variables to a script attribute using a dictionary argument to do. But in most cases you don't need to; the only context it's normally used in is when the core libraries pass variables to your script (like the variables I mentioned in the scope scripts, object in a command, or result in a menu response script) - you can just assume that those variables exist.


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

Support

Forums