MoveObjectHere Question [Solved]

Anonynn
19 Jan 2017, 05:20So I know about
MoveObjectHere
But I was wondering if there a...
CloneAndMoveObjectHere
I ask because there is a.
CloneAndMoveObject
and
CloneObject
as well as
MoveObject
Anyone know?
Pertex
19 Jan 2017, 07:14no, there isn't. But you can easily create your own function.
<function name="CloneObjectAndMoveHere" parameters="object" type="object">
return (CloneObjectAndMove(object, player.parent))
</function>

Anonynn
19 Jan 2017, 16:37Withdrawn

Anonynn
31 Jan 2017, 23:31 <function name="CloneObjectAndMoveHere" parameters="object" type="object">
return (CloneObjectAndMoveHere)
</function>
Would this function work as well? And if it was put into another Function?
crystalwizard
01 Feb 2017, 02:26um Anonynn, you've called a function, but not told it what to do. Let's translate this:
return (CloneObjectAndMove(object, player.parent))
........................^^^^^.....................^^.............^^^^^^
...........Use Which function....Do What....Who Owns
If you just do this:
return (CloneObjectAndMoveHere)
All you did was tell the game to try to run a function. The word "return" is a command to the game to expect a value to come back after the function runs.
But you didn't tell it what object to clone (The first part of the function -> CloneObject)
And you didn't tell it who owns the object (the second part of the function ->AndMoveHere)
So the game will try to call the function, and it'll probably crash with some kind of funky error.
Kinda like me saying "Add two numbers and give me a sum" but not telling you which two numbers to add.

Anonynn
01 Feb 2017, 03:41Well, the original code in my "EnemyLoot Function" was...
MoveObjectHere (small_health_potion) ---- for example.
But I'm changing all my object scripts to clone's and having them handle "this" instead of the original object. All of that is done.
Unfortunately, when I changed the scripting in the "EnemyLoot Function"
CloneObject (small_health_potion)
It can't and doesn't move the item into the player's current room. "Here" refers to the location of the player's current room. But there is no code in Quest that can move a clone to the player's current room. That's essentially what I'm trying to figure out.
I was thinking...
CloneObject (small_health_potion)
MoveObjectHere (this)
But I doubt that'll work.

crystalwizard
01 Feb 2017, 05:25MoveObjectHere assigns the parent of the object to be game.pov.parent.
game.pov should be the room you are in.
So try:
function name="CloneObjectAndMoveHere" parameters="object" type="object"
return (CloneObjectAndMove(object, game.pov.parent))
/function
Pertex
01 Feb 2017, 10:27This should work, too:
x = CloneObject (small_health_potion)
MoveObjectHere (x)

Anonynn
01 Feb 2017, 17:37Awesome! I'll try out both and see which I like best. Thank you guys ^_^
So I tried Pertex's first simply because it was easier/quicker to implement and it worked out great. ^_^ Thank you Pertex, and thank you Crystal.
Anonynn.