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

  • > I would have thought the the tree_sprite.UID would change as I select different sprites/trees.

    It does - but your Global variable Tree_UID is never used.

    I thought I did in steps 4 and then 5. Did I not use the pick value correctly?

  • Ah I see the problem, maybe. You're confirming this from the text object? That's only going to show the stats for one instance. If you look in the debug viewer you'll probably see variables are correct.

    I think I'm following you here and took these steps along with screenshots.

    First step, selected the first tree, clicked up arrow to add 10 to instance variable "leaves". Global variable Tot_trees also increased 10.

    Next, selected a different tree, clicked up arrow to add 10 to "leaves" (iv) and no increase occurred however as designed, Tot_trees (gv) went up 10.

    Last, selected first/original tree, clicked up arrow to add 10 to leaves (which it did) and Tot_trees went up 10 as well.

    Only the original tree has the leaves (iv) increase, not any of the copies.

  • Tree_ID is the global variable which is set when I left-click one of the trees and capture the sprite's UID [tree_sprite.UID]

    I would have thought the the tree_sprite.UID would change as I select different sprites/trees.

    How would I capture the value of the sprite so I can increase just that sprite's instance value (leaves) and not the leaves value on any of the other sprites?

  • So I went back and deleted all of the sprites from the layout. I then added one tree and copy/pasted it 3 times to have 4 trees total. I can replicate the issue over and over. The original tree will have the instance variable increase however the 3 trees I copied will not have their instance variable increase. The global variable Tot_leaves also increase when I click each tree.

    Is the issue with the way I'm adding sprites (copy/paste)? Using C3 302r stable

    The Tree_ID (gv) changes as it should when I click the tree however the UID remains at 2.

  • If those are the only events I don't see how it can go wrong

    I appreciate your time and appreciate a vet like you replying but it is going wrong which I can't explain. Do you see anything programming wise that should be done different?

  • I would guess you are changing your currently selected tree somehow.

    First, thank you for taking the time to reply. I appreciate it.

    I have the code set so that when I left click a tree, the Tree_ID global variable is set to the Tree_sprite.UID Then when I left click the up arrow, the Tree_ID is used to add 10 leaves. Maybe I'm not selecting the tree correctly?

    Open your game in Debug mode and pay close attention to where your code breaks down.

    • Can you successfully click a tree and store the Tree's UID in Tree_ID (bad naming convention going from UID to ID but I didn't notice any mess-ups from this in the code you showed).

    Absolutely fair. As late in the night as it was and with the frustration with the other project, I went with the dirty to try and figure out why I was struggling. But, fair point and one that I will take better caution wit.

    Does the UID match the tree it should match? It does. The text box is updated every second and the UID matches as I click back and forth between the trees.

    Can you click on the upgrade button and keep that same UID saved?

    When you click the upgrade button does a different tree gain leaves? Does Tot_leaves increase? When I click tree with UID 2, the leaves instance variable will increase however when I click on UID 3, it does not. However the Tot_leaves does increase regardless of which tree I select, which it shouldn't if UID 3 is "broken".

    These will all help you realize where your code is breaking down

    I'll try some other things but you don't see anything in the coding that would prevent it from running as expected? Or do you have a different approach that you would suggest?

  • Greetings all. I'm having the worst brain cramp on this and need some help. I've gone through demo's, tutorials and previous questions. Mental block still there.

    Essentially, I want to increase the number of a sprite's instance value. In the example below, I'm adding 10 to the "leaves" (instance variable) to a tree (sprite). But all the trees are getting the 10 when I add them. Below is the latest version of the code and any help getting me through this would be appreciated.

    I put two trees on the layout (created one, copy/pasted to make a second), added them to the Trees family and created 3 instance variables.

    Thanks everyone!

  • Hey everyone. Looking through the various game templates and examples on C3 and didn’t really see a turn-based strategy game like Civ. Figured I would ask the group if they knew of one as I’m curious how to design/program the opponents in the game being developed.

    Thanks!

  • Hey C3 World!

    Got a little turn-based game here and I'm trying to create a "summary" sprite font box which includes what actions will take place when "end turn" is pressed.

    Field 1 (Orchard) - list

    If apples is selected, I'd like the summary box to show "+2 apples". If oranges is selected, "+2 oranges" would appear.

    I've tried a couple different methods and the screenshot shows the latest trial. It adds the +2 for whatever is selected however if I change the selection, the previous choice isn't replaced. Not sure how to clear the previous choice and use the current option. There are a few fields/lists that will be adding to this summary box.

    Any help would be appreciated! Thanks all.

  • You do not have permission to view this post

  • Hey Construct world!

    Trying to put a little game together that has a 10x15 buildable grid (map) where players can place different blocks (2x2, 3x3) within the grid area. Does anyone know of a tutorial on CS on how to put that portion together? Not looking for a tutorial on the entire game model.

    Thanks all!

    *Updated* - I found this template to purchase (https://www.construct.net/en/game-assets/game-templates/city-builder-98) which is a full package but I thought there was some guide to show you the basics of a large area that could have smaller blocks placed within that area...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You're awesome! May need to get you another coffee, my friend.

    Taking what you provided and mixing it with this example (what dop2000 posted in this question > construct.net/en/forum/construct-3/how-do-i-8/array-change-text-value-169551), I've got a better idea of what's going on and can test without asking more dumb questions.

    Will update accordingly, but thank you for the quickness of the reply and info.

  • Quick snap of the rough draft. Wanting to show the array in a text box so outcomes of the upcoming actions are easy to see, however not sure how to program this.

  • Hey Lionz. I appreciate you replying and excited to work with you again.

    I overstated how far into this array I was and need to back up some. I am only designing this array at the moment in CS3 using these as guides.

    construct.net/en/tutorials/arrays-beginners-170

    construct.net/en/make-games/manuals/construct-3/plugin-reference/array

    I added the array object to the project with the default width/height/depth/elements settings 10/1/1/10 respectfully.

    If I view this like an excel spreadsheet, I foresee needing one row for the cows, one row for health.

    Is this the correct design (I gather that the cows could be listed by height and the health in a second column)? I want to make sure the health is tied to that animal so that when I run an action against cows with under 50 health, the right cows are selected.

    Thank you for your help!

  • Hey CS3 world!

    Question on best way to approach this situation. Got a game where animals are born (added to an array) but a sprite isn't created. I'm curious how to reference one of the values of the animals in the array (age) so that when the value reaches 50, that animal can be sold.

    Thanks all for your help!

    Tagged: