One Object Becomes Two?

What is the best way to take apart a single object so it becomes two? For instance, the player has a shovel and can remove the blade to then have a handle object and a blade object separately... Do I create the two objects and somehow "put them together" first, or do I create just a shovel object and then run a script that deletes the shovel object and then creates a blade object and a handle object when something like "remove blade" is typed?

You don't need to dynamically create and destroy objects (unless you really like and want to). What is often done is to have a special room (perhaps called "limbo" or something) which has no way in or out. In other words, it's a hidden room, used only to store objects. You'd have the handle and blade objects be in that room initially.

When the shovel is dismantled, you'd move the shovel to "limbo" and move the two pieces from "limbo" to the player. If the player reassembles them, you'd reverse the process.

jaynabonne wrote:You don't need to dynamically create and destroy objects (unless you really like and want to). What is often done is to have a special room (perhaps called "limbo" or something) which has no way in or out. In other words, it's a hidden room, used only to store objects. You'd have the handle and blade objects be in that room initially.

When the shovel is dismantled, you'd move the shovel to "limbo" and move the two pieces from "limbo" to the player. If the player reassembles them, you'd reverse the process.


That limbo room idea is super useful thanks! How would I handle the verb for the initial complete shovel object? If I enter "remove blade" as a verb then it only works if I then type "remove blade shovel" which doesn't make much sense. Should I just make the verb "remove blade from"...?

You could add a couple of custom commands, which would cover all possibilities. What I like about commands over verbs, is that you can have infinite possibilities in just a single self-contained command, separated by semi-colons: remove blade from handle; remove blade; take blade off handle; dismantle shovel...

Well, thanks guys...limbo room and custom commands are my new best friends! Together they worked perfectly for what I needed to do.

Just a quickie on custom commands; they can be specific to a room (will only be accepted when player is in that room), or global (will be accepted regardless of where the player is). For the former, you would naturally add it to that room (right-click, add a command), for global add it to the 'game' folder (top of tree in left pane).

I've no doubt you'd already figured that out, but it's still worth mentioning.