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
#1
How can I check what my item name is in inventory?

Is there a way to check what the item name is in my inventory? Because I need to know this as my "complicated" script is producing an item that's not working on objects like they're supposed to be when certain conditions are met.

Thank you. Smile

05-25-2012, 06:30 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#2
RE: How can I check what my item name is in inventory?

How is the item given to the player?

Tutorials: From Noob to Pro
05-25-2012, 06:32 PM
Website Find
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
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#4
RE: How can I check what my item name is in inventory?

(05-25-2012, 06:37 PM)Putmalk Wrote: Should I post the entire code of how it works?

Yeah.

I am also interested in OnEnter and OnStart.

Tutorials: From Noob to Pro
(This post was last modified: 05-25-2012, 06:52 PM by Your Computer.)
05-25-2012, 06:45 PM
Website Find
Putmalk Offline
Senior Member

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

Okay, I cheated. Smile I kind of guessed that when it was giving me the item, it was adding +1 to the number. So it wasn't chemical_container_1 anymore, it was chemical_container_2, which doesn't work with the code.

To, ahem...*fix* this, (and by fix I did something terrible and brute forced it....), I adding a for-loop for 500 times (no way the player should have to drain their pot 500 times to solve the puzzle. And it works, I guess. I'm going to keep trying.

I'm going to post the entire code with the for loops added.

//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)
{
    for(int i=0;i<=500;i++)
    {    
        if(asEntity == "chemical_container_"+i)
        {
            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
    for(int i=0;i<=500;i++)
    {    
        if(asItem == "chemical_container_"+i)
        {
            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);    
}

void OnStart()
{
    //Use Chemicals to Place On Machine
    AddUseItemCallback("glassonmachine", "glass_container_1", "AreaPlaceContainer", "PlaceJarOnArea", false);
    AddUseItemCallback("glassonmachine", "glass_container_1", "acid_machine_1", "PlaceJarOnArea", false);
    for(int i=0;i<500;i++)
        AddUseItemCallback("emptyonmachine", "chemical_container_"+i, "AreaPlaceContainer", "PlaceJarOnArea", false);
    AddUseItemCallback("halfonmachine", "chemical_container_half_a", "AreaPlaceContainer", "PlaceJarOnArea", false);
    AddUseItemCallback("halfonmachine", "chemical_container_half_b", "AreaPlaceContainer", "PlaceJarOnArea", false);
    AddUseItemCallback("halfonmachine", "chemical_container_half_c", "AreaPlaceContainer", "PlaceJarOnArea", false);
    AddUseItemCallback("fullonmachine", "chemical_container_ab", "AreaPlaceContainer", "PlaceJarOnArea", false);
    AddUseItemCallback("fullonmachine", "chemical_container_ac", "AreaPlaceContainer", "PlaceJarOnArea", false);
    AddUseItemCallback("fullonmachine", "chemical_container_bc", "AreaPlaceContainer", "PlaceJarOnArea", false);
    
    for(int i=0;i<500;i++)
        AddUseItemCallback("emptyonmachine", "chemical_container_"+i, "acid_machine_1", "PlaceJarOnArea", false);
    AddUseItemCallback("halfonmachine", "chemical_container_half_a", "acid_machine_1", "PlaceJarOnArea", false);
    AddUseItemCallback("halfonmachine", "chemical_container_half_b", "acid_machine_1", "PlaceJarOnArea", false);
    AddUseItemCallback("halfonmachine", "chemical_container_half_c", "acid_machine_1", "PlaceJarOnArea", false);
    AddUseItemCallback("fullonmachine", "chemical_container_ab", "acid_machine_1", "PlaceJarOnArea", false);
    AddUseItemCallback("fullonmachine", "chemical_container_ac", "acid_machine_1", "PlaceJarOnArea", false);
    AddUseItemCallback("fullonmachine", "chemical_container_bc", "acid_machine_1", "PlaceJarOnArea", false);
    
    AddUseItemCallback("eonmachine", "Ethyrium", "acid_machine_1", "PlaceElementOnMachine", false);
    AddUseItemCallback("yonmachine", "Yansine", "acid_machine_1", "PlaceElementOnMachine", false);
    AddUseItemCallback("honmachine", "Haprium", "acid_machine_1", "PlaceElementOnMachine", false);
    AddUseItemCallback("vonmachine", "Valium", "acid_machine_1", "PlaceElementOnMachine", false);
    AddUseItemCallback("eonarea", "Ethyrium", "AreaPlaceElement", "PlaceElementOnMachine", false);
    AddUseItemCallback("yonarea", "Yansine", "AreaPlaceElement", "PlaceElementOnMachine", false);
    AddUseItemCallback("honarea", "Haprium", "AreaPlaceElement", "PlaceElementOnMachine", false);
    AddUseItemCallback("vonarea", "Valium", "AreaPlaceElement", "PlaceElementOnMachine", false);
    
    //to drain the chemicals and start new
    AddUseItemCallback("spillab", "chemical_container_ab", "AreaDrainChemicals", "SpillChemicals", false);
    AddUseItemCallback("spillac", "chemical_container_ac", "AreaDrainChemicals", "SpillChemicals", false);
    AddUseItemCallback("spillbc", "chemical_container_bc", "AreaDrainChemicals", "SpillChemicals", false);
    AddUseItemCallback("spilla", "chemical_container_half_a", "AreaDrainChemicals", "SpillChemicals", false);
    AddUseItemCallback("spillb", "chemical_container_half_b", "AreaDrainChemicals", "SpillChemicals", false);
    AddUseItemCallback("spillc", "chemical_container_half_c", "AreaDrainChemicals", "SpillChemicals", false);
    AddUseItemCallback("spillc", "chemical_container_good", "AreaDrainChemicals", "SpillChemicals", false);
    AddUseItemCallback("spillc", "chemical_container_bad", "AreaDrainChemicals", "SpillChemicals", false);

    if(ScriptDebugOn() == true)
    {
        GiveItemFromFile("lantern", "lantern.ent");
        //Kitchen Chemical Mixes
        /*
        GiveItemFromFile("", "");
        */
        GiveItemFromFile("glass_container_1", "glass_container.ent");
        GiveItemFromFile("chemical_container_1", "chemical_container.ent");
        GiveItem("chemical_container_half_a", "Inventory", "ChemA", "chemical_container_half.tga", 0);
        GiveItem("chemical_container_half_b", "Inventory", "ChemB", "chemical_container_half.tga", 0);
        GiveItem("chemical_container_half_c", "Inventory", "ChemC", "chemical_container_half.tga", 0);
        GiveItem("chemical_container_ab", "Inventory", "ChemAB", "chemical_container_full.tga", 0);
        GiveItem("chemical_container_ac", "Inventory", "ChemAC", "chemical_container_full.tga", 0);
        GiveItem("chemical_container_bc", "Inventory", "ChemBC", "chemical_container_full.tga", 0);
        
        for(int i=0;i<10;i++)
            GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");
    }
}

void OnEnter()
{
    PlayMusic("18_amb", true, 1, 5, 0, true);
}

void OnLeave()
{

}

So I'm going to see if this works. It seemed to have worked when I tried it out, I've expanded it to cover everywhere I needed.

My head hurts. That one bug is making me seriously consider redoing this whole puzzle into something so much simplier. Because what is happening now is unacceptable and my head really hurts. Sad

(This post was last modified: 05-25-2012, 07:05 PM by Putmalk.)
05-25-2012, 06:58 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#6
RE: How can I check what my item name is in inventory?

It is safe to use the same names for the items. The game should make use of the latest item given to the player. No need to add hundreds of AddUseItemCallbacks, just one for each item.

Tutorials: From Noob to Pro
(This post was last modified: 05-25-2012, 07:32 PM by Your Computer.)
05-25-2012, 07:31 PM
Website Find
Putmalk Offline
Senior Member

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

It's okay.

I decided to say screw it. Made a new script, much simplier, and should work. Thanks anyway. Smile Sometimes it's best to just start over.

05-25-2012, 10:10 PM
Find




Users browsing this thread: 1 Guest(s)