Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I check what my item name is in inventory?
Putmalk Offline
Senior Member

Posts: 290
Threads: 13
Joined: Apr 2012
Reputation: 15
#3
RE: How can I check what my item name is in inventory?

Through script.

    RemoveItem(asItem);
    GiveItem("chemical_container_1", "chemical_container.ent", "ChemicalContainer", "chemical_container.tga", 0);

I only ask because that "chemical_container_1" that's generated under specific circumstances isn't working on the callbacks that have "chemical_container_1".

Let me explain how the bug occurs:

You place 4 items on a machine, place an empty container on the machine. (this container can be picked up and retrieved, this works fine).

Activate the machine, the container becomes Ineffective acid.

You can dump this acid in a drain to become an empty container again (that little snippet of code).

When you place the container on the machine again and pick it up, the item you receive isn't working on the intended objects.

Should I post the entire code of how it works? It is lengthy.

Here's the monstrosity of code.

I found where the issue occurs: When you drain the chemicals and get a new chemical_container_1, when you place the container on the table it doesn't give it the correct name. I'm trying to find out why...

//drainage

void InteractDrain(string &in asEntity)
{
    SetMessage("Interact", "11_DrainChemicals", 0);
}

void SpillChemicals(string &in asItem, string &in asEntity)
{
    if(asItem == "chemical_container_good")
    {
        SetMessage("Interact", "11_NoDrainGood", 0);
        return;
    }

    SetMessage("Interact", "11_ChemicalsDrained", 0);

    RemoveItem(asItem);
    GiveItem("chemical_container_1", "chemical_container.ent", "ChemicalContainer", "chemical_container.tga", 0);
}

