Controling container messages "is not open"

Alexandre Torres

Hi,
I'm trying to create a book where the player will glue pages. Only certain objects can be added. After the glue, the player cannot remove it.
I did something like this: created a transparent surface. Because I cannot figure out how to control what can be added, I designed the surface as closed, and the pages are automatically added to the book by an script when found. This all works fine, the player can access the pages, and cannot drop then.
However, the message when he tries to drop the page is the problem:
"Book is not open."
I can't figure out how to change this message to something such as "You don't want the tear the book apart" (ObjectNotOpen template)
So I went to plan B. I created a new type that inherits from surface, and I overrode the put and remove commands in order to control what can be added to the surface (and preventing anything from being removed).
It is kind of working, but I think I overdid the solution. The command override is global, so I had to copy the code from corecommands.aslx, adding an if such as:

<command name="removeSpell">
    <pattern>remove #object1# from #object2#</pattern>
    <script>
    if (HasAttribute(object2, "no_remove")) {
	msg ("you cannot remove this.")
     } else  if (not Contains(object2, object1)) { // copied from corecommands
	msg (DynamicTemplate("ObjectDoesNotContain", object2, object1))
     } else {
        DoTake (object1, false)
     }

Is there another way to do that?Could I call something like super() on command? if not, I would suggest to place all command logic in functions, so that the developer donĀ“t need to copy code from corecommands.

Thanks


hegemonkhan

There's a lot of problems people have with containers: open/close/lock/unlock/etc, which I think is mostly due to how much underlying code there is for this stuff (a lot of 'helper' code/functions to make it more user-friendly and including showing up in the GUI/Editor stuff/options/tabs/etc)

there's a lot of ~ 'on entering/exiting/opening/closing/locking/unlocking/etc' Scripts, that often use strings (prompts/messages). You can also take a look at the 'templates' where you can find all of the default responses/prompts/messages, and change them.

if you look at this link (scroll down to the bottom, you can see the complexity of the nesting heirarcy of the 'containers' and like/unlike types):

http://docs.textadventures.co.uk/quest/elements/object.html ( scroll down to the bottom to the 'Object types defined by Core.aslx', and look at all the Attributes above too)

  1. 'openable/closeable' Object Type
  2. 'open' Verb/Script Attribute/Function: these do a few actions automatically, which can cause issues (or you need to find this scripting to change it up to what you want, which isn't common knowledge)
  3. 'close' Verb/Script Attribute/Function: these do a few actions automatically, which can cause issues (or you need to find this scripting to change it up to what you want, which isn't common knowledge)
  4. 'isopen' Boolean Attribute, which is the state/indicator/flag for quest in whether the Object is effectively 'open vs closed' during game play.
  5. 'onopen' Verb/Script Attribute/Function: this does a message/prompt/response, which you may want to change, and there's also the 'templates' too
  6. 'onclose' Verb/Script Attribute/Function: this does a message/prompt/response, which you may want to change, and there's also the 'tempaltes' too.
  7. 'surface' Object Type
  8. 'container' Object Type
  9. 'container_base' Object Type
  10. 'container_closed' Object Type
  11. 'container_open' Object Type

Alexandre Torres

Thank you for the tips.


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

Support

Forums