How to check if part does not have item?

Making an event to check if party has item is easy to do, but what about the opposite
The scenario is this
Player enters maze dungeon, at the end of the maze is a key in the chest, that is the main goal but there is a side goal you can choose to do or not
There is an area in the maze that has a body with an amulet, i go and pick up the amulet and exit the maze and give it to the caretaker, he thanx me gives me reward. Near the end of the game i have to go back to the caretaker, he remembers me and thanks me for the amulet. Here is the alternative, while in the maze if i do not get the amulet and exit the maze then progress through the game until i have to go back to the caretaker, since i did not pick up the amulet i want him to say a different dialogue

So if the only option is to have an event when exiting the maze the first time, if i dont have amulet in inventory as i transfer maps, is there a script or something i can use to make the event check if i dont have item in inventory instead of check to see if i have item
1. Check if the party has the amulet via eventing as normal
2. Create an else-branch
3. Do whatever needs to be done if they don't have the amulet in the else branch
you can just have a switch tied to delivering the amulet.
when come back to them later on -if switch is on: "thank you ..." >else "who were you again..."
As an alternative to eomerolsson's suggestion, you can use

!$gameParty.hasItem($dataItems[id of amulet])

as a script condition if you absolutely need to verify that the party doesn't have it.
i actually found a script that lets me do what i want thanks everyone the script is


$gameParty.items().filter(item => item.itypeId==36).length==0 just change the number 36 to whatever item number is in your item database
Well, that's a long way of going about it, when you could just use the Else condition in the conditional branch, or turn on a switch if they have the item when exiting, which means if the switch is OFF, they don't have the item.
i actually found a script that lets me do what i want thanks everyone the script is


$gameParty.items().filter(item => item.itypeId==36).length==0 just change the number 36 to whatever item number is in your item database
There is literally no reason you would ever need to resort to a piece of code this convoluted. Game_Party's hasItem function uses numItems, which checks the value of the item container directly rather than using an expensive filter call.