//call when player interacts with empty container
void PickContainer(string &in asEntity, string &in type)
{
    if(asEntity == "chemical_container_2")
    {
        SetEntityActive(asEntity, false);
        SetEntityActive("AreaPlaceContainer", true);
        
        //replace with chemical_container_1 so we can place again!
        RemoveItem(asEntity);
        GiveItem("chemical_container_1", "chemical_container.ent", "ChemicalContainer", "chemical_container.tga", 0);
        
        SetLocalVarInt("EmptyPotOnMachine", 0);
        
        AddDebugMessage("Pot on Machine: "+GetLocalVarInt("EmptyPotOnMachine"), false);
        
        PlayGuiSound("pick_generic.snt", 1);
        SetMessage("Interact", "11_PickContainer", 0);
    }
    if(asEntity == "chemical_container_half_a_2")
    {
        SetEntityActive(asEntity, false);
        SetEntityActive("AreaPlaceContainer", true);
        
        //replace with chemical_container_1 so we can place again!
        RemoveItem(asEntity);
        GiveItem("chemical_container_half_a", "Inventory", "ChemA", "chemical_container_half.tga", 0);
        
        SetLocalVarInt("EmptyPotOnMachine", 0);
        SetLocalVarInt("A", 0);
        
        AddDebugMessage("Pot on Machine: "+GetLocalVarInt("EmptyPotOnMachine"), false);
        
        PlayGuiSound("pick_generic.snt", 1);
        SetMessage("Interact", "11_PickA", 0);
    }
    if(asEntity == "chemical_container_half_b_2")
    {
        SetEntityActive(asEntity, false);
        SetEntityActive("AreaPlaceContainer", true);
        
        //replace with chemical_container_1 so we can place again!
        RemoveItem(asEntity);
        GiveItem("chemical_container_half_b", "Inventory", "ChemB", "chemical_container_half.tga", 0);
        
        SetLocalVarInt("EmptyPotOnMachine", 0);
        SetLocalVarInt("B", 0);
        
        AddDebugMessage("Pot on Machine: "+GetLocalVarInt("EmptyPotOnMachine"), false);
        
        PlayGuiSound("pick_generic.snt", 1);
        SetMessage("Interact", "11_PickB", 0);
    }
    if(asEntity == "chemical_container_half_c_2")
    {
        SetEntityActive(asEntity, false);
        SetEntityActive("AreaPlaceContainer", true);
        
        //replace with chemical_container_1 so we can place again!
        RemoveItem(asEntity);
        GiveItem("chemical_container_half_c", "Inventory", "ChemC", "chemical_container_half.tga", 0);
        
        SetLocalVarInt("EmptyPotOnMachine", 0);
        SetLocalVarInt("C", 0);
        
        AddDebugMessage("Pot on Machine: "+GetLocalVarInt("EmptyPotOnMachine"), false);
        
        PlayGuiSound("pick_generic.snt", 1);
        SetMessage("Interact", "11_PickC", 0);
    }
    if(asEntity == "chemical_container_ab_2")
    {
        SetEntityActive(asEntity, false);
        SetEntityActive("AreaPlaceContainer", true);
        
        //replace with chemical_container_1 so we can place again!
        RemoveItem(asEntity);
        GiveItem("chemical_container_ab", "Inventory", "ChemAB", "chemical_container_full.tga", 0);
        
        SetLocalVarInt("EmptyPotOnMachine", 0);
        SetLocalVarInt("AB", 0);
        
        AddDebugMessage("Pot on Machine: "+GetLocalVarInt("EmptyPotOnMachine"), false);
        
        PlayGuiSound("pick_generic.snt", 1);
        SetMessage("Interact", "11_PickAB", 0);
    }
    if(asEntity == "chemical_container_ac_2")
    {
        SetEntityActive(asEntity, false);
        SetEntityActive("AreaPlaceContainer", true);
        
        //replace with chemical_container_1 so we can place again!
        RemoveItem(asEntity);
        GiveItem("chemical_container_ac", "Inventory", "ChemAC", "chemical_container_full.tga", 0);
        
        SetLocalVarInt("EmptyPotOnMachine", 0);
        SetLocalVarInt("AC", 0);
        
        AddDebugMessage("Pot on Machine: "+GetLocalVarInt("EmptyPotOnMachine"), false);
        
        PlayGuiSound("pick_generic.snt", 1);
        SetMessage("Interact", "11_PickAC", 0);
    }
    if(asEntity == "chemical_container_bc_2")
    {
        SetEntityActive(asEntity, false);
        SetEntityActive("AreaPlaceContainer", true);
        
        //replace with chemical_container_1 so we can place again!
        RemoveItem(asEntity);
        GiveItem("chemical_container_bc", "Inventory", "ChemBC", "chemical_container_full.tga", 0);
        
        SetLocalVarInt("EmptyPotOnMachine", 0);
        SetLocalVarInt("BC", 1);
        
        AddDebugMessage("Pot on Machine: "+GetLocalVarInt("EmptyPotOnMachine"), false);
        
        PlayGuiSound("pick_generic.snt", 1);
        SetMessage("Interact", "11_PickBC", 0);
    }
    if(asEntity == "chemical_container_good")
    {
        ResetMachine();
    
        SetEntityActive(asEntity, false);
        SetEntityActive("AreaPlaceContainer", true);
        
        RemoveItem(asEntity);
        GiveItem("chemical_container_good", "Inventory", "Chems_Good", "chemical_container_full.tga", 0);
        
        PlayGuiSound("pick_generic.snt", 1);
        SetMessage("Interact", "11_PickGood", 0);
    }
    if(asEntity == "chemical_container_bad")
    {
        ResetMachine();
    
        SetEntityActive(asEntity, false);
        SetEntityActive("AreaPlaceContainer", true);
        
        RemoveItem(asEntity);
        GiveItem("chemical_container_bad", "Inventory", "Chems_Bad", "chemical_container_half.tga", 0);
        
        PlayGuiSound("pick_generic.snt", 1);
        SetMessage("Interact", "11_PickBad", 0);
    }
}

