help! how to use two different inventory items to trigger change in hotspot

Started by funnyboy044, Tue 21/03/2017 02:42:28

Previous topic - Next topic

funnyboy044

I'm making my very first game on AGS and I would like to use two inventory items on a flowerbed to trigger a change in the hotspot where the flowerbed grows flowers. I'm trying to use what I learned on the internet but when I try using the two items on the hotspot, the display below won't play. Keep in mind that the Display below isn't all of what I'm going to put there, it's just going to be there until the flowerbed_useinv action fully works.

Code: ags

function cFlowerbed_UseInv()
{
if ((player.ActiveInventory==iSeeds) &&     
      (player.ActiveInventory==iWATERingcan) ) 
      {
    Display ("Suddenly, three small, beautiful flowers rise from the soil!");
}
else if(player.ActiveInventory==iSeeds){
player.Walk(465, 465, eBlock);
Display("You throw all the seeds into the soil.");
player.LoseInventory(iSeeds);
}
else if(player.ActiveInventory==iWATERingcan){
player.Walk(465, 465, eBlock);
Display("You pour the water onto the soil.");
player.LoseInventory(iWATERingcan);
}
else{
Display("You don't feel like putting that into the soil.");
}
}


Also, I'm thinking about causing the flowers to grow by making the flowerbed a character and making each change in the flowerbed it's own separate view(there will be 3 changes/views)(cFlowerbed.changeview). I'll do that unless there is a way I can put all the flowerbed changes into one whole view and having the flowerbed change frames at scheduled times.  Is the changeview option recommended and is there a way to do the frame changing trick I mentioned?
,

dayowlron

The problem is you can only have 1 Active Inventory at a time. You need to set up a couple of variables to show when you have completed that particular task.
Give me a sec and I will write the script based on what you have there with proper indention also.

Code: ags

bool SeedsPlanted=false;
bool SoilWatered=false;
bool FlowersMessageDisplayed=false;

function cFlowerbed_UseInv()
{
    if(player.ActiveInventory==iSeeds){
        player.Walk(465, 465, eBlock);
        Display("You throw all the seeds into the soil.");
        player.LoseInventory(iSeeds);
        SeedsPlanted=true;
    }
    else if(player.ActiveInventory==iWATERingcan){
        player.Walk(465, 465, eBlock);
        Display("You pour the water onto the soil.");
        player.LoseInventory(iWATERingcan);
        SoilWatered = true;
    }
    else{
        Display("You don't feel like putting that into the soil.");
    }
    if (SeedsPlanted &&  SoilWatered && !FlowersMessageDisplayed ) 
    {
        Display ("Suddenly, three small, beautiful flowers rise from the soil!");
        FlowersMessageDisplayed=true;
    }
}



Also added the variable FlowersMessageDisplayed because after you see that message you don't want to see that message again if they use something else on the flower bed. Try that code out and see how it works.
Pro is the opposite of Con                       Kids of today are so much different
This fact can clearly be seen,                  Don't you know?
If progress means to move forward         Just ask them where they are from
Then what does congress mean?             And they tell you where you can go.  --Nipsey Russell

dayowlron

Doesn't look like you are getting any other replies so I will attempt to answer the other part of your question.
I wouldnt use a character for the flower bed but rather use an object. It can animate if you need it to but you can also just change the graphic at various times if "animation" is not needed. If each of the 3 changes/views is just a matter of changing the graphic then you can do that by just setting the Graphic property of the object, but if each time the flowerbed changes state and there is some animation then you can do that with an object as well. Unless the flowerbed is going to be walking around or talking to other characters then it is actually better as an object.
Pro is the opposite of Con                       Kids of today are so much different
This fact can clearly be seen,                  Don't you know?
If progress means to move forward         Just ask them where they are from
Then what does congress mean?             And they tell you where you can go.  --Nipsey Russell

Kumpel

Only downside of objects is that you can't rename them. So if he wants to change the Flowerbed into Flowerbed with seeds or flowerbed with flowers etc. he needs to add a new object for each name change. A character is far more flexible on that part.
Another one is the limitation of objects in a room. If this one is crowded with these, using a character here could be useful.

About character.ChangeView: I wouldnt recommend this because it is linked to a view and the loops are activated by the direction the character is looking to (or where he walks). This means you have to combine changeview with a character.FaceDirection to get different sprites of your flowerbed. It's much easier to use character.LockViewFrame for your purpose. Maybe some code in room_Load is needed to keep the flowerbed in its current state if the player returns to the room, but that should be easy.


SMF spam blocked by CleanTalk