Two "Right mouse Button" clicked events run at the same time and Sub-event issue (Crafting).

0 favourites
  • 3 posts
From the Asset Store
Very simple code without excess options (15 events for server and 11 events for client)
  • I've been trying to fix these issues since yesterday so I would greatly appreciate any help.

    Project File: ufile.io/ml3lpg4g

    Inventory Bug

    (Two Right mouse Button clicked events run at he same time):

    When an item is taken from the Inventory and when you hover over an inventory slot, RMB on it should only drop one item into the Inventory Slot, but instead it drops 2 items at first into the Inventory Slot and then you can normally keep adding 1 item on RMB clicked (When the Mouse is over an Inventory Slot of course).

    Subscribe to Construct videos now

    The problem here is the Second Right button Clicked Event runs as well, even though only the first one should run, so it adds one item and then immediately another. But after that you can continue adding one item at a time with RMB clicked.

    Crafting issue:

    Subscribe to Construct videos now

    As you can see the crafting doesn't work, and that is because only the parent event runs and checks if 1 stone is on the Slot number 10. Even though that is true, its subevent doesn't run to check if 1 coal is in Slot number 11 to give a new item in output. How could this be approached?

  • Hello,

    I haven’t opened your project file but here are some thoughts:

    For the right click issue:

    I’d remove the wait actions. They just complicate when stuff runs.

    When you right click, the two right click events are run in order from the top down. So the first sets stuff up so the second can run. Maybe using one right click event and else in sub events would be a workable solution.

    On right click

    — slot empty ?

    —— place object in slot

    — else

    — — add one to item count in slot

    For your second issue it’s basically you want to pick two instances at the same time. There are two strategies for that.

    One is to pick them one at a time, save the info you want to some variables and then pick the other. IIDs are useful here sometimes. So that would look like:

    Variable firstObjColor=0

    Some event

    — pick a object

    —— set firstObjColor to object.color

    — pick a different object

    — object.color = firstObjColor

    —— console log: can craft

    Or if you want to use an iid to make picking the first object later easier:

    Variable firstObj=0

    Some event

    — pick first obj

    —— set firstObj to obj.iid

    — pick other object

    — obj.color = obj(firstObj).color

    —— log colors match

    Anyways the other way to handle picking two instances of the same object type is to make a family with just that type. So if the object is “sprite”, make a family, add sprite, and call it “otherSprite”

    Then you could do this:

    Sprite.x = 100

    OtherSprite.x=200

    — do something

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you so much for taking the time for making such a detailed solution! They worked perfectly and are pretty neat =] Thanks again R0J0hound!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)