void PlaceJarOnArea(string &in asItem, string &in asEntity)
{
    //NOTE: Empty Pot On Machine variable is strictly to determine if using the chemicals does anything!
    //Place Jar on the area for pick up at any time
    //Make sure we get the right items back
    
    //do nothing
    if(asItem == "glass_container_1")
    {
        SetMessage("Interact", "11_BadContainer", 0);
        return;
    }
    
    PlaySoundAtEntity("placejar", "puzzle_place_jar.snt", asEntity, 0, true);
    
    //Empty
    if(asItem == "chemical_container_1")
    {
        RemoveItem(asItem);
        
        SetLocalVarInt("EmptyPotOnMachine", 1);
        
        SetEntityActive("AreaPlaceContainer", false);
        
        AddDebugMessage("Pot on Machine: "+GetLocalVarInt("EmptyPotOnMachine"), false);
        //when we activate machine, make sure to change this to the static pot!
        CreateEntityAtArea("chemical_container_2", "chemical_container.ent", "AreaChemicalJar", true);
        SetEntityCallbackFunc("chemical_container_2", "PickContainer");
    }
    //Chemical Pot A
    if(asItem == "chemical_container_half_a")
    {
        RemoveItem(asItem);
        SetLocalVarInt("EmptyPotOnMachine", 1);
        SetLocalVarInt("A", 1);
        
        SetEntityActive("AreaPlaceContainer", false);
        
        AddDebugMessage("Pot on Machine: "+GetLocalVarInt("EmptyPotOnMachine"), false);
        //when we activate machine, make sure to change this to the static pot!
        CreateEntityAtArea("chemical_container_half_a_2", "chemical_container_half.ent", "AreaChemicalJar", true);
        SetEntityCallbackFunc("chemical_container_half_a_2", "PickContainer");
    }
    //Chemical Pot B
    if(asItem == "chemical_container_half_b")
    {
        RemoveItem(asItem);
        SetLocalVarInt("EmptyPotOnMachine", 1);
        SetLocalVarInt("B", 1);
        
        SetEntityActive("AreaPlaceContainer", false);
        
        AddDebugMessage("Pot on Machine: "+GetLocalVarInt("EmptyPotOnMachine"), false);
        //when we activate machine, make sure to change this to the static pot!
        CreateEntityAtArea("chemical_container_half_b_2", "chemical_container_half.ent", "AreaChemicalJar", true);
        SetEntityCallbackFunc("chemical_container_half_b_2", "PickContainer");
    }
    //Chemical Pot C
    if(asItem == "chemical_container_half_c")
    {
        RemoveItem(asItem);
        SetLocalVarInt("EmptyPotOnMachine", 1);
        SetLocalVarInt("C", 1);
        
        SetEntityActive("AreaPlaceContainer", false);
        
        AddDebugMessage("Pot on Machine: "+GetLocalVarInt("EmptyPotOnMachine"), false);
        //when we activate machine, make sure to change this to the static pot!
        CreateEntityAtArea("chemical_container_half_c_2", "chemical_container_half.ent", "AreaChemicalJar", true);
        SetEntityCallbackFunc("chemical_container_half_c_2", "PickContainer");
    }
    //Chemical AB
    if(asItem == "chemical_container_ab")
    {
        RemoveItem(asItem);
        SetLocalVarInt("EmptyPotOnMachine", 1);
        SetLocalVarInt("AB", 1);
        
        SetEntityActive("AreaPlaceContainer", false);
        
        AddDebugMessage("Pot on Machine: "+GetLocalVarInt("EmptyPotOnMachine"), false);
        //when we activate machine, make sure to change this to the static pot!
        CreateEntityAtArea("chemical_container_ab_2", "chemical_container_full.ent", "AreaChemicalJar", true);
        SetEntityCallbackFunc("chemical_container_ab_2", "PickContainer");
    }
    //Chemical AC
    if(asItem == "chemical_container_ac")
    {
        RemoveItem(asItem);
        SetLocalVarInt("EmptyPotOnMachine", 1);
        SetLocalVarInt("AC", 1);
        
        SetEntityActive("AreaPlaceContainer", false);
        
        AddDebugMessage("Pot on Machine: "+GetLocalVarInt("EmptyPotOnMachine"), false);
        //when we activate machine, make sure to change this to the static pot!
        CreateEntityAtArea("chemical_container_ac_2", "chemical_container_full.ent", "AreaChemicalJar", true);
        SetEntityCallbackFunc("chemical_container_ac_2", "PickContainer");
    }
    //Chemical BC
    if(asItem == "chemical_container_bc")
    {
        RemoveItem(asItem);
        SetLocalVarInt("EmptyPotOnMachine", 1);
        
        SetEntityActive("AreaPlaceContainer", false);
        
        AddDebugMessage("Pot on Machine: "+GetLocalVarInt("EmptyPotOnMachine"), false);
        //when we activate machine, make sure to change this to the static pot!
        CreateEntityAtArea("chemical_container_bc_2", "chemical_container_full.ent", "AreaChemicalJar", true);
        SetEntityCallbackFunc("chemical_container_bc_2", "PickContainer");
    }
}

void SpinWheel(string &in asEntity, int alState)
{
    //turned the machine on
    if(alState == 1)
    {
        //which machine is it?
        if(asEntity == "acid_machine_valve_x_1")
        {
            if(GetLocalVarInt("Eon") == 1)
            {
                SetWheelStuckState(asEntity, 1, true);
                AddLocalVarInt("ElementsOn", 1);
                
                CreateParticleSystemAtEntity("bubbles_1", "ps_acid_machine_bubble_large.ps", "AreaBubbles_1", true);
                PlaySoundAtEntity("boil_1", "puzzle_boil.snt", "AreaBubbles_1", 0, true);
                
                AddDebugMessage("Elements placed: "+GetLocalVarInt("ElementsOn"), false);
            }
            else
            {
                SetMessage("Interact", "11_NoChem", 0);
                return;
            }
        }
        if(asEntity == "acid_machine_valve_x_2")
        {
            if(GetLocalVarInt("Hon") == 1)
            {
                SetWheelStuckState(asEntity, 1, true);
                AddLocalVarInt("ElementsOn", 1);
                
                CreateParticleSystemAtEntity("bubbles_2", "ps_acid_machine_bubble_large.ps", "AreaBubbles_2", true);
                PlaySoundAtEntity("boil_1", "puzzle_boil.snt", "AreaBubbles_2", 0, true);
                
                AddDebugMessage("Elements placed: "+GetLocalVarInt("ElementsOn"), false);
            }
            else
            {
                SetMessage("Interact", "11_NoChem", 0);
                return;
            }
        }
        if(asEntity == "acid_machine_valve_x_3")
        {
            if(GetLocalVarInt("Von") == 1)
            {
                SetWheelStuckState(asEntity, 1, true);
                AddLocalVarInt("ElementsOn", 1);
                
                CreateParticleSystemAtEntity("bubbles_3", "ps_acid_machine_bubble_large.ps", "AreaBubbles_3", true);
                PlaySoundAtEntity("boil_1", "puzzle_boil.snt", "AreaBubbles_3", 0, true);
                
                AddDebugMessage("Elements placed: "+GetLocalVarInt("ElementsOn"), false);
            }
            else
            {
                SetMessage("Interact", "11_NoChem", 0);
                return;
            }
        }
        if(asEntity == "acid_machine_valve_x_4")
        {
            if(GetLocalVarInt("Yon") == 1)
            {
                SetWheelStuckState(asEntity, 1, true);
                AddLocalVarInt("ElementsOn", 1);
                
                CreateParticleSystemAtEntity("bubbles_4", "ps_acid_machine_bubble_large.ps", "AreaBubbles_4", true);
                PlaySoundAtEntity("boil_1", "puzzle_boil.snt", "AreaBubbles_4", 0, true);
                
                AddDebugMessage("Elements placed: "+GetLocalVarInt("ElementsOn"), false);
            }
            else
            {
                SetMessage("Interact", "11_NoChem", 0);
                return;
            }
        }
    }
}

