kyshaws25's Forum Posts

  • Thanks oosyrag. Before I spent a lot of time testing with that, I wanted to make sure it was an option.

    Take care!

  • Hey C3. Instead of a number for the timer end, I've tried using a variable which hasn't seemed to provide the desired outcome. Does anyone know if a variable can be used versus a number?

    Example below shows a number however I was hoping to use an instance or global value.

  • You do not have permission to view this post

  • Genius! That gives me a working model to reverse engineer and adapt to my sandbox.

    Thank you much! Link to buy you a coffee?

  • Hey there. Just opened up your example and it appears you used version 410 and I've got 407.2 so it won't open. Where did you download the newer version from?

    Found 410 (I had 407.2 installed locally so I could use it when I have to fly or camp). Diving into it now.

  • Yes, your assumptions were deadly accurate!

    Thank you so much for the file to explore further. I'm out of town until tomorrow morning and promise to dig into your example then. I appreciate your time and help with this!

  • Hey C-world. Below is a screenshot of my sandbox where I'm trying to figure out how to write the condition so that:

    • All boxes with the boxes.onteam variable that equal yes
    • must also have the boxes.coins variable equaling 1000

    What's happening instead when I click the arrow box, is the boxes that have the .onteam = yes are subtracting their coins if .coins is greater than/equal to 1000.

    Expectation is - If all the boxes that are .onteam = yes don't have .coins => 1000, nothing should happen.

    I can't figure out how to write that condition. I've tried "for each", without "for each", etc with no success. Any help is appreciated.

  • Thank you both for solid options!

    Cheers

  • C3, hey there. I did this before but can't find my notes so I'm just going to ask.

    Every second, coins variable increases by 4. I want this to continue until it reaches 90 which means one of the increases has to be 2.

    So frustrating as I did it before. Assistance appreciated.

  • Is that right?? Ugh... Thank you for the explanation. I had no idea what impact (if any) the list of conditions made but man does that help a lot. I appreciate the insight.

    If you're talking efficiency, when ever you use a foreach object, you should put it last in the conditions list of the event line.

    The difference is at the top it will loop over all objects and the actions will apply to any object that meet the conditions below it, where as if its on the bottom it will only loop over the objects that already meet those conditions.

    It wont make any difference with a small number of objects, but if you happen to be using hundreds or thousands of objects then it makes a difference if the conditions only apply to a few.

  • Thinking it through, I didn't explain it very well.

    1. Spawn a sprite (box) per box spawner (done manually until I can set it to be completed by a function and timed) - there are 6 spawners.

    2. Generate values for several variables of each box (weight, strength, capacity, item(s) inside, etc)

    3. When the box is selected, must complete action with that box which then sets selected back to 0. Only one box can be selected=1 at a time.

    4. While box is selected=1 and other boxes are spawned, the selected=1 shouldn't be destroyed.

    Think of character entering shed, random # of boxes to explore, picks one to take, can't take another until the one selected has an action (drop, destroy, de-select). Can still look in other boxes but can't pick it up (select it).

    I don't necessarily need to recreate/respawn the boxes as long as the values were reset by the trigger (button clicked) however the long-term plan is eventually a random amount of boxes be spawned instead of the 6 each time.

    Did the explanation help some? As I wrote it, Project Zomboid comes to mind.

    I like your coding as it's obviously cleaner than what I had and gives me something to test with what I'm trying to accomplish. I'll see if I can post a mock-up of the code shortly.

    Well I still don’t fully understand how you want it to work. I’m guessing you have a box per spawner, and you can select a box. Then clicking a button will create/ recreate the boxes that aren’t selected.

    Global number pickedBox=-1
    
    On box clicked
    — set pickedBox to box.uid
    
    On spawn_button clicked
    [negated] box: pick by uid pickedBox
    — box: destroy
    
    On spawn_button clicked
    [negated] spawner: overlaps box
    — spawned: spawn box

    If you set it up in the layout so each spawned has an overlapping box to begin with then the last two events could be merged into

    on spawn_button clicked
    [negated] box: pick by uid pickedBox
    Spawner:overlaps box
    — box: destroy
    — spawner: spawn box

    But then I wonder if we need to even recreate the boxes at all.

    Again that’s why I don’t think I fully understand fully what exactly you wanted it to do.

  • Hey there! I absolutely agree about the simplicity side of the coding. This project has gone on for almost 2 years and I frequently run across a section I did 18 months ago when I didn't have the experience. I tend to redo portions because of wasted coding and lines // streamlining things. This might be another learning experience for me.

    This coding above is my sandbox. I'm trying to replicate the scenario in my larger project of having several sprites to choose from. When you pick one, it becomes "selected" and only one sprite can be such at a time. While you perform actions on that one, you can refresh the choices but I didn't want the selected one to be deleted.

    I couldn't figure out how to delete the sprites that weren't selected, generate new sprites and all in the designated areas. You obviously know your way around development so if you have any thoughts, I'm smart enough to know when to listen/read.

  • Final product which allows the system to set the "occupied" instance variable instead of entering it somewhere else. I try to use the KISS method as often as possible (keep it simple stupid). Less variables to keep track of.

  • Say what you want but how silly an additional instance variable had to be used to help "if sprite.x isn't overlapping sprite.y" condition. I would have thought that condition could stand on its own. Solution found regardless, hopefully this helps someone else trying to find it on their own.

    This post from Dop2000 put me in the right direction

    https://www.construct.net/en/forum/construct-3/how-do-i-8/spawn-random-not-overlapping-152676

  • Closer but only 4 instances of boxes should exist at a time (one off screen, three spawned by the spawner). However if I set one of the boxes to "selected = 1", five instances exist the next time I run it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads