Frictional Games Forum (read-only)

Full Version: Problem with combining items
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone,

I want to combine 2 items in my inventory and remove both of them in return for a new item.

I tried some code i found in the Maps/Main/inventory.HPS file, but I can't get it to work in my custom story. I can combine any two items I want, but I can only receive items that are combined in the main story (orb, hand drill, copper tube and needle).

Is there a way to receive other items like keys and oil?
(09-20-2010, 01:35 AM)Mofo Wrote: [ -> ]Hello everyone,

I want to combine 2 items in my inventory and remove both of them in return for a new item.

I tried some code i found in the Maps/Main/inventory.HPS file, but I can't get it to work in my custom story. I can combine any two items I want, but I can only receive items that are combined in the main story (orb, hand drill, copper tube and needle).

Is there a way to receive other items like keys and oil?

Well, did you actually add a callback?
(09-20-2010, 01:43 AM)MulleDK19 Wrote: [ -> ]Well, did you actually add a callback?

I did, here's the code inside my custom story hps:


void OnStart()
{
AddCombineCallback("hammerandkey", "key_laboratory_1", "stone_hammer_1", "CombineHammerAndKey", false);
}


void CombineHammerAndKey(string &in asItemA, string &in asItemB)
{
PlayGuiSound("15_make_hammer", 1.0f);

RemoveItem(asItemA); RemoveItem(asItemB);

GiveItem("straightened_key", "Puzzle", "straightened_key", "key_laboratory.tga", 0);
}
If I'm not confused, you need to add a inventory script file to your custom story and then add this code to it. Also add a AddDebugMessage("Combined items!", false); to your CombineHammerAndKey function to easier see if it works.
(09-20-2010, 08:01 AM)jens Wrote: [ -> ]If I'm not confused, you need to add a inventory script file to your custom story and then add this code to it. Also add a AddDebugMessage("Combined items!", false); to your CombineHammerAndKey function to easier see if it works.

Worked like a charm, thank you very much Big Grin
(09-20-2010, 08:01 AM)jens Wrote: [ -> ]If I'm not confused, you need to add a inventory script file to your custom story and then add this code to it. Also add a AddDebugMessage("Combined items!", false); to your CombineHammerAndKey function to easier see if it works.

Exactly what do you name the inventory file?
(02-03-2011, 12:44 AM)house Wrote: [ -> ]
(09-20-2010, 08:01 AM)jens Wrote: [ -> ]If I'm not confused, you need to add a inventory script file to your custom story and then add this code to it. Also add a AddDebugMessage("Combined items!", false); to your CombineHammerAndKey function to easier see if it works.

Exactly what do you name the inventory file?

custom_stories/*your_story_here*/maps/inventory.hps

If all else fails, I made you a custom story with a working custom combination.
I'll try that. Thanks!