I'm not sure where you found that, but it also won't work the way you're intending; itypeId is for the item type, not the ID of the item itself.
it actually does work though
it actually does work though
Have you tried it when you *do* have item 36? It only works because the condition is returning false in every case and that's currently what you want, but once you have the item in question it'll still be doing the same thing as before (unless you have 36 item types in your database and the item in question happens to be item type 36, which isn't actually possible because the only valid values for itypeid are 1 (regular item), 2 (key item), 3 (hidden item A) and 4 (hidden item B ))
Here is the scenario and different outcomes I go into the maze, I find an amulet and note next to dead bodies telling me to take it to the caretaker outside of the maze. i exit the maze and give the amulet to him, he thanx me for returning it to him and I told him about the bodies. near the end of the game i return to the area where the caretaker is, and this time he is in a different location standing next to a grave, while i was gone he buried the bodies, he thanks me and moves on

I also want to have an option not to find the amulet, so when i return to the place again, the caretaker has not moved and just remains where he was from the start and there are no graves. Another option is i can choose not to enter the maze at all and when i return to that caretaker place again he remains there like before

So i cant get these outcomes to work

outcome 1, if gave amulet, he moves to a location to bury the people when i return there later
outcome 2, i did not find amulet and he remains in the same location but different dialogue
outcome 3, i did not enter maze at all and i want this outcome to be outcome 2 since its like i didn't find the amulet in the first place
...okay, but what does your event look like?
this trigger is when i exit the maze if amulet is not in inventory
1640064139236.png


I have a trigger near the end of the game, if give note is off then the did not find body will trigger, its the same as if i exit the maze without finding the amulet, there is a trigger when i exit the maze, it is did not find body in a conditional branch is if i don't have amulet item in my inventory
1640063954705.png


3. this is where the caretaker would be when I return to the area, if I gave amulet and if i give him the note or don't give him the note he will appear in the cemetery, if I don't return amulet or don't find it, he will be in the same place he is now in the garden and he wont be in the cemetery
1640063802141.png


2. this is the maze, i find the amulet, or I don't, and return it to the caretaker or I dont

1640063717991.png



1.Ok, this is the first time entering garden, caretaker is there and maze is up north, the baracades will show up after returning to this place a second time further through the game
1640063717991.png

1640063642200.png
Okay...the screenshots are helpful, but overboard. The whole map has nothing to do with your events, only the first two pictures are necessary to see if an event works or not.

Your first event is not doing what you think it is - you're looking for the party to have something of item type 36 in their inventory, and the chances are overwhelming that you don't have 36 item types in your game. Even if you do, it wouldn't pinpoint it to your amulet.

I suspect you want to be looking for item.id==36. Or just use the event commands, Conditional Branch -> Tab 4 -> Item (I have no idea why you're using a script call for this at all).
I have a trigger near the end of the game, if give note is off then the did not find body will trigger, its the same as if i exit the maze without finding the amulet, there is a trigger when i exit the maze, it is did not find body in a conditional branch is if i don't have amulet item in my inventory
I can't understand what you're saying here. Is something not doing what you expect in this event?
The scrip is meant to see if item number 36 which is the amulet is in my inventory or not, and its set to 0 at the end of the script so if I do not pick up the amulet and exit the maze, then the did not find body control switch activates. Since there is no other way to check if you don't have item in inventory to trigger a conditional branch

the end of the game trigger is if i did not enter the maze at all cause i cant trigger did not find body unless i exit through the maze, so i needed another way to activate the trigger

if did not find body is triggered then when i return, the caretaker remains where he is, though with different dialogue, but if i give amulet and note to caretaker then when i return, he will be at the cemetery, burying the bodies

If party has amulet

1640068643022.png


If you give caretaker note or do not give note with amulet
1640068677418.png



I think it could be the script that is causing it to not work, what else can I do to trigger event if I do not have item in inventory?
your other thread about this same issue was never closed. why are you making a new thread for the same discussion?

you were also already told in the other thread about how the script your using is flawed.
'item type' and 'item ID' are 2 very different things. there is only 4 item types in the engine and checking for a type is not the same thing as looking for a specific item.

instead of using script to check if you dont have the item just use 'conditional branch: (page4) item'
its literally what that option in the base engine was designed for.
why are you using a conditional within the event to check for the item, when the page has an item condition?

use the item as a condition the same way you'd use a switch!
This is not working, and you were told in your other thread that it would not work and why it would not work.


Moderator note: I have merged this with your original thread. Please do not create multiple topics for the same thing


You are just complicating it way too much. Don't even bother checking when you leave the cave. Check when you talk to the NPC if you have the item or not, and turn on a switch if you have it and give it to him. Forget script calls and player touch events.
@gstv87 i half wonder this as well. only reason i can think of that would need a check + switch is might be able to sell/use or somehow get rid of the amulet (includes giving it to the NPC so no longer in party possession) between leaving/talking to the NPC and returning in later gameplay.
(however if this is a permanent key item, then i agree that the conditional check turning on a switch for future reference makes no sense, since the graves and NPC can just use item + story progress variable page conditions.

edit:
i see OP done some edits since my post with screenshot example.
so went back to take better look at his screens and now i just have more questions.
why is "gave note" and "did not give note" 2 separate switches?
it looks like the body and note are side by side, how could you give the note and not find the body?
is this supposed to be some kinda "lie with good intention" thing like "oh here's this note but no corpse so maybe she made it out and is alive somewhere" (horrible execution if it is)
why would you need a "did not find body" switch to get turned off? only need a switch for the opposite of this. (if found body switch is on "you found it" if its not on you dont need an off)

@jedite1000 you are definitely overcomplicating by adding to many steps and checks.
the end result should only be "turned in the quest?", "good ending or bad ending?", "did he finish digging graves?"
(i still dont know where the amulet is acquired? is that scroll beside the bodies not the note and body in question? how can you find 1 or 2 of these things and not the 3rd?

can you turn in the quest having found the amulet but no note or body? can you find the note but no amulet or body? can you find body but no amulet or note? how many of these even need to be separate checks and/or switches (this is 9 possible outcomes when it should only have a "good ending bad ending" branch)
Moderator note: Closed at OP's request

Original thread: https://forums.rpgmakerweb.com/threads/how-to-check-if-part-does-not-have-item.142938/