6bf85f30-2578-4227-841b-41a0007077df's Forum Posts

  • More progress but I can't seem to get the behavior to work on all four sprites (all in the family). Maybe 3 of the 4, sometimes 2.

  • wackytoaster.at/parachute/picking.c3p

    Here's a basic setup. Keep in mind that there are countless ways to "pick" your instance and it's up to you to find out what your game needs. Here's some links so you understand what I did.

    https://www.construct.net/en/make-games/manuals/construct-3/interface/layout-view#internalH1Link4

    Picking instances

    https://www.construct.net/en/make-games/manuals/construct-3/plugin-reference/common-features/common-conditions#internalH1Link7

    https://www.construct.net/en/make-games/manuals/construct-3/system-reference/system-conditions#internalH1Link7

    Things like "compare instance variable" will also pick all instances that match. E.g. Instance variable > 5 will pick all instances where food > 5 or compare X < 100 will pick all instances that are X < 100 on the layout.

    And obviously you can chain picking to filter out more and more instances until you are left with one (or more if you need)

    E.g. pick instance variable > 5, pick instance variable < 10, pick lowest

    Will first pick all instances where food > 5, then from those all where food < 10 and than from those it picks the one lowest on food.

    Progress as I've been testing and building off your example. Here's a new question for you.

    What would the coding look like for the system to detect if one of the sprites have a food value (instance variable) of 1 or greater and if so, do x (in the below example I have a new yellow sprite created)? I've been trying various combinations of code but no success yet.

  • Your reply and contained information ended up being a huge help! When I saw your name pop-up as viewing the post, I knew help was on the way. Thank you!

    What I was struggling to do was use the right "terms/code" to find the value of the instance variable of one of the sprites. Through sheer luck (and His guidance), I found the right coding.

    With what you provided, I'm going to expand on the game now instead of spending hours figuring out which way to hold the mouse and keyboard.

    I did have one item I haven't been able to figure out. How would one configure a text/sprite font box to reflect the value of the instance variable of a sprite? For now I'm using the Black Arrow overlapping the sprite which sets the text box but there has to be a way that would reflect it constantly without needing to use the overlap method.

    Man you nailed that with the example you provided!! I know it looks simple but to this caveman, it's like FIRE!

    Again, I know I can't buy you a coffee/beer but I sincerely thank you for your time.

  • Shortest version of this question possible. How can I add 1 to a particular instance variable of the sprite I've selected?

    There are 3 sprites in the same family, all with instance variable: Food. I want one of the sprites to get +1 food and somewhere show this sprite has ## food now and the other two sprites have 0.

    How?

    I've spent 2.5 hours watching C3 Youtube vids, tutorials, backwards engineering C3 built games and I don't get it. Patience with explanation is appreciated.

  • To ensure smooth picking I use a 'for each sprite' loop with a 'for each family' nested and there I add the condition to compare the variable.

    Hey there. Trying anything I can to learn this "instance-variable" function. Is it possible to have a snippet of code added to show what you mean (and why), please? Thanks.

  • You do not have permission to view this post

  • You do not have permission to view this post

  • Seriously thank you both for your time and guidance!

  • Are coal mine and oil pump members of the Minerals family?

    I think you need to change the last event on your screenshot like this:

    > Button on clicked
    Block pick instance with UID SelectedLocationUID
    Minerals is overlapping Block
    Minerals destroy
    ...
    

    Also, it's not very efficient to re-create the buttons all the time. You can build the whole menu on the layout with hierarchy, and created/destroy it with a single action.

    Makes me happy/frustrated you saw the fix so quickly. Moved the code around to match what you had and poof! It worked. Thank you so much!

    Also, the menu with hierarchy is a little ahead of where I am but will look into it next. Of course expect a question in the forum from me when I do.

  • Either remove the block is overlapping minerals or add a pick all block before pick by uid in the last event.

    Thank you for your time and help!

  • Thank you both! Almost done for the day and can come home and test out these suggestions. I appreciate your help!

  • Hey there!

    I decided to take a couple days and refresh myself with the tutorials and review a few of the games others have submitted (seriously some talented people on here!)

    With that said, I'm trying to understand how to delete/destroy an object using the UID (maybe it's not possible, don't know). For this example, I have 3 building blocks (sprites) that provide the player the option to build an oil pump or coal mine. Each block can be something different.

    Once you build it, if you want to switch to something else, you have to first destroy it and then choose what to build there. I've got the building part down but not the destroy. I assumed it would be similar commands but I'm missing something. Any help would be appreciated.

    (There is a global variable at the top called SelectedID = -1

  • I prefer tiled background, here is a demo:

    https://howtoconstructdemos.com/simple-healthbar/

    I don't know your game, so not sure what will be the right way to pick Minerals instance. If only one mine can be built at a time and you only need one progress bar, you can pick by UID or custom ID variable.

    If you need a separate progress bar for multiple mines, you can link them with hierarchy, or put in a container, or use MineUID instance variable on the bar object.

    Good morning!

    I'm glad you posted that demo as it's the one I've gone through it's the one I thought I had reviewed.

    The problem I had was that there could be multiple mines/structures that could be built, eventually with different build times. So I wasn't sure how to get the progress bar (or it's equivalent) to show for different builds.

    Testing it now to see if I can figure out how to associate it to different builds.

  • Thanks for the info and reply.

    Do I add the “selectedID” to make it pick the right instance?

    So a sprite or tiledbackground? Interesting approach!

  • Hey everyone!

    When a mine is built in one of 15 spots, a progress bar is created (CoalMineConstruction) with the x/y of where that mine is. There is an instance variable on the coal mine (buildstatus) that is incremented +25 every 5 seconds until it reaches 100. When it hits 100, the progress bar is destroyed.

    This increment is showing up on the initial coal mine, however if another mine is built, the value for that shows as full. How do I reset the buildstatus for the others that are built after?

    Snapshot of what I'm trying to make work: