1
Technical forum / Re: Difficulty combining inventory items
« on: July 03, 2015, 06:16:10 AM »
Hello Anarchist,
Thanks for your response. I was actually already combining two inventory items without any problem so I couldn't figure out what was going wrong. I posted the code that I had in the first posting.
Here is the situation. I have a dog, an empty syringe, and empty tubes in inventory. I click on the dog with the empty syringe which causes the empty syringe to be be deleted and a filled syringe to appear in inventory. (It never occurred to me to click the syringe with the dog. That would be a bit awkward.) Then I wanted to fill the tubes using the filled syringe. That is the part that wouldn't work.
I am using the action menu that was in the 3D demo. If the left mouse button is held down, the action menu appears. In the initial script that I had, I only implemented on "LeftClick" for both objects, on "tubes" for the syringe and on "filledSyringe" for the tubes. I think that what happens is that whichever item is clicked becomes the game selected item. on "tubes" and on "filledSyringe" never run.
The first solution was just to leave the empty tubes on the counter, never take them into inventory and click on them with the filled syringe. But that left me with similar problems elsewhere.
The best solution was to implement on "Take" for the empty tubes and filled syringe. For the filled syringe I have on "LeftClick" and on "tubes" as in my first posting below. For the tubes, I have on "LeftClick" and on "filledSyringe" as in my first posting below. I also have on "Take" for both objects, which is the same as the on "LeftClick" method. The one for the filled syringe is as follows:
Everything now runs correctly. I think the problem only occurs when the left click action menu is used, not a right click menu.
Thanks for your response. I was actually already combining two inventory items without any problem so I couldn't figure out what was going wrong. I posted the code that I had in the first posting.
Here is the situation. I have a dog, an empty syringe, and empty tubes in inventory. I click on the dog with the empty syringe which causes the empty syringe to be be deleted and a filled syringe to appear in inventory. (It never occurred to me to click the syringe with the dog. That would be a bit awkward.) Then I wanted to fill the tubes using the filled syringe. That is the part that wouldn't work.
I am using the action menu that was in the 3D demo. If the left mouse button is held down, the action menu appears. In the initial script that I had, I only implemented on "LeftClick" for both objects, on "tubes" for the syringe and on "filledSyringe" for the tubes. I think that what happens is that whichever item is clicked becomes the game selected item. on "tubes" and on "filledSyringe" never run.
The first solution was just to leave the empty tubes on the counter, never take them into inventory and click on them with the filled syringe. But that left me with similar problems elsewhere.
The best solution was to implement on "Take" for the empty tubes and filled syringe. For the filled syringe I have on "LeftClick" and on "tubes" as in my first posting below. For the tubes, I have on "LeftClick" and on "filledSyringe" as in my first posting below. I also have on "Take" for both objects, which is the same as the on "LeftClick" method. The one for the filled syringe is as follows:
Code: [Select]
on "Take"
{
Game.SelectedItem = "syringeFull";
}
Everything now runs correctly. I think the problem only occurs when the left click action menu is used, not a right click menu.