Rookie trying to figure an eating issue out.

Hello all, I'm a teacher trying to make a simulation for my students. I'm a total rookie to this program and struggling my way through some issues. Most of them, I've figured out. However, this one has stumped me for a week now.

In my game, when someone "hunts", "digs", or "fishes" for an item, I have programed an item in an "offset" room to clone itself and place itself in the inventory. When a character eats an item, then the next time they try to hunt, dig, or fish I get this message:

Error running script: Unknown object or variable 'oysters'

I suspect that my character is eating the object in the "offset" room and not the one in inventory, but I can't figure out how to confirm that.

Any help would be greatly appreciated. However, please remember that I am very new to this.

A possible very simple solution is to skip cloning altogether and just move the object into the other room when “eaten”. Players will never know the difference.

Let me know if that works.

Maybe you're moving the original object (presumably "oysters") into the inventory (and then eating that), rather than the clone ("oysters1")?

You can put in a temporary script to print an expression (oysters.parent) after the action happens. This will tell you which object contains "oysters". If "oysters" is removed/destroyed, the parent should be "null". And, of course, if the parent is the player, then the oysters are in the inventory.

That should work. Can you post the cloning code so we can see why it isn't? (And the eat code if you're not using the standard consumable feature)

You can copy the script in code view, and paste on the forum by placing it between two lines of three backticks:

Code goes here

I'm using the standard consumable feature. I'm using the web based program.

Here's what the code looks like:

CloneObject (Venison)
AddToInventory (Venison)
msg ("You have found some deer. They should be helpful in feeding the colony. ")

Yeah; CloneObject creates a new object (probably named Venison1) with the alias Venison.
AddToInventory moves the object named Venison (the original) to the player's inventory.

That code should be:

newVenison = CloneObject (Venison)
AddToInventory (newVenison)
msg ("You have found some deer. They should be helpful in feeding the colony. ")

(newVenison in this case is a variable containing the name of the clone)

Alternatively, you could use:

CloneObjectAndMove (Venison, game.pov)

(game.pov is an object attribute containing the name of the player object. Moving an object there places it in the inventory)

(filler for getting my edited post, updated/posted)

the 'name' String Attribute of an Object is its ID, so the 'name' of Objects must be unique (just like DNA, no two Objects can have the same 'name' String Attribute)

so, when you clone an Object:

original Object's 'name' String Attribute: deer

cloned Objects' 'name' String Attributes: deer2, deer3, deer4, etc etc etc

so, your code:

CloneObject (Venison)
AddToInventory (Venison)

the 'CloneObject (OBJECT)' Function clones the 'Venison' (original) Object (each time you clone it): Venison2, Venison3, etc etc etc

but your 'AddToInventory (OBJECT)' Function, is moving your original Object 'Venison', into your inventory, and not your cloned Objects 'Venison2, Venison3, etc etc etc'

assuming, everything else with the code of your game is correct for what and how you're trying to do what you want, then we just need to make a simple change to the code you provided us:

CloneObjectAndMove (Venison, player) // this is assuming you're using and didn't change the name of the default 'player' Player Object), otherwise, change the 'player' to whatever you renamed it as, or you can use this too: CloneObjectAndMove (Venison, game.pov)

msg ("You have found some deer. They should be helpful in feeding the colony. ")

as seen above, there's already a built-in helper Function to move the cloned Object:

if you want to generally see how the 'CloneObjectAndMove (OBJECT)' helper Function works:

object_variable = CloneObject (Venison)
AddToInventory (object_variable)

as we create our cloned Object, it ('s location/address) is being stored into an Object (pointer/reference) Variable, as then we can use that Object (pointer/reference) Variable, to do whatever, in this case, to move the cloned Object to our inventory

something a bit more fancy that is usually useful when working with cloned Objects, is being able to know/reference back to the cloned Objects' original Object, which can be done via the same coding trick above:

// this = Venison

object_variable = CloneObject (this)
object_variable.original_object = this

msg ("Cloned Object: " +
msg ("Original Object: " +

// output:

Cloned Object: Venison2 // for the first time its cloned
Original Object: Venison

the 'object_variable.original_object = this' creates an Object (reference/pointer) Attribute (which I named it as 'original_object') on the cloned Objects, storing a pointer/reference (the location/address) of/to the cloned Object's original Object ('Venison')

Thank you all very much. I used the CloneObjectAndMove (Venison, game.pov) option and it worked like a charm. Thank you for explaining everything so clearly. Not only did it fix the issue, but I have a better understanding of the mechanics. I am very grateful.

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