Event conditions: 10 units of an item?

Hey guys, completely new here, so I'll probably be asking a lot of really basic questions.

I want to make a simple quest:
- NPC tells you to collect 10 apples
- NPC moves when you get away
- you collect 10 apples
- NPC gives you money

I'm good with points 1 and 3. Having problems with 2 and 4.

For 2: I know how to move the npc down a custom route. What I don't know is how to make it move down that route when the trigger is on the ground somewhere else.

for 4: I am using the Conditions -> Item and it doesn't seem to care how many apples my hero has in inventory. How can I make the "npc gives you money" event check for 10+ units of the apple item instead of just checking whether or not an apple item is present in the inventory?
control variable (game data option) to get the number of the item in inventory, then conditional branch to check if the variable is 10 or higher

If you follow the link to the "starting point" in my signature, you'll get to several tutorials that show you how eventing and variables work.
Thanks Andar, I'll check out the variable control, wherever it is 🙂

Also, figured out the 2nd step of my quest myself - placed an event on the ground that just sets a "move" switch to on and then edited the NPC-related event to react to the switch. Is this the correct way to do it or just a hack I invented just now?
there are dozens of ways to handle event movements - the one you used is not considered the best way because you'll use up too many switches and place too many events if you do it that way everywhere.

But we can't tell you which of the other methods you should use without seeing the event code itself. I think it might be better to simply switch the NPC to a page set on player touch and containing a moveroute to move away when the player touches that event. But that is only one of three or four alternatives, other ways might be even better.
Okay, I got it to the point where it is mostly working but still has some bugs that get me confused, but resolving those will definitely let me understand how it all works.

The map looks like this:
http://picpaste.com/pics/01-mneCwq6l.1490545686.png
Players spawns at the bottom, obviously, the Farmer girl gives us a quest to collect 10 corn. The events on plants each give 1 corn, they work fine, nothing to see there.

The event between the fence and the plant is a trigger for the Farmer to block our path once we enter the field. Here's its config:
http://picpaste.com/pics/02-J5vDKG6C.1490545727.png
As you said, there's probably a much more elegant way to do this, but that's what works for me for now. If with the info from this post you could suggest how to approach it most effectively, I'd be very grateful.

The Farmer-related event has 4 pages:
http://picpaste.com/pics/03-oHJL9odX.1490545760.png
This first one is basically just greeting the character and telling him to gather 10 corn.
http://picpaste.com/pics/06-lazbUkq8.1490545787.png
4th page just tells the NPC to move one down and 2x right when the player passes through the trigger, locking the player in the field.
http://picpaste.com/pics/04-mgwWlqoW.1490545815.png
http://picpaste.com/pics/05-dEERJgNi.1490545843.png
Page 2 and 3 are doing almost the same. They are supposed to end the quest: give the player 10 gold, take away all his corn and move the Farmer back to the original position. The difference is the text that displays when the player has exactly 10 cobs or 11 and more.

So here's how it all works:
a) we can approach the NPC and it gives us the initial text - works perfect
b) when we enter the field, the NPC blocks our way - works great
c) as long as we don't have 10 corn cobs, the NPC repeats the initial text - works perfect
Problems appear now:
d) when we get 10 or more corn cobs, the NPC repeats the initial text (and I'd like it to use one of the other lines) and then it moves away, but tries to repeat the movement twice, getting stuck in the corner
e) when approached in the corner, the NPC actually uses the text from page 2 or 3 correctly, gives us cash and takes away the corn as intended.

I'd like the Farmer to just check for the corn and if it's there, take it all, give us cash and unlock the path, all in one step. Can anyone point out what I'm doing wrong?
The control variable command like you used it will get the number of the corn in that specific moment - that is zero when you first talk to the farmer, and it will remain zero until you use that command again when next talking to the farmer - and that is not exactly how you want it.

On the first page, only have the show text and then use a control self-switch A = ON
On the second page, only have condition self-switch A, no other condition, and the following commands:
1) control variable = number of corn in inventory
2) conditional branch, variable >=10
if yes, remove the corn from inventory and show text "good work", then set move route to the event itself to move away
additionally, make a switch "quest completed" if you need that
if no , show text "you don't have enough corn

