lionz's Forum Posts

  • In a collision or overlap event you can make use of system Pick nth instance, where instance 0 and instance 1 are the two involved in the event.

  • Alright no problem. And just to clarify my first few responses on here are in reference to saving or storing that data. So the tilemaps you are drawing to create the racetrack, you can save the tile positions as a string of data, that's what I originally thought you meant by reusing.

  • If you go to the layout during runtime then yes.

  • By full array I meant all the data available not that it must be full of scores. You can sort it whenever you want but I guess after adding all data which I assume you do on start of layout? I also thought you had done sorting already because you mentioned it earlier? There is an array sort which puts them from lowest to highest, you use this, then you use array reverse to put them highest to lowest.

    As for the int conversion, i said to put it inside a for loop. All this logic can go within the other event you had for filling the array as long as its done after. You use a for loop to run through all scores in the column and convert them to int. You can do this on a button click but you need to add the for loop as mentioned above as a sub event otherwise loopindex does not mean anything.

  • It's fine to use an array for tracking but my point is if you use instance A and instance B of farm, you will still be using variables so the array is just for holding all the data. The idea is on creation of the building you set the array identifier to 1, then increase it in general by 1 (this would be a global variable to compare against), so when you create the next farm the identifier is 2. The identifier links to a row in the array so you can have all buildings in there. As for a log of the days activities you could total up a column of units produced etc

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Oh yeah that was the issue, sorting. It's been a while so I had forgotten.

    Yes the array needs to be full first, do you know where that logic is and when it has all the data?

    Once full I would use something like this to convert back to int, this logic assuming Y=0 and Y=1 are values to turn back to int :

    System for from 0 to array.width : array set value at xy(loopindex,0) to int(array.at(loopindex,0))

    System for from 0 to array.width : array set value at xy(loopindex,1) to int(array.at(loopindex,1))

    That should convert all the string numbers to ints that can be properly sorted

  • Adjusting the layers to be consistent was only a possible fix for the player appearing behind objects, is that fixed now? You didn't mention it. The extra objects appearing, there is probably a simple reason but it's only speculation without seeing the file.

  • Not sure if array is totally required for this although it could act as a way to view all data. In the end you will be pulling variable data into the array and those variables would be good enough. So a farm would have production type which is a string variable, number of stored or created products, production time/speed as number variables etc.

    If I was to put all this data in an array, what you can do is give each building an identifier which is the position or row in the array. Then with logic you link up the building's values to the array, so type = array.at(building.arrayposition,0), production time = array.at(building.arrayposition,1). This would allow all buildings to put their data into the array with very little code.

    Also I would advise putting all buildings into a buildings family for this, so you do not have duplicate code referencing different buildings, farm.arrayposition,0 and mill.arrayposition,0 become building.arrayposition,0 if you use families and family instance variables to group them.

  • Now that I think about it some more you might not have to convert them to int, should just display fine as they are in the array? You just need to put the text logic separately without the int.

  • So it's a guessing game? Level 2 probably has fewer layers so the player moves to a lower layer and is behind objects. The extra objects are either because you added them in the level 2 layout (you shouldn't if objects are global as they continue through), or you have logic that creates the player and crosshairs 'on start of layout' which you also don't need if the objects are global.

  • I'm confused myself. You're supposed to place it in the level. When you do this it is an instance of the same object so the same tilemap. Then you can draw on it with the same tileset as before. At the moment you're just clicking on it on the right side? It doesn't show up by clicking on it, you have to place it in the level. When you place the tilemap in level 1 you are creating instance 1, when you place the tilemap in level 2 you are creating instance 2, of the same object. You can draw on them separately in each layout. You don't for example need to create a second tilemap object.

  • The second image doesn't seem to show a tilemap placed in the layout or selected. Usually if you do that in another layout it has the same tileset image loaded with it because it's the same object.

  • When you say you want to reuse the same tilemap what precisely do you mean?

  • Ya I tell you above, instead of random use 'choose'. This is what you are looking for to choose between the 2 options yes? Replace random with choose.

  • Which tutorial? choose(a,b) allows you to pick between 2 things. Add this where you set the variable to right.