Guys, I’ll try to identify my problem that I haven’t been able to solve for a while. I think it’s a silly mistake of mine, but it’s already pissing me off
All my rooms are individual objects, and when there is a special item in this room, the game map changes color. So far so good, it works well. The problem is how much I have more than one item in the same room.
Watch the video for you to understand better:
Note that in the third room, I have two important items, but when I get the first item and access the map, it already changes color, which shouldn’t happen.
Legend of my objects:
gMap = Game Rooms
obj_map = game map
Basically what the code does is: It checks if there are items in the room, if so, the map with the ID equal to the room will receive variable 1 that says to change color.
obs: I don’t delete the items from the room, I just hide them, I have a purpose for that!
At a base level, it seems like you have an ID conflict somewhere. Have you checked with the debugger to see what the global variables are getting set to?
What really should happen is:
If any key items (regardless of how many there are) are in collision with the room and the key item is visible, the map must receive variable 1 (active), otherwise it receives 0 (inactive).
Hmmm… the other thing that could be going weird is you’re using multiple “for each” loops. There’s a very good chance your actions could get out of sync because each “for each” loop is cycled in entirety before it goes to the next.
You might try making a single “for each instance of gMaps” and put your other events as subevents of that.
It still looks like some kind of ID conflict, but it could be related to that as well.
And so you can see how it’s not an ID conflict, I’ve randomly changed a scene variable to get how many can still be seen in the room. And the result is the same.
And so you can see how it’s not an ID conflict, I’ve randomly changed a scene variable to get how many can still be seen in the room. And the result is the same.
Can you add more context here? Because I’m not seeing that in your events.
Your events say “if any obj_item_key has an ID less than 13 and is in collision with the room, set this other variable to 1”
You aren’t doing any check on “how many are still in the room” as none of your conditions are a counting. They are just checking the value of the ID is less than the number you specified. Not a total sum of IDs, is that what you are expecting?
Also, you absolutely still need the “for each” event. Just a single one that is a parent event.
What I need is: Check if there are visible items in the room, these items must be under ID 13 (each item has an ID that goes up to 13, ID 14 is another item) and are in collision with the room.
I tried to use count, but since I didn’t delete the items it doesn’t work.
I will try to take a look later today, but remember that events happen in order, as do conditions and actions.
At bare minimum since you are doing a check on gmaps, your collision check likely (not guaranteed) needs to be the first condition within the event otherwise your object list may not narrow correctly.
Not likely to be the only issue, but I’ll take a look.
I’ll check it out tomorrow, I can’t work today. But anyway, the google drive link with the file as it should be is there!
EDIT: @Silver-Streak. I saw your code and it does the same as mine, in this example of yours I need you to paint the box only if both keys are in hide. That is, if there is still a visible key, the box does not paint, but if the two keys are invisible, then it will be a different color.
My code does what you’re asking. The example has 1 key that is greater than ID 13 as a test. If you set both to an ID less than 13, it will not recolor until after you get both.
See my example! It’s the same programming I have in my game! Forget ID 13, just keep in mind that the count should decrease as soon as an item in the room is picked up!
Left Crate now has 2 keys with IDs < 13, 1 key with ID > 13, right crate only has keys with IDs < 13.
Each crate only changes color when you hide all keys in collision with that crate with an ID < 13.
Edit: Note, you will not be able to use “Count” in any form if you’re going to reduce a number to 0. Count will not return a result if the object list is empty, so it’ll never return 0.
See that when I enter the blackboards, it indicates whether there are items or not, when I take the one on the left, the message changes to no items. But that doesn’t happen on the right! It changes on the first item I get… And that I don’t want to happen!
Sorry @Silver-Streak, I don’t think we are getting along!
I just need to show, how many items are touching my “gMapa” object.
Independent of object ID. I just want to know how many items are left for me to collect that are in collision with my “gMAPa”, Then when all are collected, from that specific “gMapa”, I need a message to know.
If the number of items remaining matters, not “there are/are not items remaining”, you’re going to need to do a manual count in a variable at the start of your scene, for each crate, via events, and update that variable as you collect each one. This is because the Count expression/number of object condition can only count objects that exist (as in exist within a condition set, not physically exist in the scene), so if you have 0 items that apply, it won’t work.
However, for your base desire “When there are no items left to collect, show a message”, my events do that.
You can ignore the ID side of things and it’ll still work fine. Here’s an update with the ID stuff removed.