Frictional Games Forum (read-only)

Full Version: Hit a wall with crafting two items together
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I am crafting two items together... No problem...
But I need this to be done many times.
Because of the way the script calls the item based on it's name in the editor, this poses a problem.

Is there a work around?
Or any one have some ideas?

(04-06-2012, 12:32 AM)Pitfall Wrote: [ -> ]Or any one have some ideas?

Be more descriptive.
I don't know how to. I was planning on making it so players would have to use two common items to craft things like health kits.
Would using AddUseItemCallback in combination with StringContains--and perhaps local map variables--be an issue?
(04-06-2012, 01:09 AM)Your Computer Wrote: [ -> ]Would using AddUseItemCallback in combination with StringContains--and perhaps local map variables--be an issue?
Example please.
PHP Code:
void OnStart()
{
    
AddUseItemCallback("INTERNAL_NAME""NAME_OF_ITEM""NAME_OF_ENTITY""NAME_OF_CALLBACK"true);
    
// Repeat for every item.
}

void NAME_OF_CALLBACK(string &in itemstring &in entity)
{
    if (
StringContains(item"medbox"))
        
AddLocalVarInt("Medbox"1);
    else if (
StringContains(item"medicine"))
        
AddLocalVarInt("Medicine"1);

    if (
GetLocalVarInt("Medbox") > 0
        
&& GetLocalVarInt("Medicine") > 2)
    {
        
AddLocalVarInt("Medbox", -1);
        
AddLocalVarInt("Medicine", -3);
        
// Give medkit...
    
}


Still a bit of a problem. AddUseItemCallback(); per each item. Things like having many sanity potions (1 of the items used, the other being a container of blood) per map were the name would be potion_sanity_1, potion_sanity_2, etc.
(04-06-2012, 07:26 AM)Pitfall Wrote: [ -> ]Still a bit of a problem. AddUseItemCallback(); per each item. Things like having many sanity potions (1 of the items used, the other being a container of blood) per map were the name would be potion_sanity_1, potion_sanity_2, etc.

You should be able to make use of a global.hps or inventory.hps instead of the map script.
(04-06-2012, 07:47 AM)Your Computer Wrote: [ -> ]You should be able to make use of a global.hps or inventory.hps instead of the map script.
You are saying have a global script that contains:
Code:
AddUseItemCallback("Blahblah", "potion_sanity_1", "Blah", "RandomFunction");
AddUseItemCallback("Blahblah", "potion_sanity_2", "Blah", "RandomFunction");
AddUseItemCallback("Blahblah", "potion_sanity_3", "Blah", "RandomFunction");
...
(04-06-2012, 08:01 AM)Pitfall Wrote: [ -> ]You are saying have a global script that contains:

Yeah.
Pages: 1 2