void StartAcidMachine(string &in asEntity, int alState)
{
    //wheel is on
    if(alState == 1)
    {
        //check acids placed yes?
        if(GetLocalVarInt("ElementsOn") == 4)
        {
            //jar is placed
            if(GetLocalVarInt("EmptyPotOnMachine") == 1)
            {
                CreateParticleSystemAtEntity("finalflow", "ps_acid_machine_bubble_end.ps", "AreaPSDumpChems", false);
                AddTimer("changeitem", 1, "TimerChangeItem");
            }
            else
            {
                SetMessage("Interact", "11_NoJar", 0);
            }
        }
        else
        {
            SetMessage("Interact", "11_NotEnoughChems", 0);
            return;
        }
    }
}

void TimerChangeItem(string &in asTimer)
{
    //single element
    if((GetLocalVarInt("AC") == 1))
    {
        SetEntityActive("chemical_container_ac_2", false);
        CreateEntityAtArea("chemical_container_good", "chemical_container_full.ent", "AreaChemicalJar", true);
        SetEntityCallbackFunc("chemical_container_good", "PickContainer");
    }
    else
    {
        SetEntityActive("chemical_container_2", false);
        SetEntityActive("chemical_container_half_a_2", false);
        SetEntityActive("chemical_container_half_b_2", false);
        SetEntityActive("chemical_container_half_c_2", false);
        SetEntityActive("chemical_container_ab_2", false);
        SetEntityActive("chemical_container_bc_2", false);
        CreateEntityAtArea("chemical_container_bad", "chemical_container_half.ent", "AreaChemicalJar", true);
        SetEntityCallbackFunc("chemical_container_bad", "PickContainer");
    }
}


void PlaceElementOnMachine(string &in asItem, string &in asEntity)
{
    PlaySoundAtEntity("add", "puzzle_add_chemical.snt", asEntity, 0, true);
    
    if(asItem == "Ethyrium")
    {
        RemoveItem(asItem);
        SetEntityActive("acid_machine_bottle_empty01_3", false);
        SetEntityActive("acid_machine_bottle01_1", true);
        
        SetLocalVarInt("Eon", 1);
    }
    if(asItem == "Haprium")
    {
        RemoveItem(asItem);
        SetEntityActive("acid_machine_bottle_empty01_2", false);
        SetEntityActive("acid_machine_bottle02_1", true);
        SetLocalVarInt("Hon", 1);
        //AddLocalVarInt("ElementsOn", 1);
                
    }
    if(asItem == "Valium")
    {
        RemoveItem(asItem);
        SetEntityActive("acid_machine_bottle_empty01_1", false);
        SetEntityActive("acid_machine_bottle03_1", true);
        SetLocalVarInt("Von", 1);
        //AddLocalVarInt("ElementsOn", 1);
    }
    if(asItem == "Yansine")
    {
        RemoveItem(asItem);
        SetEntityActive("acid_machine_bottle_empty04_1", false);
        SetEntityActive("acid_machine_bottle04_1", true);
        SetLocalVarInt("Yon", 1);
        //AddLocalVarInt("ElementsOn", 1);
    }
}

void ResetMachine()
{

    SetLocalVarInt("EmptyPotOnMachine", 0);
    SetLocalVarInt("A", 0);
    SetLocalVarInt("B", 0);
    SetLocalVarInt("C", 0);
    SetLocalVarInt("AB", 0);
    SetLocalVarInt("AC", 0);
    SetLocalVarInt("BC", 0);    
}

(This post was last modified: 05-25-2012, 06:44 PM by Putmalk.)
05-25-2012, 06:37 PM
Find


Messages In This Thread
RE: How can I check what my item name is in inventory? - by Putmalk - 05-25-2012, 06:37 PM



Users browsing this thread: 1 Guest(s)