that's the basic, but it might need some more follow-ups depending on the rest of the game and if you need to pass that map later again.
I think I did what you described, but it's not working properly. What did I do wrong this time?
http://picpaste.com/pics/07-cWlRe8uz.1490555851.png

Also, can if-else in RPGM work like this?
if = 10 do x
if <= 10 do y
else do z
1) what is on page 3? that is most probably breaking it, because I just described two pages above,´. And higher page numbver means higher priority.
2) yes, conditional branches cen be nested - the second if would go into the else branche of the first one.
Just deleted page 3. No change, still doesn't work.
then describe what it does and what you do at each step.

One tip: always name your events, there is a reason why it has a name by default. One possible problem is that you targeted the move route on the wrong event, in case you have several events without names - if it had a name, the event command would display that name to tell you which event it is targeted on.

And post a screenshot of the first page in case you did somethign wrong there and never activated the second page correctly.
It just always goes to else and displays the else text. It does nothing from the if <= part - no gold added, no corn taken away, no text displayed, no movement. It would point to the control variable not being read correctly. Is this part correct?

http://picpaste.com/pics/08-Y3TvqDzs.1490561090.png

And yeah, I named the event and switched the move part's target from "this event" to "farmer", but the bahavior hasn't changed.
That can only happen if the number in the variable is not high enough - please use show text to display the number in the event.

It could either be too low because something else (like a plugin) uses the same variable or because you miscounted somewhere.

EDIT: I found your problem, you made the control variable wrong (if it is the one in your second screenshot)
I told you to use the game data option to get the number of the items, not to set the variable to itself with the variable option...

select game data, then click on the button to the right of the default setting "Map ID" and change that to the number of the item in inventory
Whoa! It worked. Thanks a lot, I understand it much better now. And in the meantime, I've refined the movement trigger, so in total, I'm down to 2 event pages from 4 and no (known to me) hacks 🙂

First quest in RGPM complete 🙂
Back with the last (hopefully) question about this quest 🙂

The way it's been configured now, it is a one-time only quest. Once you're done, you cannot repeat it. I'd like it to be a repeatable one. Like every time you enter the map, you can start it over.

I used "Erase event" in the if function sections that actually end the quest and it almost worked, except the NPC now disappears completely after the movement is finished. Any other way I could do it, without despawning her?
The farmer will automatically reset to the original position after reentering the map, so there is no need to change anything about the move routes - all you have to do is to reset the variables in a way to reset her to the first page.

Had I known you want to repeat the quest, I would have made the event differently - but that would probably confuse you now, so I'm just describing a different mechanic for resetting..

Two changes:
1) change the farmer event to use a regular switch instead of the self-switch I asked you to use above. Name that switch "corn quest active" or something like that. You need to change both the control self-switch command into a control switch command and the condition on the second page from self-switch to switch.
2) make an autorun on the map somewhere out of reach that contains two commands only: control switch "corn quest active" OFF and erase event

That should do it, also it will cause some problems if the player can leave the map before completing the quest.
Thank you! Out of curiosity though, and since I would probably like to do more of these repeatable quests, what would be the correct way to do it? (if that's not too much trouble)
Basically if you wanted a repeatable quest, you'd have an initial event page for the farmer where you get the introductory spiel, then turn self switch A on. Make a second page where they offer you the quest etc. When you complete the quest, turn self switch B on. You'd then have a 3rd page in the farmer event for completing the quest, then TURN SELF SWITCH B OFF. That will reset the quest to its initial offering state, but won't cause the introductory spiel to repeat.
there are different ways to do this - Trihan's method would work in most cases, but in this case it would result in the farmer giving the quest again as soon as he moves out of the way and before the player reenters the map.
That's actually a good point. You'd need an additional middle page for "got the quest but not finished it yet".
and as I did an autorun on map entering for resetting that farmer event, because otherwise it would stay at that middle event...

The reset needs to happen on entering, otherwise the quest could be repeated after completion but before leaving.

Original thread: https://forums.rpgmakerweb.com/threads/event-conditions-10-units-of-an-item.76394/