Once an object has been removed can it later be restored in the game

For example I have two objects
Unicorn
Angry Unicorn
In a script command I'd remove the unicorn and move the Angry Unicorn to the current room.
Later I would want to replace the Angry Unicorn with the Unicorn but as I've removed the Unicorn I'm not certain if this is possible.
I could make the unicorn invisible and the angry unicorn visible but if I typed examine Unicorn then Quest would not know which unicorn I was referring to.

One solution would be move move the unicorns between a temp room (maybe a room called zero) and the current room, but there might be a better solution.

Brian


In a script command I'd remove the unicorn and move the Angry Unicorn to the current room.

That's fine, as long as you remove the object rather than destroying it.

RemoveObject sets an object's parent to the special value null. This means the object is floating in space, outside of any room, where the player can't reach it. You can bring it back whenever you want.

(If you end up creating objects during the game, for example cloning monsters and potions, this can result in hundreds of pieces of space junk floating around, making your save file huge and taking up more memory. If you're cloning or creating objects, you would need to use destroy to get rid of them, but in your case RemoveObject does exactly what you want)


Another way to do it is what i like to do is make non usable rooms as folders so like a room named items then store all items in there or a room called food and store all food items I use this as it also helps keep me organized and just move items back and forth as needed.


mrangel: So to reinstate a removed object is it just a case of moving the object to the current room?

onimike: Your idea sounds similar to my zero room (see my original text).


containment/parent-child/"folder" heirarchy:

grandfather
-> father
->-> son
->->-> grandson

'grandfather' is the root parent of 'father', 'son', and 'grandson'

'grandfather' is the direct parent of 'father'
'grandfather' is the indirect parent of 'son' and 'grandson'

'father' is the direct child of 'grandfather'
'father' is the direct parent of 'son'
'father' is the indirect parent of 'grandson'

'son' is the indirect child of 'grandfather'
'son' is the direct child of 'father'
'son' is the direct parent of 'grandson'

'grandson' is the indirect child of 'grandfather' and 'father'
'grandson' is the direct child of 'son'


more examples:

C drive (drive: internal storage)
-> programs (folder)
->-> quest (folder)
->->-> quest.exe (file)

man
-> pants
->-> wallet
->->-> $5
->->-> $1
-> shirt
woman
-> purse
->-> wallet
->->-> $10

quasi (off my bad memory, lol) quest default new game:

ASL (GAME OBJECT)
-> Objects
->-> game
->->-> Verbs
->->-> Commands
->-> room
->->-> player
-> Functions
-> Timers
-> Walkthrough
-> Advanced
->-> Included Libraries
->->-> 'English.aslx'
->->-> 'Core.aslx'
->-> Object Types
->-> JavaScript


the 'remove (NAME_OF_OBJECT)' Function simply sets the built-in 'parent' Object (reference/pointer) Attribute's Value to 'null'

NAME_OF_OBJECT.parent = null

when an Object's 'parent' Object (reference/pointer) Attribute's Value is 'null', it's actually set to the 'asl' GAME OBJECT (the root parent of quest game: everything must be within the 'asl' GAME OBJECT)

if you want the 'NAME_OF_OBJECT' Object to be back within the default 'room' Room Object, then you'd just do this:

NAME_OF_OBJECT.parent = room
// or
set (NAME_OF_OBJECT, "parent", room)
// or
MoveObject (NAME_OF_OBJECT, room)


whereas, the 'destroy (NAME_OF_OBJECT)' Function actually does destroy the Object: it ceases to exist in your game


Thanks hegemonkhan.

Brian


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

Support

Forums