Adding an action attribute (Is this a good idea?)
#1623
Replies: 3 comments
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
-
|
I now have a version that seems much better: https://gist.github.com/KVonGit/1ef2f0999de528a71d760965f86fd21f NOTES: Instead of using verbs, this is setup to check the location and objects for an "action" atribute before handling a command the default way. For a room or an object, add an "action" script attribute. Use the Tell function instead of msg in the action script. This will add the text to a queue to print, instead of directly printing, giving the code a chance to prepend the object's display alias before printing the response when there are multiple direct objects. NOTE: When Tell is used outside of an action script, it will print directly using the msg script. Your "action" script will have these local variables:
If you wish your script to override the default behavior, set prsa.overridden to true like this: prsa.overridden = true Currently, a room will have an argument called "rarg", which will be either "m_beg" (for the beginning of the command) or "m_end" (for the end of the command). (NOTE: "m_enter" and "m_exit" could be added and used in rooms' action scripts, but it would be easier to just use Quest's enter and exit scripts, I think.) When you enter a command, the order of operations will be:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm sure I'm overlooking something, and I'm also sure this could be coded better...
When porting the old Infocom games, it's nice to have an
ACTIONattribute in Quest.(We can simply use Quest's verb functionality in most cases, but that gets tedious when there are so many objects and rooms.)
In ZIL, an object/room can have an ACTION property which defines a routine that runs before the default command action (and can possibly override everything, if it returns true).
This test game seems to handle everything correctly, but I overlook stuff more often than not. Plus, the code is most assuredly hacky.
Thoughts? Suggestions?
Test game
Details
ZIL-Lib.aslx
Details
Beta Was this translation helpful? Give feedback.
All reactions