Trouble cloning objects
Lance Thrak
09 Feb 2014, 01:08In my game, I have the following script for the description of an object named "cup":
IF cup CONTAINS ice.
THEN:
- PRINT MESSAGE: "It looks like a cup of ice."
ELSE:
- PRINT MESSAGE: "It looks like an empty cup."
Somewhere else in my game, I have a CLONE OBJECT AND MOVE script that clones the cup and moves the clone to a different room.
Here's my problem: If one cup contains ice, all the cups, including cups that don't contain ice, have the description "It looks like a cup of ice."
How can I make the empty cups have the description "It looks like an empty cup."?
I need an unlimited amount of cups in my game, so an explanation on how to achieve my goals without cloning objects probably won't be helpful.
IF cup CONTAINS ice.
THEN:
- PRINT MESSAGE: "It looks like a cup of ice."
ELSE:
- PRINT MESSAGE: "It looks like an empty cup."
Somewhere else in my game, I have a CLONE OBJECT AND MOVE script that clones the cup and moves the clone to a different room.
Here's my problem: If one cup contains ice, all the cups, including cups that don't contain ice, have the description "It looks like a cup of ice."
How can I make the empty cups have the description "It looks like an empty cup."?
I need an unlimited amount of cups in my game, so an explanation on how to achieve my goals without cloning objects probably won't be helpful.
george
09 Feb 2014, 02:14When you clone the object the new object gets a new name like cup1. The problem is that your script references the original cup directly. You need to substitute the name for the cup you're looking at, so change the script to use the object name instead of just 'cup' -- usually you can substitute 'this' to reference the current object.
Lance Thrak
09 Feb 2014, 02:57This completely solved my problem. Thank you! 

onimike
14 Nov 2014, 03:05george wrote:When you clone the object the new object gets a new name like cup1. The problem is that your script references the original cup directly. You need to substitute the name for the cup you're looking at, so change the script to use the object name instead of just 'cup' -- usually you can substitute 'this' to reference the current object.
Hi was searching for this problem and found this, problem is I still don't understand fully how I would change script to read "THIS" what would I put in there for a rock? Like I have a rock and I want to clone it when you walk in another room, but the scripting does not work the same and reads it as you do not have "SAID" item. Like I want to sharpen the rock but its like im not holding it. Sorry for being a noob.
george
14 Nov 2014, 04:25No worries, basically you write 'this' wherever you normally would write 'rock'. In the Quest scripting GUI wherever there's a regular input form field (so not a dropdown menu) you can write whatever you want.
Here I made a little example.
You sing to clone rocks and then click on them to look at their different descriptions. The use of 'this' is in the look at script for the rock.
Here I made a little example.
You sing to clone rocks and then click on them to look at their different descriptions. The use of 'this' is in the look at script for the rock.
onimike
14 Nov 2014, 04:44Thank you for a quick response, so I just type in newRock = CloneObjectAndMove (rock, room) as an expression or set variable newRock = CloneObjectAndMove (rock, room) to get my rock able to be sharpened even if I do not pick it up? I just tried that and it clones it but does not act like the actual item, I still have to take original rock to make others work.
It States with clone in inventory
Sharpen
"You have to pick up the rock before you can sharpen it."
How do I make its scripts the same?
Sorry im not getting this its probably real easy.
It States with clone in inventory
Sharpen
"You have to pick up the rock before you can sharpen it."
How do I make its scripts the same?
Sorry im not getting this its probably real easy.
george
14 Nov 2014, 05:00I can't say for sure without seeing your code but my guess is you haven't written 'this' in your sharpen script. Don't pay much attention to 'newRock', that's just a temporary variable for that particular script and doesn't have any effect on scripts that occur later in the game.
So my guess is you still have 'rock' written in your sharpen script but you really need to write 'this' where 'rock' is written.
So my guess is you still have 'rock' written in your sharpen script but you really need to write 'this' where 'rock' is written.
onimike
14 Nov 2014, 05:07Wow the thins you learn lmao so sorry and thank you so much wow that was so easy I knew it was just couldn't see where lol thank you again so much this will make a huge difference in my games now 

HegemonKhan
15 Nov 2014, 00:35it's a 'love-hate' relationship in trouble-shooting when you find out it's a simple mistake and not a big misunderstanding with the proper coding:
you're glad (love) it was just a small stupid simple typo mistake, but you're furious (hate) that it took so much effort and~or time in finding it, for being something so simple and stupid as a typo (you wish for the effort, that it was some much bigger mistake, that you'd hopefully be able to fix...), laughs.
when you're able to trouble-shoot your coding well, then you know you're truly learning to code, laughs
you're glad (love) it was just a small stupid simple typo mistake, but you're furious (hate) that it took so much effort and~or time in finding it, for being something so simple and stupid as a typo (you wish for the effort, that it was some much bigger mistake, that you'd hopefully be able to fix...), laughs.
when you're able to trouble-shoot your coding well, then you know you're truly learning to code, laughs
