Removing a Cloned Item Without Using "This" [Solved]

I was curious if there was a way to remove a cloned item without using "this" just like we do for regular objects. For example...

RemoveObject (bootybum)

I noticed we have a CloneObjectAndMove and so on but I wasn't sure how to remove one, except maybe by using alias?

Anyway, the reason I don't want to use "this" is because I've been trying to eliminate using that script in my game as much as possible. I heard a couple of years ago that if Quest updated again and/or moved to being browser-based it would be extremely difficult to incorporate a 'this' script. So as a precaution, I've been removing it wherever possible.

Obviously, the problem is when using cloned items is that they don't get removed with RemoveObject

Is there another way?

Thank you ahead of time! I greatly appreciate it!


Can you use a function to find the name and alias?

msg (
msg (this.alias)

And then maybe you can use its name?

The various CloneObject functions return an object reference.

(Edited to fix errors)

So you could do game.someattribute = CloneObjectAndMoveHere (some object), and later on you can do RemoveObject (game.someattribute).

Or if you want to remove all the clones of a particular object in the current room:

list_of_clones = FilterByAttribute (ScopeVisible(), "prototype", original_object_that_was_cloned)
foreach (obj, list_of_clones) {
  RemoveObject (obj)

If you want to remove the particular object that the player used a verb on, then you need to use this. And if you have a reference to this, why not use it?

I heard a couple of years ago that if Quest updated again and/or moved to being browser-based it would be extremely difficult to incorporate a 'this' script.

That's extremely unlikely. this or some equivalent is at the core of OO programming; every OO language has it, and you really can't do without it. It might not work the same, but it would still be there.

Moving to Javascript, it's conceivable that the name of the variable might change (to avoid confusion between this and $this); or it might stay as this but become a reserved word rather than a variable.

(In Quest, you can do this = SomeObject in the middle of a script to change which object this refers to. This is probably a bad idea and will be confusing for anyone trying to debug your code, but it's valid. In javascript, it would be an error. Similarly, in places where there is no this (in a function or in a script which isn't attached to an object), Quest allows you to create a normal variable called "this". Javascript doesn't)

if Quest updated again and/or moved to being browser-based

Also worth noting that there are a few ways to go about making an entirely javascript-based version of Quest. One (which I believe they're doing for Quest 6) is to make a javascript library that includes many of the same function names as Quest. In this case it's a new engine, and converting your game to it would involve rewriting all of your code anyway. Or there's the option I prefer, writing a JS interpreter that can read Quest's script language. This would be a lot more work for the developers, but should mean that most existing games will work fine.

What unsolved this?

Print expression.

msg (
msg (this.alias)

Remove object.

RemoveObject (this)

Is this what you want?

Oh good! So using "this" won't be a problem then? I was curious how Types were going to get transferred if that was the case but it sounds like everything should be fine. Whew! I was really worried there. I probably will just continue to use "this" as little as possible but it's a load off knowing it won't be mandatory. @[email protected] That was giving me anxiety.

Thanks for all the replies and explanations! Mr.Angel and Jmnevil54 :)

But yes, Jmnevil54 --- that would work but it wouldn't really solve the original issue xD However since the issue isn't an issue, you're would be a nice alternative workaround. But RemoveObject (this) should be fine.

Thank you both so much!


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